scanrub
CRLF Injectionhigh prioritypartial coverage

CRLF Injection / HTTP Header Injection

2 min read 36 reports analyzed ScanRub Research
Share

Summary

Reports cluster around:

  • classic HTTP response splitting via newline in user input that ends up in a Set-Cookie / Location header
  • SMTP command injection via newlines in app-config fields (Grafana SMTP password, Nextcloud Calendar appointment description) leading to RCE through email rendering misuse
  • LDAP password field with embedded newlines smuggling SMTP / Redis commands
  • Library bugs (Ruby net/http set_content_type, Cloudflare Transform Rules concat() decoding hex escapes) where newline in a value reaches the final HTTP request unescaped.
◈ flow diagram
User InputHTTP Header …CRLF InjectionHeader/Log S…Response or …
◈ chart
Critical
3
High
9
Medium
15
Low
9

Top Affected Components / Targets

  • Endpoints reflecting parameters into Location / Set-Cookie / custom headers
  • App-config UIs (SMTP host/port/user/pass, LDAP DN)
  • Email-rendering / SMTP-using features
  • Reverse proxy / CDN rule engines

Common Attack Vectors

  • Inject %0d%0a into URL parameter that is reflected into Location / Set-Cookie
  • Inject newline into SMTP password / from / to fields used by app-config
  • Inject newline into LDAP password field used as DN fragment
  • Use hex escapes \x0a\x0d to bypass naive newline filters

Common Payloads

  • %0d%0aSet-Cookie:+evil=1
  • %0d%0aLocation:+https://evil.com
  • x\r\nHeader: injected
  • password\r\nMAIL FROM:<attacker@evil>
  • \x0a\x0dHeader: smuggled (Cloudflare concat)

Detection Strategy

Stage 1: response-splitting probe

Inject %0d%0aX-Test-Probe:hit into URL parameters that end up in Location / Set-Cookie / X-* response headers; flag when X-Test-Probe header appears in the response.

Stage 2: SMTP/LDAP advisory

When authenticated config UI has SMTP/LDAP credential fields, mark as high-risk surface and add to authenticated-scan checklist.

Stage 3: CVE marker

Compose with Nuclei for known CRLF/HRS-via-config CVEs.

Tip: Testing tools that run these checks in parallel across every discovered endpoint can cut the time required substantially compared to fully manual testing, as long as they confirm findings with more than one signal to keep the false-positive rate down.

False-Positive Notes

  • Many reflections are encoded - only flag when the probe header actually appears in the response.
  • SMTP-via-config requires authenticated state.

How to Test

Manual Testing Methodology

Here is a systematic approach to identifying CRLF Injection / HTTP Header Injection vulnerabilities in a target application.

Step 1: Reconnaissance and Surface Mapping

Before testing, map all input vectors that could be affected. Identify parameters, headers, cookies, and request bodies that interact with the vulnerable component. A proxy such as Burp Suite or OWASP ZAP, paired with normal browsing of the target, is usually enough to build this list.

Step 2: Baseline Request

Send a legitimate request and record the normal response: status code, content length, response time, and any identifying tokens. This baseline matters because it's what you'll compare later responses against once payloads are involved.

Step 3: Payload Injection

Inject test payloads into each identified input vector one at a time. Start with benign detection payloads before escalating to anything that could actually trigger the vulnerability. For CRLF Injection / HTTP Header Injection specifically, submit %0d%0a (and raw \r\n where the transport allows it) followed by a new header name/value or a fake log line into every parameter that ends up reflected in a response header, Set-Cookie value, redirect target, or logged field.

Step 4: Response Analysis

Compare the response against your baseline, looking specifically for an extra, attacker-defined header appearing in the raw HTTP response, a split response body, or a forged entry appearing in application logs.

Step 5: Confirmation

Once a potential vulnerability is detected, confirm it with at least a few independent test cases to rule out coincidence. Document the exact request and response as proof. For CRLF Injection / HTTP Header Injection, a confirmed finding typically means showing that attacker-controlled input changes the application's behavior in a way that matters for security, not just that a payload was reflected somewhere harmless.

Real-World Impact

Real-World Impact

CRLF and HTTP header injection let an attacker insert carriage-return/line-feed sequences into a value that ends up in a raw HTTP header or a log line, splitting what should be a single header into multiple, or a single log entry into several. In a header context, this can inject entirely new response headers, split the response into two, or plant content the application never intended to serve — including a second, attacker-controlled response body.

The practical exploits built on this primitive include HTTP response splitting (poisoning what an intermediate cache stores and serves to other users), session fixation via an injected Set-Cookie header, and open-redirect-adjacent phishing via an injected Location header — the specific impact depends on which header ends up attacker-controlled.

In logs specifically, CRLF injection enables log forging: an attacker can fabricate fake log entries designed to mislead an investigator or hide evidence of the real attack among plausible-looking noise.

Prevention & Remediation

Prevention and Secure Coding

Preventing CRLF Injection / HTTP Header Injection takes a defense-in-depth approach — no single control below is sufficient alone, but together they close off both the primary path and the most common bypasses.

Reject CR/LF in header and log values outright. Strip or reject \r and \n characters from any user input that will be placed into an HTTP header value or a log line — don't attempt to escape them, reject the input.

Use framework header-setting APIs. Set headers and cookies through the framework's own API (which typically encodes or rejects invalid characters automatically) rather than concatenating raw strings into a header block.

Validate redirect and cookie values against a strict format. Where a value must go into a Location or Set-Cookie header, validate it against an allowlist format before use, not just against CR/LF.

Structured logging. Use a structured (e.g. JSON) logging format rather than freeform string concatenation, which makes log forging via embedded newlines far harder to pull off convincingly.

Source reports

A sample of the disclosed HackerOne reports this playbook was synthesized from.

Frequently Asked Questions

What is CRLF Injection / HTTP Header Injection?
Reports cluster around: (1) classic HTTP response splitting via newline in user input that ends up in a Set-Cookie / Location header; (2) SMTP command injection via newlines in app-config fields (Grafana SMTP password, Nextcloud Calendar appointment description) leading to RCE through email rendering misuse; (3) LDAP password field with embedded newlines smuggling SMTP / Redis commands; (4) Library bugs (Ruby net/http set_content_type, Cloudflare Transform Rules concat() decoding hex escapes) where newline in a value reaches the final HTTP request unescaped.
How common is CRLF Injection / HTTP Header Injection in bug bounty reports?
Scanrub's research corpus for this playbook is built from 36 disclosed HackerOne reports in this category, synthesized for detection and prevention guidance rather than reproduced verbatim.
How do I test for CRLF Injection / HTTP Header Injection?
Map every input vector, record a baseline response, then inject targeted test payloads one field at a time and compare the response for timing, length, error, or reflection differences from that baseline. The "How to Test" section above walks through the full methodology for this specific vulnerability class.
What is the single most effective fix for CRLF Injection / HTTP Header Injection?
Reject CR/LF characters outright from any user input that reaches an HTTP header or log line, and set headers through the framework's own API rather than raw string concatenation.
Weekly security research

New vulnerability playbooks, tool updates, and bug bounty insights - delivered to your inbox. No spam.

Unsubscribe anytime. We respect your inbox.
Press ⌘K to search×