CRLF Injection ‘How to Hunt it’
A legacy redirect endpoint on an IBM subdomain passed user-controlled input into the Location response header without filtering CR and LF characters. An attacker could inject arbitrary response headers, including a Set-Cookie header for the ibm.com domain.
Published on medium.com
Bug Bounty
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This write-up covers a CRLF injection found on IBM. The author's point is not the complexity of the bug but that it is hunted less often than it should be, so the article is as much about when to look for it as about the finding itself.
The affected feature was an old redirect-style endpoint on an IBM subdomain. The endpoint accepted the destination as part of the URL path and answered with a 302 Found whose Location header was built from that input. The real legacy subdomain is redacted in the write-up; www.example.ibm.com is a placeholder standing in for it.
CRLF injection occurs when an application lets user-controlled CR (\r) and LF (\n) characters reach an HTTP response header without properly filtering them. The basic idea:
User Input HTTP Response Header %0d%0a 'CRLF' New attacker-controlled header
Setup
No accounts, roles, tools or versions are described. The work was done during recon, and the author states plainly that he was not initially looking specifically for CRLF. The precondition for the whole finding is a piece of user-controlled input that reaches a response header, which is why the article lists the surfaces worth watching:
- Redirect endpoints, via the
Locationheader. - Parameters such as
url,redirect,next,return,destinationandtarget. - Paths such as
/redirect/<input>,/link/<input>and/go/<input>. - Download and file endpoints that control filenames.
- Functionality that generates
Set-Cookie. - Custom and proxy headers.
Finding it
During recon the author identified an old redirect-style endpoint on an IBM subdomain:
https://www.example.ibm.com/cgi-bin/link/
The endpoint accepted the destination as part of the URL path. Before testing anything malicious, he confirmed its normal behaviour with a request such as:
GET /cgi-bin/link/http://example.com/
which returned a redirect:
HTTP/1.1 302 FoundLocation: http://example.com/
At that point the Location header became the interesting sink: the server was taking attacker-controlled input and using it to construct an HTTP response header. That is exactly the behaviour that makes CRLF worth testing.
Exploitation
Step 1: check whether CRLF sequences are sanitised
The first test was whether the server sanitised CRLF sequences:
https://www.example.ibm.com/cgi-bin/link/https://example.com%0d%0aX-Test: injected
and the response was:
Location: https://example.comX-Test: injected
This confirmed that the server decodes %0d%0a into real \r\n and does not block it, meaning a new response header was successfully injected.
Step 2: escalate to Set-Cookie injection
To escalate impact, the author tried one of the most well-known techniques, Set-Cookie injection, which could allow a trusted origin to issue a cookie controlled by the attacker:
GET https://www.example.ibm.com/cgi-bin/link/http://example.com/%0d%0aSet-Cookie:EVIL=1;Domain=ibm.com
and the response was:
HTTP/1.1 302 FoundServer: nginx/1.31.3Date: Sat, 01 Aug 2026 15:55:02 GMTContent-Type: text/html; charset=iso-8859-1Content-Length: 203Connection: closeStrict-Transport-Security: max-age=63072000; includeSubdomains;Set-Cookie: EVIL=1;Domain=ibm.comLocation: http:/example.com/
The Set-Cookie header was successfully injected. At this point Set-Cookie headers could be injected into the response.
Step 3: stop at the demonstrated capability
This is an important part of validating CRLF findings. Although Set-Cookie injection was confirmed, the author did not claim:
- session hijacking
- account takeover
- session fixation
- authentication bypass
- CSRF bypass
Those impacts require additional evidence. Proving that an arbitrary cookie can be injected is different from proving that an authentication cookie can be overwritten and then used to compromise an account.
Prove the capability first, then prove the real-world impact.
Don't automatically turn header injection into a Critical vulnerability without demonstrating the chain.

