DedSec Security Research ·
Here is a hypothetical. A dynamic scan of a staging environment returns three findings against endpoints that put request data into response headers. The first, titled "HTTP response splitting" and rated high, is on /set-lang?lang=, which sets a language cookie and redirects. The scanner sent a value containing an encoded carriage return and line feed followed by a second header, and in the raw response it saw that second header on its own line. The second, titled "CRLF injection" and rated medium, is on /go?next=, which issues a redirect; the scanner found its marker inside the Location header. The third is on /track?ref=, which writes the ref value into a response header, and the scanner reported it clean because its payloads came back with the carriage return and line feed still visible as text in the header value.
The first gets escalated, because high is high. The second is assigned to a developer, because the marker is "in the header". The third is never looked at, because nothing split. As in the earlier posts in this series, each call rests on the title and the rating rather than on what the scanner observed and what that observation can prove. The first may be the only true positive, the second may be a reflected value that never split, and the third may be a value that splits once something downstream decodes it a second time.
This post is for whoever is holding a CRLF or header-injection finding from a dynamic scan, or a clean result on a header-reflecting endpoint that they are about to rely on. It covers what the mechanism is — how a carriage return and line feed in a header value can start a new header or a new body — the difference between header injection, full response splitting and the log-injection cousin, what CWE-113 is and the claim a finding has to support, why the serialisers we measured mostly reject the control characters outright and exactly where injection still survives, what a scanner's evidence must show to tell a split from a reflection, the false positives and the false negatives, the fix, and the static-analysis view. It is the tenth post in a series about confirming DAST findings, after reflected XSS, SQL injection, OS command injection, Nuclei template matches, ffuf content discovery, path traversal, open redirect, SSRF through URL-fetch parameters and XXE. It overlaps the open-redirect post, because a redirect is a common place a tainted value reaches a Location header, and the security headers post for what an injected Set-Cookie or redirect header can do.
Sources, and how each was checked. The measurements below were made on our test machine on 1 November 2026, in a scratch directory on an Ubuntu 24.04 machine, inside a Linux network namespace with only a loopback interface. We confirmed the isolation before the runs: a lookup of the external name example.com failed, so nothing left the machine. The software was Python 3.12.3 (Ubuntu package 3.12.3-1ubuntu0.17), whose http.server, http.client, urllib.request and http.cookies modules we exercised directly and whose header-validation source we read with the inspect module; Node.js 22.22.2, whose core http module reports llhttp 9.3.0 and undici 6.24.1; and curl 8.5.0. We wrote a deliberately vulnerable loopback server that reflected a query parameter into a Location and a Set-Cookie header through the standard library, drove it with curl, and read the raw bytes with cat -A so that every carriage return and line feed was visible. CWE-113 (improper neutralisation of CRLF sequences in HTTP headers), CWE-93 (the CRLF-injection parent), CWE-117 (improper output neutralisation for logs), RFC 9110 and RFC 9112 (HTTP semantics and HTTP/1.1 message syntax), and RFC 9113 (HTTP/2) are cited by name and described in our own words, because we had no copy of them on the machine to quote from. We did not measure Java, .NET, PHP, Go, any web framework above the standard library, any reverse proxy, load balancer or CDN, or any browser. Where this post says something about those, it is written as mechanism, not as a measurement, and it says so. The opening scenario is hypothetical, and no number in this post measures any scanner, ours included.
HTTP/1.1 is a text protocol whose structure is carried by one delimiter. The status line and each header occupy a line, lines end with a carriage return and a line feed — the two bytes written \r\n — and a bare \r\n with nothing before it ends the header block and begins the body. That single fact is the whole vulnerability. If an attacker can get a \r\n into a value that the server writes into the header block, they can end the current header and write their own; if they can get two in a row, they can end the header block and write their own body.
So the raw material is any request value — a query parameter, a path segment, a header such as a language preference or a forwarded host, a cookie — that the application copies into a response header. The classic sinks are a Location header built from a next or url parameter, a Set-Cookie built from user input, a Content-Disposition filename, a custom X- header echoing a request value, and any caching or language header derived from input. The weakness is not that the application sets a header from input. Applications do that constantly. The weakness is that the value crosses into the header's structure instead of staying inside its value.
Three outcomes sit on a spectrum, and they are worth separating because they prove different things and carry different impact.
\r\n lets the attacker add a header. An injected Set-Cookie sets a cookie of their choosing; an injected caching header can make an attacker-influenced response cacheable by a shared cache; an injected Refresh header redirects the user (an injected Location does so only on a 3xx response); an injected Access-Control-Allow-Origin can open CORS where none was sent; and with a double CRLF, the real security headers after the injection point are pushed into the body and lost. In the single-CRLF case the response is still one response.\r\n sequences, plus a crafted status line and body, let the attacker terminate the real response and write a second, entirely attacker-written response onto the connection. Where a cache, a proxy or a pipelining client reads that second response and associates it with the next request, it becomes cache poisoning or a cross-user effect. This is the high-impact end. Putting the second message on the wire was easy against the unvalidated writer measured below; whether anything downstream acts on it depends on components we did not measure.CWE-113 is the application failing to neutralise carriage return and line feed sequences before writing attacker-influenced data into an HTTP header, usually a response header. The consequence is one of the three outcomes above. The claim a finding has to support is narrow and checkable, and it has two halves that a scanner often conflates:
The gap between the two halves is the whole problem. "The marker is in the Location header" is evidence for the first half only. The measurements below show that on the runtimes we tested, the second half frequently does not happen, because the layer that serialises the header rejects the control characters before they reach the socket. A finding built on the first half alone is a common false positive in this class.
Whether a \r\n survives is decided by the last layer that checks the value before it becomes bytes. That is often the runtime's header serialiser and sometimes a framework or builder above it, so the framework name alone does not decide it. We measured that layer in two runtimes, on both the server side and the client side, because the same application-level mistake is caught in some of these places and not others.
Node.js 22.22.2 core http rejects it, in both directions. Setting a Location header to a value containing \r\n through response.setHeader, through response.writeHead, and setting an outgoing request header through http.request, all threw ERR_INVALID_CHAR with the message "Invalid character in header content". A bare carriage return and a bare line feed were rejected the same way. The check is in the header serialiser, so it fires regardless of which framework built the value, as long as the framework uses core http to send it. A value that was already the literal text %0d%0a — we sent %250d%250a, which the URL parser decodes once to the five characters %0d%0a — was written verbatim and did not split, because it contains no actual control character.
Python's outbound client rejects it; its standard server does not. http.client.putheader, and urllib.request which is built on it, raised ValueError: Invalid header value for a value containing a carriage return, a line feed, or both. Reading the module source explains exactly what is and is not caught: the validator is the regular expression \n(?![ \t])|\r(?![ \t\n]), which rejects a line feed that is not followed by a space or tab and a carriage return that is not followed by a space, tab or line feed. A \r\n that begins a new header line matches, and is rejected. This is the client that a server-to-upstream request, a webhook sender or an SSRF-style fetcher would use, so the outbound path is guarded against a CR or LF that starts a new header line, though not against the folding forms below.
The server side is the opposite, and it is the result that matters most for this class. http.server.BaseHTTPRequestHandler.send_header performed no CR/LF validation (only a strict Latin-1 encode). When our vulnerable loopback server copied a parameter whose value contained a carriage return and line feed into a Location header through send_header, the bytes went to the wire unchanged. Read with cat -A, the response was, one line per bullet (Date header omitted):
HTTP/1.1 302 Found^M$Server: BaseHTTP/0.6 Python/3.12.3^M$Location: /home^M$X-Injected: yes^M$Content-Length: 0^M$^M$ (the empty line that ends the headers)^M$ is a carriage return then a line feed. The injected X-Injected: yes is a distinct header on its own line, which is the proof the first half of the claim cannot give. A bare line feed alone was enough: a value of /home then a line feed then X-Injected: viaLF produced a Location: /home line ending in a line feed with no carriage return, and curl still read the following X-Injected: viaLF as a separate header. A lenient writer and a lenient parser each only need to accept the one byte.
The same writer also split the response outright. We sent the classic splitting payload (the injected header, an injected Content-Length: 0, an empty line, then a complete second status line, header and body) and read the connection with a raw socket rather than an HTTP client, because a client stops after the first message. The bytes on the wire were the 302 with X-Injected: yes and Content-Length: 0, an empty line, then HTTP/1.1 200 OK, Content-Type: text/html, an empty line and <html>splitpage</html>, followed by the server's own Content-Length: 0 header, now stranded after the injected body. curl, reading the same response, showed only the first message and stopped at the injected Content-Length. That is a server-side wire split; no cache, proxy or client was measured, so whether anything downstream would treat the second message as the response to another request is not something this measurement shows.
Set-Cookie injection fell out of the same mechanism. A /cookie route that built Set-Cookie: pref= + value, with a value of light then a carriage return and line feed then Set-Cookie: session=attacker, produced two distinct Set-Cookie headers on the wire: Set-Cookie: pref=light and Set-Cookie: session=attacker. The attacker set a second cookie of their choice. Note that Python's own cookie builder would have stopped this: http.cookies.SimpleCookie raised "Control characters are not allowed in cookies" for the same value. The injection survives only when the application formats the Set-Cookie header itself and sends it through the unvalidated server writer.
The lesson from the pair of results is the one that should drive triage: do not reason about CRLF injection from the framework name. Reason about the exact call that serialises the header. The standard-library server writer accepted everything; the standard-library client writer and both Node core paths rejected it. The same application bug is exploitable through one and not the other.
In the two runtimes we measured, the validated serialisers rejected the raw control characters; Java, .NET, PHP, Go and frameworks were not measured. The finding survives in the gaps, and these are the places to look before accepting or dismissing one.
send_header case above, a templated raw response, a minimal HTTP implementation, a custom proxy that reassembles headers — is outside the validated serialiser. This is the surviving case we measured directly.%250d%250a once and got the literal text %0d%0a; decoding that a second time produced an actual carriage return and line feed. If one layer URL-decodes a value into a header safely as literal text and a second layer decodes it again before it reaches the wire, the control characters appear after the check. A value that looks inert at the point of validation can split one decode later.http.client accepted values containing a line feed then a space, a line feed then a tab, a carriage return then line feed then a space, and a carriage return then a space. None of these creates a distinct new header at the sending client; to a recipient that unfolds them they are continuation lines of the same header. Only CRLF followed by a space or tab is obs-fold as RFC 9112 defines it; LF followed by a space is one only to a recipient that accepts a bare LF as a line ending, and CR followed by a space is a bare CR, which RFC 9112 says a recipient must treat as invalid or replace with a space. RFC 9112 also forbids a sender from generating obs-fold outside the message/http media type, so Python's client would send something a conformant sender would not, and recipients are left to reject it or replace it with spaces. An intermediary that handles these forms differently from the origin is where request-smuggling-adjacent problems begin. This is a measured acceptance at the client; what a given proxy does with it downstream we did not measure.And one place it did not survive in our tests. A Unicode code point whose low byte is a newline — U+010A and U+560A both end in byte 0x0A — can smuggle a line feed past a check if a later step narrows the character to one byte, a technique that has worked against some runtimes. In our tests, which covered only Python's http.client, it did not survive. Through http.client, which encodes header values as Latin-1, both characters raised UnicodeEncodeError rather than narrowing to 0x0A, and a real U+000A was caught by the validator regex. A Latin-1 strict encode of U+010A or U+560A refused; a UTF-8 encode produced multi-byte sequences (\xc4\x8a and \xe5\x98\x8a), neither of which contains a bare 0x0A. So on this stack the "high code point, low byte is a newline" trick did not produce a newline. It may on a runtime that narrows silently with a lossy cast, and the honest statement is that it is stack-specific and must be measured, not assumed.
A scanner that tests for CRLF injection sends a value with an encoded carriage return and line feed and a recognisable injected header, then reads the response. The finding stands or falls on one distinction: did the injected header appear as a distinct header in the parsed response, or did the marker appear as text inside a header value or in the body?
curl -s -i without following redirects, piped through cat -A, shows each header on its own line with its line ending; the injected header on its own line, with a real line ending (CRLF, or LF on a lenient pair) before it, is proof of the second half of the claim. An HTTP client's parsed header map showing the injected name as a key is the same evidence.Location: /home%0d%0aX-Injected:%20yes, with the sequence still percent-encoded, or Location: /home\r\nX-Injected... written as literal text within the value, means the value reached the header and no control character reached the wire. That is the second hypothetical finding, and on that evidence it is clean for this class (though see the third for why a clean reading is not the end of it), and it may still be an open redirect if the value controls the destination.The marker design matters too, for the same reason it does in the open-redirect and SSRF posts. An injected header with a unique, recognisable name, checked as a parsed header key rather than searched for as a substring of the raw bytes, removes the ambiguity between "a header split" and "my payload is sitting in a value". And the response must be read before any client normalises it: a client that silently drops a malformed header, or reconnects, can hide the very split that proves the finding.
And the false negatives, which matter more because they produce a clean result with no finding to triage:
The procedure below is general practice. Inject a header or cookie whose name you chose and that does nothing harmful; never smuggle a real second response at a system other people use, and never poison a shared cache you do not own.
curl -s -i without -L, piped through cat -A, shows every line ending. Keep this exact output as evidence.\r\n before it: header injection, confirmed. Marker still encoded or literal inside a value: reflection, not this class. Second full status line and body on the connection: response splitting.\r\n.\r\n. A lenient writer and parser pair may honour the single byte, as ours did.%250d%250a) in case a downstream layer decodes again, and check whether anything splits later in the flow.All of this is general practice. The root rule: never let a carriage return or line feed from input reach a header serialiser, and prefer the serialiser that enforces this for you.
\r\n and continuing is fragile, because a double-decode or an alternate encoding can reintroduce it after the strip. Reject the request, or reject the value, when it contains a control character where one is not allowed.http.cookies.SimpleCookie refused the control characters; a hand-built Set-Cookie through the raw writer did not. The same holds for any header with its own builder.Static analysis models CRLF injection as taint from a request value to a header-writing sink: a Location write, a Set-Cookie build, a generic add-header call, a log write for the CWE-117 cousin. The SAST false positives post covers the general failure of crediting a sanitiser against a sink it does not protect, and this class has its own version of it. The dangerous property is often a *default*: whether the sink validates. A rule that flags every add-header call fed by input will fire on every call that routes through a serialiser that already rejects control characters, which includes the Node core and Python http.client calls we measured (apart from the folding forms http.client permits), and a rule that assumes the serialiser always validates will miss the raw writer that does not. Being precise requires knowing which sink serialises the header, exactly as confirming the dynamic finding did. A URL-encode of the whole value is not a sanitiser for this sink if a later layer decodes it; HTML-escaping does nothing to a carriage return or line feed; stripping one occurrence is defeated by a double decode. The valid sanitiser is a reject-on-control-character check, or a serialiser that performs one, applied to the value that actually reaches the wire.
A confirmed DAST finding tells you that a deployed endpoint let a control character into a response header, but not which line built it or whether another path shares the flaw. A SAST finding tells you which call writes untrusted data into a header, but not whether a reachable route feeds it or whether the running serialiser rejects the control characters anyway. Each answers the other's open question, and both turn on the same fact: which writer, and does it validate.
\r\n is confirmation; an encoded or literal sequence inside a value is reflection.\r\n, and a double-encoded sequence in case a second decode reintroduces the control characters.Back to the three hypothetical findings.
In the scenario, the /set-lang?lang= finding was real. Read with line endings visible, the response carried a distinct injected header after a genuine carriage return and line feed, and a crafted payload went further and smuggled a second response that the shared cache in front of the application stored. The handler had formatted the Set-Cookie and Location bytes itself and sent them through a raw writer that did not validate. The fix routed both headers through the framework's validated response API and rejected any control character in the lang value, and the retest ran the full sequence, a bare line feed, and a double-encoded variant; none split. The rating stayed high while open, because it was genuine and it reached a cache.
In the scenario, the /go?next= finding was a reflection, not a split. The marker was inside the Location header with the carriage return and line feed still percent-encoded, because the application never decoded the value, so no control character reached the header at all; had one reached it, the response object's serialiser would have rejected it, as Node core did in our tests (it threw ERR_INVALID_CHAR, and our handler returned a 500). It was closed for this class, with the raw response attached — and re-filed as an open redirect candidate, because next still controlled the destination, which is a different finding with its own confirmation.
In the scenario, the /track?ref= clean result was a false negative. The header the scanner read showed the carriage return and line feed as literal text, so the immediate response did not split. A downstream component decoded the header value a second time before writing it to an internal response, and the double-decoded value split there. Tested with a double-encoded payload and traced one hop further in, it was a real header injection on the internal path. The fix decoded the value once at a known layer and rejected control characters, and the retest used the double-encoded payload that the original scan had never tried.
AppSecD's dynamic and API testing runs Nuclei, Dalfox, SQLMap, Commix, Katana, Arjun, FFuf and Interactsh for out-of-band detection, plus 150+ native checks and API discovery across 50+ web frameworks. In its lifecycle this is the runtime stage: DAST and API testing run against the deployed application, because code review cannot see an injection that only appears once the application is assembled and running. Its static analysis includes dataflow taint analysis that traces source to sink across functions. Its AI layer assembles attack chains across findings, showing how separately unremarkable issues combine. Its findings are deduplicated across scans and tracked through new, reopened and fixed states, and they need maker-checker approval to close, so a finding cannot be closed unilaterally.
That is the whole claim, and data/products.ts, the single source of truth for what these products do, does not mention CRLF or HTTP header injection at all. So this post does not claim that AppSecD has a dedicated CRLF or response-splitting check, which payloads, marker headers or encodings it sends, whether it reads raw response bytes or a parsed header map, whether it distinguishes a split header from a reflected value, whether it tries bare line feeds or double-encoded sequences, whether it tests Set-Cookie injection, cache poisoning or the log-injection cousin, how it rates the severity of such a finding, whether its attack-chain assembly links header injection to cache or open-redirect findings, whether its static rules account for which serialiser validates, or how accurate any such detection would be. The measurements, the confirmation procedure, the fixes and the checklist above are general practice, not a description of how AppSecD works internally, and they apply to any scanner's output, ours included. The scenario in this post is hypothetical and does not describe any AppSecD deployment, user or finding.