nyx/tests/dynamic_fixtures/header_injection/rust/vuln.rs
2026-06-05 10:16:30 -05:00

17 lines
640 B
Rust

// Phase 08 (Track J.6) — Rust HEADER_INJECTION vuln fixture.
//
// The function inserts the attacker-controlled `value` into an axum
// `HeaderMap` via `headers_mut().insert`, bypassing
// `HeaderValue::from_str`'s newline check by passing the tainted
// bytes through `HeaderValue::from_bytes(...).unwrap()`. A payload
// carrying `\r\nSet-Cookie: nyx-injected=pwn` splits the single
// header into two on the wire.
use axum::http::HeaderMap;
use axum::http::HeaderValue;
pub fn run(headers: &mut HeaderMap, value: &str) {
headers.insert(
"set-cookie",
HeaderValue::from_bytes(value.as_bytes()).unwrap(),
);
}