The bug was reported, triaged and resolved, and was rated high.
Root cause
The server took user-controlled input from the URL path and used it directly to construct the Location response header, decoding %0d%0a into real \r\n without blocking it. Because the decoded characters were written into the header block, everything after them was interpreted as a new header, which is how X-Test and later Set-Cookie appeared in the response. The report does not describe the code or any filtering that was present, so the exact implementation mistake is not stated; the observable behaviour is that CRLF sequences were decoded and not rejected.
Impact
Under the conditions shown, an attacker can inject a response header into a response served from the IBM origin, including Set-Cookie with a Domain attribute covering ibm.com. The author is explicit that this is the limit of what was proven: session hijacking, account takeover, session fixation, authentication bypass and CSRF bypass were not claimed, because each would need additional evidence. The report does not state which users or how many could be affected, nor what the browser did with the injected cookie.
Fix
The behaviour that has to go is the decoding of %0d%0a into real \r\n inside a header value: user input used to build Location should be rejected or stripped of CR and LF before it reaches the response header.
Variants to test
A quick checklist from the write-up, useful on other targets:
[ ] Find redirects / forwarding functionality[ ] Identify user-controlled URL/path parameters[ ] Confirm the value reaches Location[ ] Test encoded %0d%0a[ ] Use a harmless X-CRLF-Test header first[ ] Inspect the raw HTTP response[ ] Confirm actual header injection[ ] Test controlled impact such as Set-Cookie[ ] Check whether Location can be manipulated[ ] Verify browser behavior where relevant[ ] Don't claim authentication impact without proof
Anything beyond that, such as overwriting an authentication cookie and using it, needs its own demonstration before it goes in the report.
What happened, in plain words
A security researcher was browsing an old part of IBM's website during the early information-gathering phase of a bug bounty hunt. He found a page whose only job was to send visitors onward to another address, a bit like a signpost that says "this way to example.com". The page built its answer from whatever address the visitor put in the link, and it did not clean that address properly. By slipping two invisible control characters into the address, the researcher made the server add extra lines to its reply, lines the server never meant to send. One of those extra lines was a cookie instruction, sent from IBM's own domain.
He reported it, the report was triaged and resolved, and it was rated high. This article explains, from zero, what that kind of bug is, how he found it, and why he deliberately stopped short of claiming more than he had proved.
The basics you need first
Before the bug makes sense, a few everyday ideas.
A server and a browser. Your browser asks a website's server for a page. The server answers with a short block of text called an HTTP response. The first lines of that response are called headers: small labelled instructions such as "this page is HTML" or "send the visitor to this other address". Below the headers comes the actual page content.
A header. Think of headers as the labels on a parcel: who sent it, what is inside, where to forward it. Each header is one line, written as a name, a colon, and a value, for example Location: http://example.com/.
A redirect. When a server wants to send you somewhere else, it replies with status code 302 Found and a Location header holding the destination. Your browser reads that header and quietly loads the new address. Old websites often have a helper page that does this, so a short link can point at a long one.
A cookie. A cookie is a small piece of text a website asks your browser to store and to send back on later visits. It is how a site remembers that you are logged in. The server sets one with a Set-Cookie header. The Domain part of that header says which sites the cookie belongs to; a cookie marked for ibm.com would be sent to IBM's sites.
CR and LF. These are two invisible control characters: carriage return (\r) and line feed (\n). Together they mark the end of a line in an HTTP response. In a URL they are usually written in encoded form as %0d and %0a.
CRLF injection. If a website takes something you typed and pastes it into a response header without cleaning it, and you can smuggle those two line-ending characters in, then everything you write after them is read by the browser as a brand new header. You have injected a header the server never intended to send. The write-up sums up the idea like this:
User Input HTTP Response Header %0d%0a 'CRLF' New attacker-controlled header
Read it left to right: your input goes into a response header; the encoded %0d%0a acts as the line break; what follows becomes a new header under your control.
Bug bounty and recon. A bug bounty programme pays researchers for reporting security flaws. Recon is the early stage of looking around a target: mapping pages, parameters and old features, without attacking anything yet.
When to think about CRLF
The whole finding rests on one condition: some input you control reaches a response header. The write-up lists the places where that is worth checking:
- Redirect endpoints, because they fill in the
Locationheader. - Parameters with names such as
url,redirect,next,return,destinationandtarget, because those names suggest the site will forward you somewhere. - Paths such as
/redirect/<input>,/link/<input>and/go/<input>, where the destination sits in the address itself. - Download and file endpoints that control filenames, since the filename may end up in a header.
- Anything that generates
Set-Cookie. - Custom and proxy headers.
Finding the endpoint
The researcher says plainly that he was not looking for CRLF at first. During recon he came across an old redirect-style endpoint on an IBM subdomain:
https://www.example.ibm.com/cgi-bin/link/
The real subdomain is hidden in the write-up; www.example.ibm.com is a stand-in. The endpoint took the destination as part of the URL path, meaning the address you want to be sent to is simply glued onto the end of the link.
Before trying anything malicious, he checked that it worked normally. That is a sensible first move: you cannot tell what is unusual until you know what usual looks like.
GET /cgi-bin/link/http://example.com/
Line by line: GET is the browser's way of saying "give me this". /cgi-bin/link/ is the helper page. http://example.com/ is the destination being passed along. The server answered:
HTTP/1.1 302 FoundLocation: http://example.com/
HTTP/1.1 302 Found means "I am not giving you a page, I am forwarding you". Location: http://example.com/ is the forwarding address, copied from the input. (The write-up prints these headers run together on one line; in a real response each header sits on its own line.)
That is the key observation: the server takes text the visitor controls and uses it to build a response header. That is exactly the situation where CRLF becomes possible.
Testing for CRLF
Step 1: does the server clean the line breaks?
The first test asked a simple question: if I send the encoded line-break characters, does the server strip them out or pass them through?
https://www.example.ibm.com/cgi-bin/link/https://example.com%0d%0aX-Test: injected
Here %0d%0a is the encoded carriage return and line feed, and X-Test: injected is a harmless header the researcher made up. The name starts with X- by convention for custom headers, and it does nothing; it is only there to be seen. The response was:
Location: https://example.comX-Test: injected
The server turned %0d%0a back into real line-ending characters and did not block them, so X-Test: injected appeared as a separate header in the reply. That is the proof of injection: a header the server never wrote, now in its response.
Step 2: can the injected header be a cookie?
A harmless test header proves the mechanism but not much else. To show real capability, the researcher tried the best-known use of CRLF, Set-Cookie injection: making a trusted site hand out a cookie of the attacker's choosing.
GET https://www.example.ibm.com/cgi-bin/link/http://example.com/%0d%0aSet-Cookie:EVIL=1;Domain=ibm.com
Line by line: the request goes to the helper page; http://example.com/ is the destination; %0d%0a is the smuggled line break; Set-Cookie:EVIL=1;Domain=ibm.com is the header the researcher wants the server to emit. It asks the browser to store a cookie named EVIL with the value 1, belonging to the whole of ibm.com. The response was:
HTTP/1.1 302 FoundServer: nginx/1.31.3Date: Sat, 01 Aug 2026 15:55:02 GMTContent-Type: text/html; charset=iso-8859-1Content-Length: 203Connection: closeStrict-Transport-Security: max-age=63072000; includeSubdomains;Set-Cookie: EVIL=1;Domain=ibm.comLocation: http:/example.com/
Again the write-up prints the headers run together; in a real response each one is on its own line. Reading them: 302 Found is the redirect; Server: nginx/1.31.3 names the web server software; Date is when the reply was made; Content-Type says the body is HTML in the iso-8859-1 character set; Content-Length: 203 is the body size in bytes; Connection: close means the connection will be closed after this reply; Strict-Transport-Security tells the browser to keep using HTTPS for a long period. Then comes the injected Set-Cookie: EVIL=1;Domain=ibm.com, and finally the ordinary Location header. The cookie header sits in the middle of IBM's own response, which is what makes it interesting.
Step 3: stop at what was proved
This is the part of the write-up the author stresses most. He confirmed cookie injection, and he did not claim any of the following:
- session hijacking
- account takeover
- session fixation
- authentication bypass
- CSRF bypass
Each of those is a much bigger claim and needs its own evidence. Showing that you can plant any cookie is not the same as showing that you can overwrite the cookie that keeps a user logged in and then use it to take over the account. His rule:
Prove the capability first, then prove the real-world impact.
Do not turn header injection into a Critical finding without demonstrating the chain from injection to damage.

