CRLF Injection and HTTP Response Splitting
User input containing carriage return and line feed characters is written into an HTTP response header, letting an attacker add headers or split the response.
| Severity | Medium |
| CVSS 3.1 | 6.1 CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N Open in the calculator |
| CVSS 4.0 | 5.1 CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N Open in the calculator |
| CWE | CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Request/Response Splitting') |
| OWASP Top 10 | A05:2025 Injection |
| MITRE ATT&CK | T1189 Drive-by Compromise |
| Category | Injection |
Description
The application places values supplied by the user into HTTP response headers, most often the Location header of a redirect, a Set-Cookie header or a custom header, without removing carriage return and line feed characters (CR and LF, URL-encoded as %0d and %0a). HTTP/1.1 separates headers with CRLF, so an encoded line break in the input ends the intended header and starts a new one of the attacker's choosing.
An attacker who persuades a user to follow a crafted link can use this to set or overwrite cookies in the user's browser, which can enable session fixation, and to add or override security headers. Two line breaks end the headers altogether, and the rest of the input becomes the response body, which is known as HTTP response splitting; where the body can be injected in this way, the attacker can run script in the user's session as with cross-site scripting. Where a shared cache stores the manipulated response, the effect can reach other users without any further interaction.
The weakness typically shows itself on a test when a payload such as %0d%0aSet-Cookie:test=1 in a parameter produces a separate header in the raw response. Burp Suite reports it as HTTP response header injection and OWASP ZAP as CRLF injection. Most current frameworks reject line breaks in header values, so it is now found mainly in older platforms, custom servers, and web server or load balancer rules that copy a decoded part of the URL into a header, such as a redirect built from a normalised path.
Remediation
Keep line breaks out of response headers:
- Remove or reject carriage return, line feed and NUL characters, after decoding, in any value written to a response header. HTTP itself treats these characters in header values as invalid.
- Set headers only through the framework's header API rather than writing raw responses, and keep the framework and web server up to date so that their own checks apply.
- For redirects, validate the destination against an allowlist and encode it as a URL, rather than copying input into the
Locationheader. - Review web server and proxy rules that build headers from request data. In nginx, use
$request_uri, which keeps the original encoding, rather than the decoded$uriinreturnandrewritetargets and inadd_headervalues.
Confirm the fix by repeating the original requests with encoded CR and LF characters, including double-encoded forms, and checking that the raw response contains no injected header.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.