Year Of Security for Java – Week 23 – HTTP Header Injection

No Gravatar

What is it and why should I care?
HTTP Header Injection is a specific injection attack that affects HTTP headers. It involves being able to manipulate the header data to cause various problems (response splitting, CRLF injection, cache poisoning, XSS, etc.). In general, it’s a lesser known and understood attack, which is usually a recipe for minimal protection in applications to prevent it, and that is certainly the case with header injection.

Likely the most common would be CRLF injection (Carriage Return [%0d or \r] Line Feed [%0a or \n]), which involves adding the CRLF to the header, which results in proxy servers/caches/browsers mis-interpreting the response in an insecure manner, and gives the attacker control of part or all of the “split” response. This can lead to the other issues mentioned above.

What should I do about it?
The recommendation for header injection is the same as that for all injections – validate and encode. For header injection specifically, you should ensure that you:

1. Canonicalize – make sure the data is in its’ simplest form before validation.

2. Validate – perform whitelist (only allow these few good characters) validation as opposed to blacklist (only reject these few bad characters) validation. Validation should ensure you don’t allow CR/LF characters in any encoded form.

3. Encode – encode the resulting output if necessary. If your input validation is tight enough, this step is just a layered defense, but you should encode in case anything ever slips by validation for some reason. Again, take special care to encode CR/LF here.

References
———–
http://www.cgisecurity.com/lib/HTTP-Request-Smuggling.pdf
http://www.securityfocus.com/archive/1/411585
http://packetstormsecurity.org/papers/general/whitepaper_httpresponse.pdf
http://lists.grok.org.uk/pipermail/full-disclosure/2006-February/042358.html
http://cwe.mitre.org/data/definitions/113.html
https://www.owasp.org/index.php/Interpreter_Injection#HTTP_Response_Splitting
https://www.owasp.org/index.php/HTTP_Response_Splitting
https://www.owasp.org/index.php/CRLF_Injection

Be Sociable, Share!

Technorati Tags: , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *