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 the lid request parameter is copied into the Location response header. The payload 1bc0e%0d%0ae8a601c9516 was submitted in the lid parameter. This caused a response containing an injected HTTP header.
Request
GET /link/tplimage?lid=1bc0e%0d%0ae8a601c9516&pubid=21000000000226650 HTTP/1.1 Host: clickserve.cc-dt.com Proxy-Connection: keep-alive Accept: */* User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Response
HTTP/1.1 302 Found Date: Fri, 12 Nov 2010 03:12:31 GMT Server: Apache/1.3.41 (Unix) Location: http://redacted.net/gan_impression?lid=1bc0e e8a601c9516&pubid=21000000000226650 Content-Type: text/html; charset=iso-8859-1 Expires: Fri, 12 Nov 2010 03:12:31 GMT Content-Length: 349
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>302 Found</TITLE> </HEAD><BODY> <H1>Found</H1> The document has moved <A HREF="http://gan.vulnerable.ad.partner/gan_impression?lid=1bc0 ...[SNIP]...
The value of the pubid request parameter is copied into the Location response header. The payload 6c377%0d%0ac19b1e4dac1 was submitted in the pubid parameter. This caused a response containing an injected HTTP header.
Request
GET /link/tplimage?lid=41000000030310796&pubid=6c377%0d%0ac19b1e4dac1 HTTP/1.1 Host: clickserve.cc-dt.com Proxy-Connection: keep-alive Accept: */* User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Response
HTTP/1.1 302 Found Date: Fri, 12 Nov 2010 03:12:31 GMT Server: Apache/1.3.41 (Unix) Location: http://redacted.net/gan_impression?lid=41000000030310796&pubid=6c377 c19b1e4dac1 Content-Type: text/html; charset=iso-8859-1 Expires: Fri, 12 Nov 2010 03:12:31 GMT Content-Length: 349
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>302 Found</TITLE> </HEAD><BODY> <H1>Found</H1> The document has moved <A HREF="http://gan.vulnerable.ad.partner/gan_impression?lid=4100 ...[SNIP]...
2. Cross-domain Referer leakageprevious There are 2 instances of this issue:
When a web browser makes a request for a resource, it typically adds an HTTP header, called the "Referer" header, indicating the URL of the resource from which the request originated. This occurs in numerous situations, for example when a web page loads an image or script, or when a user clicks on a link or submits a form.
If the resource being requested resides on a different domain, then the Referer header is still generally included in the cross-domain request. If the originating URL contains any sensitive information within its query string, such as a session token, then this information will be transmitted to the other domain. If the other domain is not fully trusted by the application, then this may lead to a security compromise.
You should review the contents of the information being transmitted to other domains, and also determine whether those domains are fully trusted by the originating application.
Today's browsers may withhold the Referer header in some situations (for example, when loading a non-HTTPS resource from a page that was loaded over HTTPS, or when a Refresh directive is issued), but this behaviour should not be relied upon to protect the originating URL from disclosure.
Note also that if users can author content within the application then an attacker may be able to inject links referring to a domain they control in order to capture data from URLs used within the application.
Issue remediation
The application should never transmit any sensitive information within the URL query string. In addition to being leaked in the Referer header, such information may be logged in various locations and may be visible on-screen to untrusted parties.
GET /link/tplclick?lid=41000000030310796&pubid=21000000000226650 HTTP/1.1 Host: clickserve.cc-dt.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; CloudScan Vuln Crawler http://cloudscan.me) Connection: close
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>302 Found</TITLE> </HEAD><BODY> <H1>Found</H1> The document has moved <A HREF="http://gan.vulnerable.ad.partner/gan_click?lid=41000000030310796&pubid=21000000000226650">here</A> ...[SNIP]...
GET /link/tplimage?lid=41000000030310796&pubid=21000000000226650 HTTP/1.1 Host: clickserve.cc-dt.com Proxy-Connection: keep-alive Accept: */* User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Response
HTTP/1.1 302 Found Date: Fri, 12 Nov 2010 03:12:01 GMT Server: Apache/1.3.41 (Unix) Location: http://redacted.net/gan_impression?lid=41000000030310796&pubid=21000000000226650 Content-Type: text/html; charset=iso-8859-1 Expires: Fri, 12 Nov 2010 03:12:01 GMT Content-Length: 348
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>302 Found</TITLE> </HEAD><BODY> <H1>Found</H1> The document has moved <A HREF="http://gan.vulnerable.ad.partner/gan_impression?lid=41000000030310796&pubid=21000000000226650">here</A> ...[SNIP]...
Report generated by XSS.CX at Fri Nov 12 07:37:20 EST 2010.