CRLF Injection
Description
CRLF (Carriage Return Line Feed) Injection occurs when an attacker can inject CRLF characters into HTTP headers, potentially leading to HTTP response splitting, header injection, or other malicious actions.
Example with Scenario
Scenario: A web application takes user input to generate HTTP headers. An attacker can manipulate the input to inject additional headers or split the HTTP response, leading to various attacks.
Payloads and Test Cases
Payloads
Header Injection:
HTTP Response Splitting:
Test Cases
Header Injection:
Payload:
Test Case:
HTTP Response Splitting:
Payload:
Test Case:
Mitigation
Input Validation:
Validate and sanitize user input to ensure it does not contain CRLF characters.
Implement strict validation rules to reject malicious input.
Use Libraries:
Use libraries and frameworks that automatically handle header encoding and prevent injection.
Avoid constructing HTTP headers manually using user input.
Secure Headers:
Set secure HTTP headers to mitigate the impact of potential CRLF injection.
Use Content Security Policy (CSP) and other security headers to protect the application.
Error Handling:
Implement proper error handling to avoid revealing header information in error messages.
Return generic error messages without disclosing sensitive details.
Last updated