Strobesstrobes
Platform
Solutions
Resources
Customers
Company
Pricing
Book a Demo
Strobesstrobes

Strobes connects every exposure signal to autonomous action, so security teams fix what matters, prove what works, and stop chasing noise.

Book a DemoTalk to an expert
ISO 27001SOC 2CREST
  • Platform
  • Platform Overview
  • Agentic Exposure Management
  • AI Agents
  • Integrations
  • API & Developers
  • Workflows & Automation
  • Analytics & Reporting
  • Solutions
  • Exposure Assessment (EAP)
  • Attack Surface Management
  • Application Security Posture
  • Risk-Based Vulnerability Management
  • Adversarial Exposure Validation (AEV)
  • AI Pentesting
  • Pentesting as a Service
  • CTEM Framework
  • By Industry
  • Financial Institutions
  • Technology
  • Retail
  • Healthcare
  • Manufacturing
  • By Roles
  • CISOs
  • Security Directors
  • Cloud Security Leaders
  • App Sec Leaders
  • Resources
  • Blog
  • Customer Stories
  • eBooks
  • Datasheets
  • Videos & Demos
  • Exposure Management Academy
  • CTEM Maturity Assessment
  • Pentest Health Check
  • Security Tool ROI Calculator
  • Company
  • About Strobes
  • Meet the Team
  • Trust & Security
  • Contact Us
  • Careers
  • Become a Partner
  • Technology Partner
  • Partner Deal Registration
  • Press Release

Weekly insight for security leaders

CTEM research, agentic AI trends, and what's actually moving the needle.

© 2026 Strobes Security Inc. All rights reserved.

Privacy PolicyTerms of ServiceCookie PolicyAccessibilitySitemap
Back to Blog
CRLF Injection: How It Works and How to Test for It
Application Security

CRLF Injection: How It Works and How to Test for It

Akhil ReniFebruary 24, 20256 min read

Table of Contents

  • What is CRLF injection?
  • How does CRLF injection work?
  • How do you test for CRLF injection?
  • What can an attacker do with CRLF injection?
  • How do you prevent CRLF injection?
  • Frequently asked questions
  • Sources and references

Authors

A
Akhil Reni

Share

Table of Contents

  • What is CRLF injection?
  • How does CRLF injection work?
  • How do you test for CRLF injection?
  • What can an attacker do with CRLF injection?
  • How do you prevent CRLF injection?
  • Frequently asked questions
  • Sources and references

Authors

A
Akhil Reni

Share

TL;DR
  • ✓CRLF injection abuses the carriage return (%0d) and line feed (%0a) characters that separate HTTP headers, letting you inject new headers or split the response.
  • ✓If user input reaches a response header (a redirect Location, a Set-Cookie value), unfiltered %0d%0a lets you forge headers, set cookies, or inject a body.
  • ✓It enables HTTP response splitting, web cache poisoning, reflected XSS via an injected body, session fixation, and log injection.
  • ✓CRLF injection is tested under WSTG-INPV-15 (HTTP Splitting/Smuggling) and maps to A03:2021 Injection in the OWASP Top 10.
  • ✓Prevent it by stripping or rejecting CR and LF in any value placed into a header, and by using framework header APIs that encode them automatically.

CRLF injection is a web vulnerability that exploits how the HTTP protocol uses the carriage return and line feed characters, written as %0d and %0a in URL encoding, to separate one header from the next. When user-controlled input is written into a response header without filtering those bytes, you can inject your own headers or even an entire second response, an attack known as HTTP response splitting.

This post explains the mechanics, walks through the payloads and tooling to find CRLF injection, shows what it escalates into (cache poisoning, XSS, session fixation, log forging), and covers the one-line fix. It is tested under WSTG-INPV-15 and maps to A03:2021 Injection.

What is CRLF injection?

CRLF injection is an attack that inserts carriage-return (CR, %0d, \r) and line-feed (LF, %0a, \n) characters into application output that becomes part of an HTTP response, breaking the intended structure of the message. HTTP uses the sequence \r\n to end each header line and a doubled \r\n\r\n to mark the end of headers and the start of the body, so injecting those bytes lets you forge structure the server never intended.

The vulnerable pattern is any place user input lands in a response header: a redirect that reflects a url parameter into Location, a language preference written into Set-Cookie, or a custom header echoing a request value. CRLF injection is the gateway to header injection and response splitting, both tested in the input-validation portion of a web application pentesting checklist.

How does CRLF injection work?

It works by smuggling encoded newline characters into a value that the server writes into a header, so your text after the newline becomes a new header line. Consider an endpoint that redirects using a parameter and reflects it into the Location header. Supplying encoded CRLF lets you append a header of your choosing.

# Original
/redirect?url=/home
# Response: Location: /home

# Inject a forged Set-Cookie via CRLF
/redirect?url=/home%0d%0aSet-Cookie:%20sessionid=attacker
# Response now contains:
#   Location: /home
#   Set-Cookie: sessionid=attacker

Doubling the sequence (%0d%0a%0d%0a) closes the header block and lets you write a body, which is full HTTP response splitting. Inject HTML there and you get reflected XSS even if the normal page output is encoded.

Strobes insight
CRLF injection is the bug that resurrects XSS after you've encoded the body. If headers reflect user input unfiltered, a doubled %0d%0a lets you write your own response body, encoding be damned.

How do you test for CRLF injection?

Find every parameter that influences a response header, then inject encoded CRLF sequences and inspect the raw response for a new line you control. Burp Suite is the cleanest way to see exactly which bytes land where, because you can view the unrendered response and confirm the injected header appears.

