#BugBounty — Exploiting CRLF Injection can lands into a nice bounty
The web application did not sanitise user input reflected in HTTP response headers, allowing CRLF injection. An attacker could inject a Location header to redirect victims to a malicious site.
Published on medium.com
{{media:0}}
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 is a write-up of a CRLF injection found in the website of an online food delivery company in India. The researcher, Avinash Jain (@logicbomb_1), describes the home page as having a couple of inputs whose values are reflected into the HTTP response headers. The report does not name the company, the specific input, or the parameter involved.
CRLF injection, as the report defines it, happens when user-entered data is passed directly into response header fields such as Location or Set-Cookie without proper sanitisation. The consequences listed in the report range from XSS and cache poisoning to cache-based defacement and page injection.
Setup
No accounts, roles, tools or versions are described. The only precondition stated is that the home page reflects some inputs into HTTP headers, and that non-printable control characters in those inputs were not being encoded.
Finding it
While looking for security loopholes on the site, the researcher noticed that a couple of inputs on the home page were reflected into the HTTP headers. After some experimentation, the key observation was that non-printable control characters were not encoded, although they should have been. That gap suggested trying CRLF sequences, and specifically trying to inject a Location header to see whether the response would redirect.
Exploitation
Step 1: Inject a Location header through the reflected input
The researcher sent a request whose input contained CRLF characters followed by a Location header pointing at http://www.evilzone.org. The proof of concept is shown in the screenshot below.

The screenshot is captioned CRLF Injection HTTP Header. The report does not reproduce the raw request or payload as text, so the exact parameter name and encoding used are not given.
Step 2: Observe the injected header in the response
The server responded by placing the CRLF characters into the response. The Location HTTP header was set in the response with the value http://www.evilzone.org, as injected through the CRLF payload.
This screenshot is captioned CRLF Injection and shows the response containing the injected header.
Step 3: Confirm the redirect
The browser followed the injected Location header and redirected to the attacker-controlled site, evilzone.org.

