CRLF Injection - http://stage.mackeeper.com/
The application copied user-supplied data into a response header without sanitising newline characters, allowing an attacker to inject arbitrary HTTP headers. An attacker could add headers such as a fake 'virus' header to the response.
- Triaged in 18 hours
- Fixed in 15 days
- Paid in 15 days
- Disclosed after 7 months
Summary by the program
Summary:
CRLF Injection - http://stage.mackeeper.com/
CRLF injection vulnerabilities arise when user-supplied data is copied into a response header in an unsafe way. If an attacker can inject newline characters into the header, then they can inject new HTTP headers and also, by injecting an empty line, break out of the headers into the message body and write arbitrary content into the application's response.
Vulnerable URL: hhttp://stage.mackeeper.com/
Steps To Reproduce:
In the rawRequest we have added '%0D%0Avirus:%20value' In Burp Repeater copy and paste the below rawRequest Notice the response with header added ------rawRequest---------- GET /%0D%0Avirus:%20value HTTP/1.1 Connection: keep-alive Accept: / Accept-Encoding: gzip,deflate Host: stage.mackeeper.com User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0
------rawRequest----------
Context
The target is stage.mackeeper.com, a host in the *.mackeeper.com scope of the Clario bug bounty program on HackerOne. The report is titled "CRLF Injection - http://stage.mackeeper.com/" and was disclosed on 25 May 2020 with a low severity rating (CVSS 3.5) and a bounty of 50.00 USD.
The program's summary explains the class of bug in general terms: CRLF injection arises when user-supplied data is copied into a response header in an unsafe way. If an attacker can inject newline characters into the header, they can inject new HTTP headers and, by injecting an empty line, break out of the headers into the message body and write arbitrary content into the application's response.
The vulnerable URL given in the report is:
hhttp://stage.mackeeper.com/
That is how it appears in the report, with the doubled leading h.
Setup
The report describes no account, role or special precondition. The only tool named is Burp Repeater, used to send a hand-crafted raw request to the host. The request carries a Firefox 64.0 user agent string.
Finding it
The researcher's approach was to place the encoded CRLF sequence %0D%0A directly in the request path, followed by a header-like string. The idea is that if the server copies the request path into a response header without sanitising it, the encoded newline will be decoded and interpreted as a header separator in the response.
The payload used is:
%0D%0Avirus:%20value
%0D%0A is the URL-encoded form of carriage return and line feed. virus:%20value is the header the researcher wanted to see appear in the response, with %20 being an encoded space.
Exploitation
Step 1: Send the crafted request
The report instructs the reader to add %0D%0Avirus:%20value to the raw request, paste the raw request below into Burp Repeater, and notice the response with the header added.
GET /%0D%0Avirus:%20value HTTP/1.1
Connection: keep-alive
Accept: /
Accept-Encoding: gzip,deflate
Host: stage.mackeeper.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0
The request line is GET /%0D%0Avirus:%20value HTTP/1.1, so the encoded CRLF and the header-like text sit in the path. The remaining headers are ordinary: Connection: keep-alive, Accept: /, Accept-Encoding: gzip,deflate, the Host of the staging server, and the Firefox user agent. The Accept header is written as Accept: / in the report.
Step 2: Observe the response
The report's expected result is stated in one line: notice the response with the header added. The injected virus: value header is what the researcher was looking for in the server's reply. The report does not include the raw response, so the exact status line and the full set of response headers are not shown.
Root cause
The report does not describe the server-side code. What the behaviour implies is that the application takes the request path and reflects it into a response header without stripping or rejecting CR and LF characters, so the encoded %0D%0A is decoded and treated as the end of one header line and the start of another. The program's summary frames the general mechanism: unsafe copying of user-supplied data into a response header lets an attacker add headers, and an injected empty line would let them break into the body. Whether any output encoding or header validation existed on this host is not stated.
Impact
The program's summary sets out the two consequences of the class: an attacker can inject new HTTP headers, and by injecting an empty line can break out of the headers into the message body and write arbitrary content into the application's response. In this report the demonstrated effect is the addition of a single header, virus: value, to the response. The report does not show a body injection, a cache poisoning scenario, a redirect, cookie manipulation or any effect on other users, and it does not describe who would be exposed. The report was rated low severity with a bounty of 50.00 USD.
Fix
The general remedy for this class, consistent with the program's own description, is to stop copying user-controlled data into response headers unsafely: strip or reject CR and LF characters before any value reaches a header, and avoid reflecting the raw request path into headers at all.
Variants to test
- Put
%0D%0Aplus a header name and value in the path of other hosts in scope and look for the extra header in the response, as was done here. - Try the same sequence in query string parameters that the application might echo into headers, such as redirect or language parameters, and check whether a new header line appears.
- Inject an empty line after the CRLF pair (
%0D%0A%0D%0A) to see whether content can be written into the response body, which is the stronger form described in the program summary. - Try the raw characters where the client allows them, and the encoded forms
%0D%0A,%0aand%0d, since different servers decode and normalise differently.
A positive result in each case is a response whose header block contains the injected header, or whose body contains the injected content.
Hunting notes
The payload sat in the request path of a staging host. During recon, hosts that echo parts of the request into Location, Set-Cookie or custom headers are the ones worth probing with an encoded CRLF.
What happened, in plain words
A security researcher found a bug on a website run by Clario, the company behind MacKeeper. The site was a staging copy of MacKeeper's web presence, at stage.mackeeper.com. A staging site is a test version of a real site, kept separate so that changes can be tried out before they go live.
The bug is called CRLF injection. Every message a web browser and a web server exchange is made of lines of text, and each line ends with an invisible pair of characters: a carriage return (CR) and a line feed (LF). In URLs these two characters can be written in an encoded form, %0D for CR and %0A for LF. If a server takes something the visitor controls, such as the path part of the URL, and copies it into a line of its reply without cleaning it, then an attacker can smuggle those newline characters in. The server then treats the smuggled newline as the end of one line and the start of another, and whatever follows becomes a brand new line in the reply. Since the top of a server's reply is a list of headers (small labelled pieces of information such as Content-Type or Set-Cookie), the attacker can add headers of their own. If they inject two newlines in a row, they create an empty line, and an empty line is the signal that the headers have ended and the actual page content begins. That lets them write content into the page itself.
The researcher demonstrated the first, milder half of this: they put an encoded newline plus a made-up header into the URL path, sent the request by hand, and the server's reply came back with that made-up header included. The report was rated low severity (CVSS 3.5) and paid a bounty of 50.00 USD. It was disclosed on 25 May 2020.
Context
The target is stage.mackeeper.com, a host that falls inside the *.mackeeper.com scope of the Clario bug bounty program on HackerOne. A bug bounty program is a scheme where a company publishes which of its systems may be tested and what it will pay for valid findings. The asset listed for the program is *.mackeeper.com.
The report is titled "CRLF Injection - http://stage.mackeeper.com/" and was disclosed on 25 May 2020 with a low severity rating (CVSS 3.5) and a bounty of 50.00 USD. CVSS is a standard scoring system for the seriousness of a security flaw; 3.5 out of 10 sits in the low band.
The program's summary explains the class of bug in general terms: CRLF injection arises when user-supplied data is copied into a response header in an unsafe way. If an attacker can inject newline characters into the header, they can inject new HTTP headers and, by injecting an empty line, break out of the headers into the message body and write arbitrary content into the application's response.
The vulnerable URL given in the report is:
hhttp://stage.mackeeper.com/
That is how it appears in the report, with the doubled leading h. Read it as the ordinary address of the staging site; the extra letter is a typo in the write-up, not part of the address.
Setup
The report describes no account, role or special precondition. You do not need to log in, and there is no particular user type required. The only tool named is Burp Repeater, used to send a hand-crafted raw request to the host.
Burp is a tool for intercepting and editing the traffic between a browser and a server. Repeater is one of its tabs: you paste a request into it, press send, and read the exact reply the server gives back. It is useful here because it lets you send a hand-crafted raw request and read the exact reply. Sending the request by hand bypasses that.
The request carries a standard Firefox 64.0 user agent string. The user agent is a header in which the browser announces what it is. The request carries a Firefox 64.0 user agent string.
Finding it
The researcher's approach was to place the encoded CRLF sequence %0D%0A directly in the request path, followed by a header-like string. The request path is the part of the address after the hostname, the /something bit. The idea is that if the server copies the request path into a response header without sanitising it, the encoded newline will be decoded and interpreted as a header separator in the response.
The payload used is:
%0D%0Avirus:%20value
%0D%0A is the URL-encoded form of carriage return and line feed. virus:%20value is the header the researcher wanted to see appear in the response, with %20 being an encoded space.
Exploitation
Step 1: Send the crafted request
The report instructs the reader to add %0D%0Avirus:%20value to the raw request, paste the raw request below into Burp Repeater, and notice the response with the header added.
GET /%0D%0Avirus:%20value HTTP/1.1
Connection: keep-alive
Accept: /
Accept-Encoding: gzip,deflate
Host: stage.mackeeper.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0
Line by line:
GET /%0D%0Avirus:%20value HTTP/1.1is the request line.GETis the method, meaning "give me this resource". The middle part is the path being requested, and this is where the payload sits: an encoded carriage return and line feed, then the textvirus:%20value.HTTP/1.1is the version of the protocol being spoken.Connection: keep-aliveasks the server to keep the network connection open after this reply, so further requests can reuse it.Accept: /tells the server which kinds of content the client will accept. It is written asAccept: /in the report.Accept-Encoding: gzip,deflatesays the client can handle compressed replies, which saves bandwidth.Host: stage.mackeeper.comnames the site being asked for. One server can host many sites, so this header tells it which one is wanted.User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0identifies the client as Firefox 64.0 on 64-bit Windows.
If the server echoes it without cleaning, the encoded newline becomes a real newline in the reply.
Step 2: Observe the response
The report's expected result is stated in one line: notice the response with the header added. The injected virus: value header is what the researcher was looking for in the server's reply. The report says to notice the response with the header added, but does not include the raw response. The report does not include the raw response, so the exact status line and the full set of response headers are not shown.
Root cause
The report does not describe the server-side code. What the behaviour implies is that the application takes the request path and reflects it into a response header without stripping or rejecting CR and LF characters, so the encoded %0D%0A is decoded and treated as the end of one header line and the start of another. The program's summary frames the general mechanism: unsafe copying of user-supplied data into a response header lets an attacker add headers, and an injected empty line would let them break into the body. Whether any output encoding or header validation existed on this host is not stated.
A useful comparison is a form where you write your name and it is printed on a badge. If the printer treats every line break in your name as "start a new line on the badge", then writing a name with a line break in it lets you add extra lines of your own. The server here is that printer, and the request path is the name field.
Impact
The program's summary sets out the two consequences of the class: an attacker can inject new HTTP headers, and by injecting an empty line can break out of the headers into the message body and write arbitrary content into the application's response. In this report the demonstrated effect is the addition of a single header, virus: value, to the response. The report does not show a body injection, a cache poisoning scenario, a redirect, cookie manipulation or any effect on other users, and it does not describe who would be exposed. The report was rated low severity with a bounty of 50.00 USD.
Fix
The general remedy for this class, consistent with the program's own description, is to stop copying user-controlled data into response headers unsafely: strip or reject CR and LF characters before any value reaches a header, and avoid reflecting the raw request path into headers at all.
Variants to test
- Put
%0D%0Aplus a header name and value in the path of other hosts in scope and look for the extra header in the response, as was done here. - Try the same sequence in query string parameters that the application might echo into headers, such as redirect or language parameters, and check whether a new header line appears. Query string parameters are the
name=valuepairs after the?in a URL. - Inject an empty line after the CRLF pair (
%0D%0A%0D%0A) to see whether content can be written into the response body, which is the stronger form described in the program summary. - Try the raw characters where the client allows them, and the encoded forms
%0D%0A,%0aand%0d, since different servers decode and normalise differently.
A positive result in each case is a response whose header block contains the injected header, or whose body contains the injected content.
Hunting notes
The payload sat in the request path of a staging host. During recon, hosts that echo parts of the request into Location, Set-Cookie or custom headers are the ones worth probing with an encoded CRLF. Recon here means the early survey of a target: finding hosts, pages and parameters before testing them. Location is the header a server uses to tell a browser to go somewhere else, and Set-Cookie is the header that hands the browser a cookie, a small piece of data the browser stores and sends back on later requests. Both are common places for a server to copy in a value it was given.
Reproducible means anyone else can follow the same steps and see the same result.
Glossary
- API: a defined way for one piece of software to ask another for data or actions, like a menu of requests a service accepts.
- Bounty: money a company pays a researcher for a valid security finding.
- Bug bounty program: a scheme where a company publishes which systems may be tested and what it pays for findings.
- Burp Repeater: a tab in the Burp tool where you paste a raw HTTP request, send it, and read the exact reply.
- Carriage return (CR): the invisible character
\r, encoded in URLs as%0D, that ends a line in many network protocols. - Cookie: a small piece of data a server asks the browser to store and send back on later requests, often used to remember who you are.
- CRLF: the pair carriage return plus line feed, the standard way to end a line in HTTP; encoded as
%0D%0A. - CRLF injection: a flaw where attacker-supplied newline characters reach a response header, letting the attacker add headers or content.
- CVSS: a standard 0 to 10 scoring system for the seriousness of a security flaw.
- GET: the HTTP method meaning "give me this resource".
- Header: a labelled line of information at the top of an HTTP request or response, such as
HostorContent-Type. - Host: the header naming which site on a server is being requested.
- HTTP: the protocol browsers and servers use to exchange requests and responses.
- Line feed (LF): the invisible character
\n, encoded in URLs as%0A, that moves to the next line. - Location: a response header telling the browser to go to a different address.
- Path: the part of a URL after the hostname, such as
/page. - Payload: the crafted input a researcher sends to try to trigger a bug.
- Query string: the
name=valuepairs after the?in a URL. - Recon: the early survey of a target to find hosts, pages and parameters before testing.
- Reproducible: a result anyone can repeat by following the same steps.
- Response: the reply a server sends back to a request.
- Scope: the list of systems a bug bounty program allows to be tested.
- Set-Cookie: a response header that hands the browser a cookie to store.
- Staging site: a test copy of a real site, kept separate so changes can be tried before going live.
- URL encoding: writing special characters as
%plus two hex digits so they can travel safely in a URL. - User agent: a header in which the browser announces what browser and operating system it is.