# Payloads to try (and double-encoded variants)
%0d%0aSet-Cookie:%20test=crlf
%0d%0aX-Injected:%20yes
%0d%0a%0d%0a<script>alert(1)</script>

# Double-encoded, for filters that decode once
%250d%250aX-Injected:%20yes

# Fuzz header-reflecting params at scale
ffuf -w params.txt -u "https://target/redirect?FUZZ=%0d%0aX-Injected:yes"

Watch redirect (Location), cookie, and any reflected custom headers. If your injected header or body shows up in the raw response, it is confirmed. This is WSTG-INPV-15 and belongs in your penetration testing test cases.

What can an attacker do with CRLF injection?

CRLF injection is rarely the end goal; it is a primitive that unlocks several higher-impact attacks depending on what you can inject. The severity ranges from log noise to full response control.

  • HTTP response splitting: inject a full second response, leading to web cache poisoning that serves your content to other users.
  • Reflected XSS: if output encoding blocks XSS in the body but headers are unfiltered, an injected body via CRLF reintroduces script execution.
  • Session fixation: inject a Set-Cookie to pin a victim's session ID to a value you know.
  • Log injection: inject newlines into values that get logged to forge entries or break log parsing and monitoring.
  • Open redirect chaining: combine header control with redirects for phishing.
Where to Hunt for CRLF Injection
Header sinks
  • ✓Redirect Location parameters
  • ✓Set-Cookie / preference values
  • ✓Reflected custom headers
  • ✓Host / X-Forwarded-* echoes
Payload variants
  • ✓%0d%0a (standard)
  • ✓%250d%250a (double-encoded)
  • ✓%0d%0a%0d%0a + body (splitting)
  • ✓\r\n in JSON/API values

How do you prevent CRLF injection?

Prevent CRLF injection by removing or rejecting CR and LF characters from any value before it is written into an HTTP header, and by relying on framework APIs that do this for you. Most modern HTTP libraries (the Servlet API, Node's http module, ASP.NET) refuse header values containing raw newlines, so the bug usually appears where developers build headers from raw strings or use older platforms. Continuous coverage of injection flaws like this is exactly what agentic pentesting is built to automate.

Concretely: strip or URL-encode \r and \n in redirect targets, cookie values, and any reflected header; validate redirect destinations against an allowlist rather than reflecting user input; and never log raw, unsanitized request data on the same line as structured fields. As with all injection bugs, treat data and protocol structure as separate things.

Frequently asked questions

What is the difference between CRLF injection and HTTP response splitting?
CRLF injection is the underlying technique of inserting carriage-return and line-feed characters into HTTP output. HTTP response splitting is what you achieve when that injection lets you terminate the headers and inject a full second response. Response splitting is the more severe outcome of a CRLF injection flaw.
What characters cause CRLF injection?
The carriage return (CR, \r, encoded %0d) and line feed (LF, \n, encoded %0a). HTTP uses the pair \r\n to separate headers and \r\n\r\n to end the header section, so injecting these characters into a response lets an attacker forge headers or a body.
Which OWASP category does CRLF injection belong to?
CRLF injection falls under A03:2021 Injection in the OWASP Top 10. In the Web Security Testing Guide it is covered by WSTG-INPV-15, Testing for HTTP Splitting and Smuggling, alongside related request and response manipulation attacks.
Can CRLF injection lead to XSS?
Yes. If body output is properly encoded but response headers reflect user input without filtering newlines, a doubled %0d%0a lets you inject an entire response body containing a script tag. That reintroduces reflected XSS through the header channel even when normal output encoding is in place.
How do you prevent CRLF injection?
Strip or reject CR and LF characters in any value written to an HTTP header, validate redirect targets against an allowlist, and use modern HTTP framework APIs that refuse header values containing raw newlines. Treat user input as data, never as protocol structure.

Sources and references

  • OWASP CRLF Injection
  • OWASP WSTG: Testing for HTTP Splitting/Smuggling (WSTG-INPV-15)
  • PortSwigger: HTTP response splitting / header injection
A
Akhil Reni
Co-founder and CTO, Strobes
Akhil Reni is co-founder and CTO of Strobes, building AI-driven penetration testing and exposure management for security teams.
Tags
Web SecurityCRLF InjectionOWASP

Stop chasing vulnerabilities Start reducing exposure

See how Strobes AI agents validate and fix your most critical exposures automatically.

Book a Demo
Continue Reading

Related Posts

How to Catch Blind Bugs Scanners Miss
Penetration TestingOffensive Security

How to Catch the Blind Bugs Scanners Miss

Out-of-band validation detects blind SSRF, blind SQLi, and out-of-band XXE that return no in-band response. Learn how it works and why it matters.

May 29, 202613 min
5 Vulnerabilities in Every Vibe-Coded App
Application SecurityLLM Security

5 Vulnerabilities in Every Vibe-Coded App

The 5 security flaws AI coding assistants ship by default: missing authz, leaked secrets, weak JWTs, IDOR, eval RCE — with detection queries and fixes for each.

May 29, 202613 min
Threat Modeling Explained: STRIDE and Methodology
Application SecurityVulnerability Management

Threat Modeling Explained: STRIDE and Methodology

Threat modeling finds design flaws before code exists. Learn STRIDE, data flow diagrams, trust boundaries, and how STRIDE compares to DREAD, PASTA, and attack trees.

Mar 21, 20269 min