HawkScan Test Info for CRLF Injection

CRLF Injection


Plugin Id: 40003 | CWE: 113


To mitigate the risks associated with CRLF injection, the following steps can be taken:

  1. Input validation: Implement strict input validation to prevent any user-supplied data from being included in HTTP response headers or cookies. This can be achieved by using appropriate sanitization and validation techniques, such as regular expressions or input filtering functions.

  2. Output encoding: Ensure that all user-supplied data is properly encoded before being included in HTTP response headers or cookies. This can be done by using encoding functions specific to the output context, such as urlencode for URL parameters or htmlentities for HTML output.

  3. Secure coding practices: Follow secure coding practices to minimize the risk of CRLF injection vulnerabilities. This includes avoiding the use of user-supplied data in HTTP response headers or cookies whenever possible, and using secure coding frameworks or libraries that handle input validation and output encoding automatically.


CRLF injection is a vulnerability that allows an attacker to manipulate HTTP response headers or cookies by injecting special characters known as CRLF (Carriage Return Line Feed). By exploiting this vulnerability, an attacker can set arbitrary values for these headers or cookies, potentially leading to various security risks.


The risks associated with CRLF injection include:

  1. Cookie manipulation: By injecting CRLF characters into the HTTP response headers, an attacker can set arbitrary values for cookies. This can lead to session hijacking, where the attacker impersonates a legitimate user by stealing their session cookie.

  2. Arbitrary header injection: CRLF injection can also allow an attacker to set arbitrary HTTP response headers. This can be used to perform various attacks, such as HTTP response splitting or cache poisoning, which can lead to further security vulnerabilities.

  3. Cache poisoning: By carefully crafting the injected response using cross-site scripting (XSS), an attacker can exploit cache poisoning vulnerabilities. This can result in the caching of malicious content by intermediate proxies or browsers, leading to the execution of arbitrary code or the disclosure of sensitive information to unauthorized parties.