Home / Knowledge hub / CRLF injection
Knowledge hub
CRLF injection
Using carriage return and line feed characters to split a response or a log line.
What it means
CRLF stands for carriage return and line feed, the two characters that end a line in many text formats, including HTTP headers, email and log files. CRLF injection is slipping those characters into input so that the receiving system treats them as the end of one line and the start of another.
The attacker does not need to run code. They only need an application that copies their text into a line-based format without removing the line breaks. It is a flaw in how text is assembled, not in how a server is configured, so patching the server rarely fixes it. The same few characters work across many systems, which is why the technique keeps returning.
Why it matters
What follows depends on where the text lands. In an HTTP response it can add headers or split the response. In a log it can forge entries. In an email it can add recipients. Each is a way for an outsider to write lines that your system believes it wrote itself. MITRE lists the weakness as CWE-93.
The business effects are indirect but real: planted cookies, poisoned caches, spam sent from your mail server, and log records that mislead an investigation. These are often found late because nothing crashes. Spam sent through your mail server can also get your domain blocked, which stops legitimate email from reaching customers.
How it shows up
You meet it in redirect and cookie handling, file name headers, contact forms that build emails, and logging that records raw input. Line breaks may arrive encoded, as %0d and %0a in a URL, which a filter that checks only for literal characters can miss.
Decode input first, then reject or remove carriage return and line feed in any value that goes into a header, subject line or log line. Use library functions that handle structure for you, rather than joining strings. Test by sending encoded line breaks in each field and checking the output. See header injection and log injection.
Questions people ask
CRLF injection, answered
What does CRLF mean?
It stands for carriage return and line feed, written \r\n in code and %0d%0a when URL-encoded. Together they mark the end of a line in HTTP and several other protocols.
Software that builds lines from input must keep them out of values.
Is CRLF injection the same as header injection?
Header injection is one use of CRLF injection, aimed at HTTP headers. The technique also reaches logs, email headers and other line-based formats.
The common cause is untrusted text reaching a line-based format.
Why do filters miss it?
Line breaks can arrive in encoded forms, such as percent-encoded or double-encoded characters. A filter that checks only the raw text can be bypassed.
Decode first, then validate, and use framework functions that reject them.
What is the worst case?
Response splitting, where a forged second response is stored by a cache and served to other visitors. Planted cookies and forged log entries are more common.
Impact depends entirely on where the text lands.
How do we test for CRLF injection?
Send encoded line breaks in parameters and look for new headers, extra email recipients or new lines in logs.
A harmless marker value makes the result unambiguous without changing real data.
Sources
Where this comes from
Related
Terms that sit next to this one
HTTP header injection
Slipping line breaks into input so an attacker adds headers to your response.
Log injection
Input that forges or hides log entries by smuggling in new lines.
Email header injection
Input that adds extra recipients or headers to an email your app sends.
Injection
Input that ends up running as a command instead of being read as text.
Input sanitisation
Cleaning or stripping risky characters from input, which is weaker than encoding.
Where does a line break end up?
A single line break can start a new header, a new log entry or a new email recipient. We test where your inputs end up and report only what we proved, with the request and the response. Book a pilot on one app.
Or start with a $199 pilot on one application: thirty days, success criteria agreed before day one, credited against the annual if you convert.