This screenshot is captioned Successful Redirection via CRLF Injection and shows the redirection taking place.
Root cause
The report attributes the issue to user-entered data being passed directly into response header fields without proper sanitisation. In this case the specific failure was that non-printable control characters were not encoded, which allowed CRLF sequences to reach the header and start a new header line. The report does not describe the server-side code, framework or any defence that was present and failed, so the exact implementation mistake is not stated.
Impact
The report says the impact of CRLF injection varies and includes all the impacts of cross-site scripting as well as information disclosure. It can also deactivate certain security restrictions, such as XSS filters and the Same Origin Policy in the victim's browser, leaving victims susceptible to malicious attacks. In the demonstrated case, the concrete effect was a redirect of the response to an attacker-chosen site. The report does not quantify how many users or which users were affected, or whether any further exploitation beyond the redirect was carried out.
Fix
The report gives a general mitigation: sanitise the CRLF characters before passing data into a header, or encode the data so that CRLF sequences cannot enter the header. The timeline records that the bug was reported to the company on 11 November 2017, marked fixed on 6 December 2017, re-tested and the fix confirmed on 13 December 2017, and a bounty of USD 250 awarded on 20 December 2017.
Variants to test
- Other reflected header inputs. Look for any parameter whose value appears in a response header such as
Location,Set-Cookieor a custom header. A positive result is a response in which a new header line appears that you did not send as a legitimate header. - Redirect parameters. Test parameters that feed a
Locationheader with CRLF followed by a secondLocationvalue. A positive result is the browser following your injected URL instead of the intended one. - Cookie injection. Inject CRLF followed by a
Set-Cookieheader. A positive result is a cookie appearing in the response that the application did not set. - Response splitting into the body. Inject a double CRLF followed by HTML. A positive result is your markup rendered in the response body, which is the XSS path the report mentions.
- Cache poisoning. Where a cache sits in front of the application, check whether an injected header or body is stored and served to other users. A positive result is a second, clean request receiving the injected content.
- Control character handling. Send other non-printable characters and observe whether they are encoded or passed through. A positive result is any control character surviving into the header unencoded, which indicates the same missing sanitisation.
What happened, in plain words
A security researcher found a bug in the website of an online food delivery company in India. The bug let him make the site's server send a response that told the visitor's browser to go to a different website, one controlled by the attacker. He reported it, the company fixed it, and he received a bounty of USD 250.
The bug is called CRLF injection. It happens when a website takes something a user typed and puts it directly into the technical instructions that travel with every web page, without cleaning it first. Those instructions are called HTTP headers. By slipping special invisible characters into his input, the researcher was able to add a new instruction of his own: a Location header, which tells the browser to redirect. The browser obeyed and went to evilzone.org.
This article explains the whole story from scratch, assuming you only know how to use a browser. It covers what the researcher did, why each step worked, and how to prevent it.
Background: how a web page reaches your browser
When you type a web address and press Enter, your browser sends a request to a server. The server replies with a response. Both the request and the response are made of two parts: headers and a body.
- Headers are lines of text that carry instructions and information. For example, a response header might say
Content-Type: text/html(meaning the body is a web page) orSet-Cookie: session=abc(meaning the server wants the browser to store a small piece of data). - The body is the actual content: the HTML of the page, an image, a file, and so on.
Headers are separated from the body by a blank line. Each header is on its own line, and lines are separated by a special pair of invisible characters called CRLF (Carriage Return + Line Feed). In many systems, CRLF is written as \r\n. You can think of it like the Enter key on your keyboard: it marks the end of a line.
Because headers are just lines of text, if an attacker can insert their own CRLF into a header value, they can end the current header line and start a new one. That is the heart of CRLF injection.
What is CRLF injection?
The report defines it like this:
CRLF Injection Vulnerability is a web application vulnerability happens due to direct passing of user entered data to the response header fields like (Location, Set-Cookie and etc) without proper sanitsation, which can result in various forms of security exploits.Security exploits range from XSS, Cache-Poisoning, Cache-based defacement,page injection and etc.
In simpler words: if a website takes something you typed (like a search term or a form field) and puts it straight into a response header without checking it, you might be able to include CRLF characters. Those characters let you break out of the intended header and add your own headers. The consequences can be serious: cross-site scripting (running your own code in the victim's browser), cache poisoning (making a shared cache store your malicious response and serve it to others), defacement (changing what the page looks like), and more.
The target and the first clue
The researcher was looking for security loopholes on the website of an online food delivery company in India. On the home page, he noticed that a couple of inputs (fields where you can type something) had their values reflected into the HTTP headers. In other words, whatever you typed in those fields appeared somewhere in the response headers.
He then discovered that non-printable control characters were not being encoded. Control characters are characters that don't have a visible symbol, like the Enter key or the Tab key. Encoding means converting such characters into a safe representation (for example, turning a newline into %0A). If they are not encoded, they pass through as-is. That was the clue: if control characters like CR and LF can pass through, then a CRLF sequence might also pass through, and that could let him inject a new header.
Step 1: Trying to inject a Location header
A Location header is used in HTTP responses to tell the browser to go to a different URL. It is commonly used for redirects. The researcher decided to try injecting a Location header pointing to http://www.evilzone.org to see if the server would redirect there.
The proof of concept is shown in the screenshot below. The report does not reproduce the raw request or payload as text, so the exact parameter name and encoding used are not given.

CRLF Injection HTTP Header
The screenshot is captioned CRLF Injection HTTP Header. Because the server did not encode those characters, they were treated as part of the header structure.
Step 2: Seeing the injected header in the response
The server responded by placing the CRLF characters into the response. As a result, the Location HTTP header was set in the response with the value http://www.evilzone.org, exactly as injected through the CRLF payload.
CRLF Injection
This screenshot is captioned CRLF Injection. That is the proof that the injection worked.
Step 3: Confirming the redirect
The browser followed the injected Location header and redirected to the attacker-controlled site, evilzone.org.

Successful Redirection via CRLF Injection
This screenshot is captioned Successful Redirection via CRLF Injection and shows the redirection taking place.
Why it worked (root cause)
The report attributes the issue to user-entered data being passed directly into response header fields without proper sanitisation. In this case, the specific failure was that non-printable control characters were not encoded, which allowed CRLF sequences to reach the header and start a new header line. The report does not describe the server-side code, framework, or any defence that was present and failed, so the exact implementation mistake is not stated.
Impact
The report says the impact of CRLF injection varies and includes all the impacts of cross-site scripting as well as information disclosure. It can also deactivate certain security restrictions, such as XSS filters and the Same Origin Policy in the victim's browser, leaving victims susceptible to malicious attacks. In the demonstrated case, the concrete effect was a redirect of the response to an attacker-chosen site. The report does not quantify how many users or which users were affected, or whether any further exploitation beyond the redirect was carried out.
How to fix it
The report gives a general mitigation: sanitise the CRLF characters before passing data into a header, or encode the data so that CRLF sequences cannot enter the header. In practice, this means removing or escaping any CR or LF characters from user input before it is used in a header.
The timeline records that the bug was reported to the company on 11 November 2017, marked fixed on 6 December 2017, re-tested and the fix confirmed on 13 December 2017, and a bounty of USD 250 awarded on 20 December 2017. The report does not describe the specific code change the company made.
Variants to test
If you are testing for similar issues, here are some variations to try:
- Other reflected header inputs. Look for any parameter whose value appears in a response header such as
Location,Set-Cookie, or a custom header. A positive result is a response in which a new header line appears that you did not send as a legitimate header. - Redirect parameters. Test parameters that feed a
Locationheader with CRLF followed by a secondLocationvalue. A positive result is the browser following your injected URL instead of the intended one. - Cookie injection. Inject CRLF followed by a
Set-Cookieheader. A positive result is a cookie appearing in the response that the application did not set. - Response splitting into the body. Inject a double CRLF followed by HTML. A positive result is your markup rendered in the response body, which is the XSS path the report mentions.
- Cache poisoning. Where a cache sits in front of the application, check whether an injected header or body is stored and served to other users. A positive result is a second, clean request receiving the injected content.
- Control character handling. Send other non-printable characters and observe whether they are encoded or passed through. A positive result is any control character surviving into the header unencoded, which indicates the same missing sanitisation.
Glossary
- CRLF: Carriage Return + Line Feed, a pair of control characters that marks the end of a line in HTTP headers. Often written as
\r\n. - HTTP header: A line of text in a request or response that carries instructions or information, such as
LocationorSet-Cookie. - Location header: An HTTP response header that tells the browser to navigate to a different URL, used for redirects.
- Set-Cookie header: An HTTP response header that asks the browser to store a small piece of data (a cookie).
- Sanitisation: The process of cleaning user input to remove or neutralise dangerous characters.
- Encoding: Converting characters into a safe representation, for example turning a space into
%20. - Control character: A non-printable character, such as Enter (CR/LF) or Tab, that affects formatting or interpretation.
- XSS (Cross-Site Scripting): A vulnerability where an attacker can inject and run their own code in another user's browser.
- Cache poisoning: An attack where a shared cache is tricked into storing malicious content and serving it to other users.
- Same Origin Policy: A browser security rule that restricts scripts from one site from accessing data from another site.
- Bounty: A reward paid by a company to a security researcher who reports a valid vulnerability.