Issue
HTTP response splitting occurs when an application places untrusted input in an HTTP response header without safely validating or encoding it. In HTTP/1.1, response headers are sent as lines separated by carriage return and line feed (CRLF). If input can add those control characters, a recipient may interpret one response as multiple responses. RFC 9112, §11.1
A common risky pattern is building a Location redirect or a Set-Cookie value from request data. A vulnerable application might decode %0D%0A in a request parameter and then copy the resulting characters into a response header. The root cause is unsafe handling of data at the point where it becomes part of an HTTP header. CWE-113
HTTP response splitting is distinct from HTTP request smuggling. Response splitting involves attacker-controlled data altering an outgoing response. Request smuggling involves differences between HTTP components in how they parse request boundaries. OWASP Web Security Testing Guide
Examples
Normal redirect response:
HTTP/1.1 302 FoundLocation: /home
Illustrative vulnerable construction: The application decodes a request parameter and concatenates it into a Location header. If the framework permits CRLF in the value, an attacker may be able to add another header or, under the right conditions, create a second response.
Location: <decoded request parameter>
Safer behavior: Reject the input if it contains CR or LF, then validate the redirect destination against the application’s expected format. Prefer framework response APIs that set headers safely and reject invalid values.
if value contains CR or LF: reject the request destination = validate_allowed_local_path(value)response.set_header("Location", destination)
Use the framework’s validation and response APIs.
Impact
The direct result may be header injection or, if the injected content creates another response boundary, response splitting. Further effects depend on how browsers, proxies, and caches handle the resulting messages. Possible consequences include content spoofing or cache poisoning, but those outcomes require additional conditions—for example, a shared cache that accepts and stores the attacker-influenced response. RFC 9112, §11.1
A reflected CRLF string or an extra header alone does not prove that an attacker can poison a cache, execute script, access another user’s data, or take over an account. Those claims require evidence that the relevant downstream component processes the response as intended and that the necessary victim, cache, or browser conditions are present.
Testing
1. Check whether input creates a separate response header
Find a value used in a response header, then insert encoded line breaks and a test header. Inspect the raw response for a separate parsed header.
Example: A marker displayed in the body does not confirm a new header. Check the raw response seen by the client.
GET /redirect?next=%2Fhome%0d%0aX-Test-Marker%3A%20demo HTTP/1.1
Host: app.example.test
2. Compare decoding and output locations
Try the relevant input through each supported request format and compare redirects, cookies, and custom headers. Record whether intermediaries reject or normalize the line breaks.
Example: The application and proxy may decode input at different stages. Compare their observed output where available.
GET /redirect?next=%2Fhome%250d%250aX-Test-Marker%3A%20demo HTTP/1.1
Host: app.example.test
3. Verify downstream behavior
If a new header is confirmed, check its effect in the relevant browser or cache. Report only the behavior shown by the response and consumer.
Example: A separate header is evidence of header injection. It does not automatically prove cache poisoning or script execution.
Common false positives: A tool may display a reflected string from the response body rather than from a header. The framework or proxy may reject, normalize, or encode CRLF. A scanner may report a payload that appeared in a request or log but never reached the response. Modern HTTP/2 and HTTP/3 use different message framing from HTTP/1.1, so assess the actual protocol and any translation through gateways; behavior observed on one connection or protocol does not establish behavior across the whole deployment. RFC 9110 RFC 9112
Mitigation
Primary fixes
- Avoid constructing HTTP headers by concatenating strings. Use the framework’s response and header APIs, and confirm that the deployed framework version rejects invalid header values.
- Validate values according to their purpose. For redirects, accept only approved local paths or explicitly allowlisted destinations. For cookies and other headers, use the format required by that header.
- Reject CR and LF in untrusted values used in headers. Do not rely on removing only one spelling of the characters: input may be decoded or transformed at different points. Validate after the application’s intended decoding step, and avoid repeated or inconsistent decoding.
- Encode data for the correct context. URL-encode individual URL components when constructing URLs; URL encoding alone is not a general-purpose defense for arbitrary header values.
Additional defenses
- Keep frameworks, web servers, proxies, and other HTTP components current.
- Review every path that writes request-derived data into response headers, including redirect and cookie handling.
- Use cache controls appropriate to the response’s content and sensitivity. Cache controls can reduce some exposure, but they do not fix unsafe header construction.
Retest: Repeat the same probes after the fix. Confirm that the application rejects the input or keeps it within a valid header value; confirm that no attacker-controlled second response is parsed by the server, proxy, or cache. A browser’s failure to display an attack page is not enough to establish that the underlying issue is fixed.