What Is CRLF Injection? Delimiter Injection Explained
CRLF injection slips line breaks into a text protocol so one message becomes two. See where it hides in HTTP, mail, logs and IRC, and how to prevent it.
CRLF injection is an attack where untrusted input containing carriage return and line feed characters ends up inside a text protocol message, so the receiver reads one message as two. Many protocols, including HTTP headers, SMTP, IRC and log formats, use CRLF to separate lines or commands. If an application copies input into that stream without escaping or rejecting those characters, an attacker can add lines the application never meant to send.
What is CRLF injection?
CRLF injection is a delimiter injection flaw: input that carries line break characters is placed into a line-based protocol or file without being escaped. The receiving side treats each line break as the end of one record and the start of another, so attacker text becomes a separate header, command or log entry.
CR is carriage return (byte 0x0D, written \r) and LF is line feed (byte 0x0A, written \n). Some protocols require both, some accept LF alone. MITRE catalogs the general weakness as CWE-140, improper neutralization of delimiters, and the specific line-break case as CWE-93.
Why does CRLF injection matter?
Line-based protocols give every line the same authority as the sender. If one line arrives from a trusted server, the next line does too. An injected line therefore inherits whatever trust the channel carries, which can be far more than the user who supplied the input.
The damage depends on where the line lands:
- HTTP responses. An injected header can set cookies, change caching or split the response.
- Email. Injected SMTP headers can add recipients or alter the message.
- Logs. A forged log entry can hide activity or mislead an investigator.
- Server-to-server chat protocols. An injected command can run with the authority of the server that relays it.
The last case is what happened with UnrealIRCd CVE-2026-114713. The server's labeled-response module echoed the client-supplied IRCv3 label tag back into replies without escaping it. Because IRC separates commands with line breaks, a normal user could push extra lines into traffic between linked servers, where they ran with server authority. CISA added the flaw to its Known Exploited Vulnerabilities catalog on November 13, 2026.
How CRLF injection differs from command injection
Command injection puts attacker input into an operating system shell. CRLF injection stays inside the application protocol: no shell is involved and no host code runs. The result is still serious because protocol messages carry actions. In IRC, a forged KILL or GLINE line disconnects or bans users across the network. In HTTP, a forged header can plant a session cookie.
The two are often confused because both come from the same root mistake: mixing data and control characters in one string and trusting the receiver to tell them apart.
Where CRLF injection hides
The risky pattern is any place that echoes or forwards a value the client controls into a line-based output:
- Reflected identifiers, such as request labels, correlation IDs or nicknames, copied into replies.
- Redirect locations and custom headers built from query strings.
- Mail headers built from web form fields such as name or subject.
- Log lines that include user agents, usernames or URLs.
- Relayed messages between federated or linked servers.
Reflected identifiers deserve extra attention because they look harmless. The IRCv3 labeled-response specification says the label is an opaque value of up to 64 bytes. Opaque to the server means the server should not interpret it, but it still must encode it correctly on the way out.
How do you prevent CRLF injection?
Encode or reject line break characters at every point where untrusted data enters a line-based format. Prefer the format's own escaping rules, and validate at input as a second layer.
In practice:
- Use the protocol's escaping. The IRCv3 message-tags specification defines escapes for tag values:
\:for semicolon,\sfor space,\\for backslash,\rfor CR and\nfor LF. HTTP and mail libraries have equivalent header encoders. Apply them on output, every time. - Validate on input. If a field never legitimately contains control characters, reject any value with bytes below 0x20. Length limits help too.
- Use structured APIs. Set headers through a library call instead of concatenating strings. Most modern HTTP frameworks refuse header values with CR or LF.
- Treat peer input as untrusted. A message from a linked server can still carry text a user wrote. Servers should validate relayed lines as well as client lines.
- Test with control characters. Add CR, LF and encoded forms such as
%0d%0ato your test cases for every reflected field.
How do you detect CRLF injection in logs?
Look for records where a field that should hold one short token contains encoded line breaks, or where actions appear that no user or operator issued. For an IRC network, that means KILL, GLINE or mode changes with no matching operator activity. For web applications, it means response headers or cookies your code never sets.
When a vendor patches a flaw like this, hot-patching closes the hole without a restart. Our guide on how to hot-patch UnrealIRCd and verify the fix walks through that process for the current case, and the article on why linked server trust turns one bug into a takeover explains why the impact spreads across a whole network.
Key points for defenders
- Any line-based protocol is a candidate: HTTP, SMTP, IRC, SIP, syslog.
- Escape on output using the format's own rules, and validate on input.
- Reflected values that the server is told to treat as opaque still need encoding.
- Injected lines inherit the trust of the channel they ride on, which is why CRLF injection between servers is worse than in a single client session.