Why it worked
The server took text from the URL path and used it directly to build the Location header. It decoded %0d%0a back into real line endings and did not reject them. Because those characters mark the end of a header line, everything written after them was read as a new header. That is how X-Test, and later Set-Cookie, ended up in the response. The write-up does not describe the server code or any filtering that was in place, so the exact programming mistake is not stated; what is observable is that the line breaks were decoded and not blocked.
What an attacker could do with it
As demonstrated, an attacker can add arbitrary headers to a response served from IBM's trusted domain, including a Set-Cookie with a Domain covering ibm.com. That is the limit of what was shown. Session hijacking, account takeover, session fixation, authentication bypass and CSRF bypass were not claimed, because each would need extra proof. The write-up does not say which users or how many could be affected, nor what a browser actually did with the injected cookie.
The fix
The behaviour that has to go is the decoding of %0d%0a into real line endings inside a header value: input used to build Location should be rejected, or stripped of carriage returns and line feeds, before it reaches the response header.
A checklist for other targets
The write-up ends with a short checklist to reuse elsewhere:
[ ] Find redirects / forwarding functionality[ ] Identify user-controlled URL/path parameters[ ] Confirm the value reaches Location[ ] Test encoded %0d%0a[ ] Use a harmless X-CRLF-Test header first[ ] Inspect the raw HTTP response[ ] Confirm actual header injection[ ] Test controlled impact such as Set-Cookie[ ] Check whether Location can be manipulated[ ] Verify browser behavior where relevant[ ] Don't claim authentication impact without proof
Anything beyond that, such as overwriting a login cookie and using it, needs its own demonstration before it belongs in a report.
Glossary
- HTTP: the language browsers and servers use to exchange requests and responses.
- HTTP response: the server's reply, made of a status line, headers, and usually a body.
- Header: one labelled line in a request or response, such as
LocationorSet-Cookie. - Status code: a number at the start of a response saying what happened, such as
302for a redirect. - 302 Found: a status code meaning "the thing you asked for is elsewhere, go to this address".
- Location header: the header that holds the address a redirect sends you to.
- Redirect: a server reply that sends the browser to a different address.
- Cookie: a small piece of text a site asks the browser to store and send back later, commonly used to remember a login.
- Set-Cookie: the response header a server uses to give the browser a cookie.
- Domain attribute: the part of a
Set-Cookieheader saying which sites the cookie belongs to. - CR and LF: carriage return (
\r) and line feed (\n), the invisible characters that end a line. - CRLF injection: slipping those line-ending characters into input that reaches a response header, so extra headers can be added.
- URL encoding: writing special characters in a URL in percent form, such as
%0dfor carriage return and%0afor line feed. - Sink: the place where untrusted input ends up and does its damage, here the
Locationheader. - Recon: the early, mostly harmless stage of mapping a target's pages and features.
- Bug bounty: a programme that pays researchers for reporting security flaws.
- Triaged: reviewed and accepted as a valid issue by the programme.
- Session hijacking: taking over someone's logged-in session, usually by stealing their session cookie.
- Account takeover: gaining control of another person's account.
- Session fixation: forcing a known session identifier on a victim so the attacker can later use it.
- Authentication bypass: getting past a login check without valid credentials.
- CSRF: cross-site request forgery, tricking a logged-in user's browser into sending a request they did not intend.
- nginx: a common web server program; the response above names version 1.31.3.
- Strict-Transport-Security: a header telling the browser to keep using HTTPS for that site for a set time.
- Content-Type: a header saying what kind of content the body is.
- Content-Length: a header giving the body size in bytes.
- X- header: a header name starting with
X-, by convention used for custom, non-standard headers.