CRLF Injection: Splitting One Response Into Two

Day 17 made the server trust a header it should have configured itself. Today you abuse something even smaller, two invisible characters that HTTP uses purely as plumbing, the carriage return and line feed that separate one header from the next. CRLF Injection happens when user input containing these characters reaches a raw HTTP header or a log line without being stripped or encoded, letting an attacker inject entirely new headers, split one response into two, or forge a log entry that was never actually logged.
This is the sixteenth class in the series, and it is proof that a vulnerability does not need a payload that looks dangerous to be dangerous. The entire attack is two characters, \r\n, in the wrong place.
Inside scope only, with minimal proof. HTTP response splitting can chain into stored XSS and session fixation against real victims. Confirm the injection with a benign custom header or a harmless reflected value, and never actually plant a payload that affects other users.
What CRLF injection actually is
Every HTTP message, request or response, uses \r\n (carriage return, line feed) as the separator between each header line, and a double \r\n to mark the end of the headers and the start of the body.
HTTP/1.1 200 OK\r\n
Content-Type: text/html\r\n
Set-Cookie: session=abc123\r\n
\r\n
<html>...
If an application takes user input and inserts it into a response header, a redirect Location header built from a parameter, a value echoed into a Set-Cookie, a custom header reflecting part of the request, and does not strip or encode \r\n sequences from that input first, an attacker can supply input containing its own encoded \r\n characters, typically as %0d%0a in a URL, and the underlying HTTP library will interpret them exactly as it would any other line break: the end of the current header, and the start of whatever comes next.
?redirect=http://example.com%0d%0aSet-Cookie:%20session=attacker_value
If this value flows unsanitized into a Location header, the response the server builds literally contains a newline followed by a brand new Set-Cookie header the developer never wrote, injected entirely through a value that was only ever supposed to be a redirect target.
HTTP response splitting, the escalation that makes this serious
A single injected header is already a finding. The more severe variant, formally named CWE-113 and extensively documented by OWASP, is HTTP response splitting: injecting enough CRLF sequences, including the double \r\n that marks the end of headers, to make the server produce what looks to any downstream consumer like two complete, separate HTTP responses from a single request.
?redirect=http://example.com%0d%0aContent-Length:%200%0d%0a%0d%0aHTTP/1.1%20200%20OK%0d%0aContent-Type:%20text/html%0d%0a%0d%0a<script>alert(document.cookie)</script>
If this succeeds, the attacker has effectively smuggled an entire second, attacker-controlled HTTP response into the connection. Depending on what sits downstream, a browser, a caching proxy, a load balancer, this second response can be interpreted as the real response to a completely different, subsequent request on the same connection, leading to reflected or stored-feeling cross-site scripting, cache poisoning that serves the attacker’s fabricated page to other visitors, or session fixation by forcing a victim’s browser to accept an attacker-chosen session cookie via an injected Set-Cookie header.
This exact mechanism is why response splitting is treated as meaningfully more severe than a bare, single injected header: a single header injection is a boundary violation, response splitting is a boundary violation that can be weaponized directly against other users of the same application.
Why this still happens
Developers build headers with string concatenation, the same root mistake as several earlier classes in this series. A redirect URL, a custom header value, a cookie value, assembled by gluing a fixed string and a user-supplied value together, with no step that specifically checks for or strips \r\n sequences.
Modern frameworks mostly prevent the worst of this by default, but not universally, and not in every code path. Many current web frameworks and HTTP libraries now reject or automatically encode raw CRLF characters in header values, which is exactly why a large share of currently disclosed reports involve either older systems, specific libraries with an overlooked edge case, or unusual encoding and overflow conditions that slip past an otherwise-correct filter.
Header overflow and parsing edge cases reintroduce the bug even in hardened systems. A disclosed report against X, formerly Twitter, specifically described HTTP response splitting caused by header fields “overflowing,” a distinct root cause from the classic unsanitized-input pattern, where exceeding an expected header size limit caused the parser itself to misinterpret where one header ended and the next began.
Log files are a second, quieter target entirely separate from response splitting. If user input reaches a server-side log file without CRLF sanitization, an attacker can inject fake log lines, forging timestamps, fabricating entire bogus log entries, or breaking automated log parsing and alerting systems that assume one line per log entry, a technique generally called log injection or log poisoning, related in mechanism but distinct in impact from the HTTP-facing variant.
Real disclosed reports
- Twitter, HTTP Response Splitting via header overflow, disclosed through HackerOne. This report specifically noted that the root cause differed from an earlier, similarly-titled Twitter response splitting report the same researcher had previously submitted, with the header fields “overflowing” being the actual trigger this time rather than straightforward unsanitized input, a useful reminder that the same high-level bug name can have genuinely distinct underlying causes worth documenting separately.
- Shopify, v.shopify.com response splitting, documented in detail in the widely referenced book “Real-World Bug Hunting.” Covered alongside the Twitter case as one of the book’s primary worked examples for this entire vulnerability class, demonstrating the CRLF-to-response-splitting chain on a major e-commerce platform’s infrastructure.
- Airbnb, CRLF Injection, 13 upvotes, $2,500 bounty, reported by researcher bobrov. A clean, moderately paid example on a major program, demonstrating that even a comparatively low-upvote, straightforward CRLF finding carries real financial value when the injection point and impact are clearly documented.
- Apache, mod_userdir CRLF injection allowing HTTP response splitting, CVE-2016-4975, credited through the Internet Bug Bounty program, reported by researcher bobrov. This flaw affected the widely deployed Apache HTTP Server’s
mod_userdir module specifically, and was mitigated in Apache versions 2.4.25 and 2.2.32, showing this bug class reaching all the way into foundational web server software rather than only application-layer code.
- GitLab, CVE-2023-0508, Improper Neutralization of CRLF Sequences in HTTP Headers, credited to researcher akadrian through GitLab’s HackerOne program, affecting GitLab versions from 12.9 up through patched releases in the 15.10, 15.11, and 16.0 branches. A recent, actively maintained, high-profile application reintroducing a textbook CWE-113 flaw, underscoring that this is not purely a legacy bug class confined to older infrastructure.
- Ruby’s CGI library, HTTP response splitting leaking confidential information, credited through the Internet Bug Bounty program, reported by researcher ht0k. A vulnerability in a core language library rather than an individual application, meaning every application built on top of the affected CGI library inherited the flaw until the library itself was patched, a pattern worth remembering from Day 1’s discussion of supply chain risk.
Read the Airbnb report first for the most straightforward, cleanly documented example on this list. Then compare the two separate Twitter response splitting reports, noting specifically how the second one’s “header overflow” root cause differed from the more commonly discussed unsanitized-input pattern, since recognizing that distinction is exactly what separates a surface-level understanding of this bug from a thorough one.
The main variants
Classic header injection via an unsanitized redirect or reflected parameter. The textbook case shown at the top of this post. Works whenever user input reaches any response header without CRLF stripping or encoding.
Full HTTP response splitting. The escalated form, injecting enough CRLF sequences including the header-terminating double sequence to smuggle an entirely separate, attacker-controlled HTTP response, enabling reflected XSS, cache poisoning, or session fixation depending on what sits downstream.
Header overflow-triggered splitting. The distinct Twitter variant, where exceeding an expected size or count limit on headers causes a parser to misinterpret header boundaries, achieving a similar end result through an entirely different mechanical cause than straightforward unsanitized input.
Log injection, separate from the HTTP-facing variants. User input reaching a server-side log file without CRLF sanitization, allowing forged log entries, broken automated parsing, or fabricated audit trails, a quieter but genuinely serious impact, especially against applications whose incident response or compliance processes depend on trustworthy logs.
CRLF injection chained specifically into session fixation. Where an injected Set-Cookie header can set a session identifier of the attacker’s choosing in the victim’s browser, letting the attacker later authenticate using that same, known session value once the victim logs in, a particularly severe escalation path worth specifically calling out when documenting impact.
Where to look, pointed at your recon
- Any parameter that gets reflected into a redirect’s
Location header. Classic “login then redirect to” parameters, logout redirects, any ?redirect=, ?url=, ?next=, or ?returnTo= style parameter from your recon’s params.txt.
- Any custom header the application sets based on request data. Debug headers, tracing headers, anything that echoes part of the request back as a response header rather than in the body.
- Any feature that writes user-supplied values into a server-side log file directly, custom log formats, audit trails, or analytics pipelines that record a raw request value without escaping it.
- Cookie-setting logic that incorporates any user-controlled value, a username, a locale, a preference value, anywhere that value is concatenated into a
Set-Cookie header’s construction.
- Legacy or vendored HTTP libraries and older framework versions, surfaced through technology fingerprinting during earlier recon, since this is consistently where the GitLab, Apache mod_userdir, and Ruby CGI cases above were ultimately rooted.
How to hunt it, step by step
Step 1: identify every parameter that plausibly reaches a response header. Redirect parameters first, then any custom or reflected header, from your recon.
Step 2: inject a basic, URL-encoded CRLF sequence with a benign custom header. %0d%0aX-Injected-Test:%20true appended to the candidate parameter, and check the raw response headers, not just the rendered page, for your injected header appearing.
Step 3: if the basic sequence is filtered, try alternate encodings. Double URL encoding (%250d%250a), mixed case, or raw unencoded characters depending on how the request is transmitted, since some filters only strip one specific encoded form.
Step 4: if a single header injection succeeds, attempt full response splitting. Inject the double CRLF sequence marking end-of-headers, followed by a complete second response including its own status line and headers, and observe whether the response, or caching behavior, reflects a genuinely split response.
Step 5: test log injection separately from the HTTP-facing variants. Submit a value containing CRLF sequences in a field you know gets logged, like a User-Agent or custom tracked parameter, and if you have any visibility into logs, such as a self-hosted test instance or an admin panel exposing log output, confirm whether a fabricated log line appears.
Step 6: tooling can speed up broad sweeps. Automated scanners purpose-built for this, like crlfuzz, are explicitly documented in several of the disclosed writeups above as the researcher’s first step, quickly testing many parameters and encodings across a target rather than trying each by hand.
Step 7: prove the finding with the most benign payload that demonstrates impact. A custom, clearly harmless injected header is sufficient to prove basic CRLF injection. Reserve an actual XSS payload or Set-Cookie injection demonstration for confirming the response splitting escalation specifically, and never for anything resembling real exploitation against another user.
Writing the CRLF injection report
Title: CRLF Injection in [parameter] at [endpoint] allows [header injection / HTTP response splitting / log injection]
Summary:
One sentence: which parameter, which encoding worked, and whether
the proof shown is a single injected header or full response
splitting.
Steps to Reproduce:
1. Submit [request] with [%0d%0a or alternate encoding] followed
by [benign injected header, e.g. X-Injected-Test: true] in
[parameter].
2. Observe the raw HTTP response headers (not the rendered page)
contain the injected header, confirming CRLF injection.
3. (If escalated) Submit [double-CRLF payload including a second,
complete response] and observe [the response being interpreted
as two separate responses / cache poisoning / a Set-Cookie
value taking effect] confirming response splitting.
(Exact request and raw response headers, ideally via curl -i or
Burp's raw response view, showing the injected content clearly.)
Impact:
User input reaches an HTTP response header (or log entry) without
CRLF sanitization, allowing an attacker to inject arbitrary
headers. [If escalated: this can be chained into reflected XSS,
cache poisoning affecting other users, or session fixation via a
forged Set-Cookie header.] State the realistic worst case your
specific finding demonstrates, not a hypothetical maximum.
Remediation:
Strip or reject CRLF sequences (and their URL-encoded forms) from
any user input before it is placed into a response header, cookie
value, or log entry. Prefer a framework or library function
specifically designed for setting headers and cookies, which
typically encodes or rejects these sequences automatically, over
manual string concatenation.
The strongest reports on this list, the Airbnb and GitLab cases especially, show the raw HTTP response, not a browser screenshot, since the injected header or split response is often invisible in a rendered page and only visible in the actual wire-level HTTP traffic, exactly what a triager needs to verify the finding quickly.
What programs often reject
- A single injected header with no demonstrated downstream consequence, on programs that explicitly require evidence of an actual security impact rather than header injection alone
- Findings relying on an HTTP/1.0-only parsing quirk or a browser no longer in meaningful use
- Log injection findings where the researcher has no actual visibility into whether the forged entry reached a real, consumed log file, only a theoretical claim that it “should”
- Reports demonstrating response splitting with a payload that would have affected a real, non-consenting user had it actually been deployed as a live attack
The mindset: whitespace is still just input
This series has repeatedly asked whether a boundary enforces what it claims to enforce. CRLF injection is the starkest version of that question yet, because the “dangerous” input here is not a recognizable attack string, no script tags, no SQL keywords, nothing that looks suspicious to a human skimming a request. It is two of the most ordinary characters in computing, a carriage return and a line feed, placed exactly where the underlying protocol assigns them special structural meaning. Whenever user input flows into anything that treats whitespace as a delimiter, a header, a log format, a config file, that delimiter is worth testing, however unremarkable the input looks.
Homework for Day 18
- From recon, list every parameter that gets reflected into a redirect
Location header, and every custom or reflected response header on the target.
- Test basic CRLF injection with a benign custom header using URL-encoded
%0d%0a, checking the raw response headers specifically, not the rendered page.
- If filtered, try alternate encodings, double encoding and mixed case, before concluding the parameter is safe.
- Where basic injection succeeds, attempt full response splitting with a complete, benign second response, and separately test any log-writing feature for log injection.
- Read the Airbnb CRLF report and both of the separately disclosed Twitter response splitting reports end to end. For each Twitter report specifically, note the different root cause described, unsanitized input versus header overflow, and how each report framed its proof and impact differently as a result.
A confirmed CRLF injection with only a single demonstrated header is typically a valid medium severity finding, and one escalated to full HTTP response splitting with a clear XSS, cache poisoning, or session fixation chain is usually rated high. Document it with the raw HTTP response showing the injected content, and recommend a dedicated header-setting function over manual string concatenation.
Day 19 moves to a bug where the application’s own redirect logic becomes the attacker’s weapon, Open Redirect, and how a seemingly low-severity finding regularly becomes the first link in a phishing chain.