Skip to content
Smuggling / CRLF Write-up Beginner

CRLF Injection — xxx$ — How was it possible for me to earn a bounty with the Cloudflare WAF?

A CRLF injection vulnerability allowed an attacker to inject arbitrary HTTP headers into responses. The author demonstrated cookie bombing and triggering a Cloudflare WAF block, which could render the site unusable for a user.

Proviesec Follow

Published on infosecwriteups.com

Bounty$500 View original

I recently discovered a CRLF injection vulnerability on a popular website. In this blog post, I will describe the vulnerability and the attack scenarios that I was able to demonstrate.

Proviesec, on infosecwriteups.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

This is a write-up of a CRLF injection vulnerability that the researcher found on a popular website. The report does not name the target, the product or the specific feature that was vulnerable, and it does not describe what that feature normally does. What it does describe is the class of bug, the tooling used to find it, two attack scenarios that were demonstrated, and the disclosure timeline. The bounty was 500 USD, and the report was published on 24 December 2022.

CRLF is the two-character sequence (Carriage Return, Line Feed) that marks the end of a line of text in many computing contexts. In a web context, the danger is that user-controlled input containing CRLF reaches a place where line breaks are meaningful, such as an HTTP header. If the application does not handle CRLF sequences properly and does not sanitise user-generated content, an attacker can inject content into the response.

The report names two main use cases for CRLF injection:

  • Log splitting: the attacker inserts an end-of-line character and an extra line to falsify log file entries, deceiving system administrators and hiding other attacks.
  • HTTP response splitting: CRLF injection is used to add HTTP headers to the HTTP response and, for example, perform an XSS attack that leads to information disclosure.
From the original on infosecwriteups.com

Setup

The only tool the researcher names is crlfuzz, available at https://github.com/dwisiswant0/crlfuzz. It is a command-line tool that tests for CRLF injection vulnerabilities by injecting CRLF sequences into HTTP headers. The report does not give a version number, and it does not describe any account, role or other precondition on the target: the testing was done against the site as an outside tester.

Finding it

The researcher used crlfuzz to look for the vulnerability on the website. The workflow described is: clone the repository, install the necessary dependencies, then run the tool with the target URL and the desired payload as arguments. The tool injects the payload into the HTTP headers and sends the request to the target website.

From the original on infosecwriteups.com

Exploitation

Step 1: run crlfuzz against the target

Bash
▶ crlfuzz -u "http://target"

This invokes crlfuzz with the target URL passed to -u. The tool then injects CRLF sequences into HTTP headers and sends the resulting requests to the target. If the website is vulnerable to CRLF injection, the tool receives a response indicating that the injected payload was successfully executed.

From the original on infosecwriteups.com

Step 2: cookie bomb

In the first attack scenario, the researcher injected a cookie bomb into the website. A cookie bomb aims to overwhelm a website's server by injecting a large number of cookies into the user's browser, which can make the site slow or unresponsive for the affected user. The payload given as an example is:

HTTP
Set-Cookie: bomb=1Set-Cookie: bomb=2Set-Cookie: bomb=3…Set-Cookie: bomb=10000

This payload would inject 10000 cookies into the user's browser, potentially causing the website to become slow or unresponsive.

Step 3: trigger a Cloudflare WAF block

In the second scenario, the researcher set a cookie and triggered a Cloudflare WAF block. Cloudflare WAF (Web Application Firewall) is a security measure that protects websites from a variety of threats, including injection attacks. When a WAF block is triggered, the website's server has detected potentially malicious activity and is blocking access to the website to protect it. The payload given as an example is:

HTTP
Set-Cookie: crlf=attack

This payload sets a cookie with the value attack, which may be detected as malicious by the website's server and trigger a Cloudflare WAF block.

Root cause

What it establishes is that CRLF sequences could be injected into HTTP headers on the target. The likely cause is that user-controlled input was written into a response header without stripping or rejecting CR and LF characters.

Impact

The report describes the impact of CRLF injection as diverse, ranging from cross-site scripting to information disclosure. It can also disable security restrictions such as XSS filters and the Same Origin Policy in victims' browsers, leaving them vulnerable to malicious attacks. With the attack scenarios described, the researcher was able to show how quickly the site can be rendered unusable for a single user. The cookie bomb affects the individual user whose browser receives the injected cookies; the report does not claim a wider effect.

Timeline

Event Date
Submitted 16 Nov 2021
Accepted 17 Nov 2021
Triaged 17 Nov 2021
Needs more info 13 Dec 2021 (the researcher supplied more information)
Triaged again 19 Aug 2022, bounty 500 USD
Resolved / Closed not stated

Fix

The general guidance it gives is that developers should properly handle CRLF sequences and sanitise user-generated content, and that a WAF should be configured correctly so that it effectively protects against potential attacks.

Variants to test

The report lists two tools for further work: crlfuzz and the researcher's own payload collection at https://github.com/Proviesec/crlf-payloads. It also points to five public reports as prior art:

Report Program Bounty
1575912 Cloudflare 3100 USD
446271 Twitter 2940 USD
197279 Airbnb 2500 USD
192667 Starbucks not stated
237357 Snapchat 500 USD

The report's closing tips translate into concrete tests:

  1. Study the mechanics first. Understand how CRLF injection works so you can recognise potential vulnerabilities and design effective test cases.
  2. Scrutinise headers and cookies. CRLF injection often involves manipulating these elements.
  3. Test different browsers and applications. The same vulnerability may affect different browsers and applications in different ways, so test as many combinations as possible.
  4. Report responsibly. Follow responsible disclosure guidelines and report the issue to the affected website's security team as soon as possible.

The researcher's HackerOne profile is https://hackerone.com/proviesec.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

A security researcher found a bug on a popular website that let him slip extra instructions into the website's reply to a visitor's browser. The bug is called CRLF injection. The report does not name the website, the product or the feature that was affected, and it does not say what that feature normally does. What it does cover is what the bug class is, which tool he used to find it, two attacks he demonstrated with it, and how the report moved through the bug bounty process. He was paid 500 USD, and the write-up was published on 24 December 2022.

Before going further, two ideas need explaining, because everything else rests on them.

A web server is the computer (or fleet of computers) that holds a website and answers requests. When you type an address into your browser, the browser sends a request over the internet and the server sends back a response. That response has two parts: a set of headers, which are short labelled lines of housekeeping information, and a body, which is the actual page content. Headers are things like "here is a cookie" or "this content is HTML". You never see them on the page, but your browser reads them and acts on them.

A cookie is a small piece of text that a website asks your browser to store and to send back on every later visit to that site. It is how a site remembers who you are between page loads, for example that you are logged in. The server hands a cookie to the browser with a header line that starts with Set-Cookie:. Think of it as a coat-check ticket: the server writes the ticket, the browser keeps it in its pocket and shows it again next time.

From the original on infosecwriteups.com

What CRLF means

CRLF stands for Carriage Return and Line Feed. These are two invisible characters that, taken together, mean "the line ends here, start a new one". In many computing contexts they mark the end of a line of text. The name comes from old typewriters: carriage return moved the typing head back to the left margin, line feed rolled the paper up one line. Computers kept the idea.

Why does that matter for security? Because in a web response, a line break is what separates one header from the next. If a website takes something a user typed and puts it into a header without cleaning it, and that something contains CRLF, the browser will treat whatever follows the line break as a brand new header written by the server. The user has effectively been allowed to write server instructions. The report puts it this way: if developers do not properly handle CRLF sequences and do not sanitise user-generated content, an attacker can inject content into the response.

Sanitise here means to strip out or neutralise dangerous characters before using input. If you are going to paste a visitor's text into a header, you remove any CR and LF characters first, so the text cannot break out of its line.

The report names two main uses of a CRLF injection:

  • Log splitting: the attacker inserts an end-of-line character and an extra line to falsify log file entries, deceiving system administrators and hiding other attacks. A log file is the running diary a server keeps of what happened to it. If an attacker can write fake lines into that diary, an administrator reading it later may be misled about what really occurred.
  • HTTP response splitting: CRLF injection is used to add HTTP headers to the HTTP response and, for example, perform an XSS attack that leads to information disclosure. XSS (cross-site scripting) is when an attacker gets their own code to run inside someone else's browser in the context of a trusted site. Information disclosure means data that should have stayed private leaks out.

The Report

From the original on infosecwriteups.com

How the researcher found the CRLF

He used a tool called crlfuzz, available at https://github.com/dwisiswant0/crlfuzz. It is a command-line tool, meaning it is run by typing commands into a text window rather than by clicking buttons. It tests for CRLF injection by injecting CRLF sequences into HTTP headers.

A command-line tool is a program you operate by typing its name and some options. It is the difference between ordering at a counter and using a self-service machine: fewer pictures, more precision, and easy to repeat exactly.

The report does not give a version number for the tool, and it does not describe any account, role or other precondition on the target. The testing was done from the outside, as any visitor could.

The workflow he describes is: clone the repository, install the necessary dependencies, then run the tool with the target URL and the desired payload as arguments. A repository is a folder of source code published online, usually on a site like GitHub, that you can copy down to your own machine. Dependencies are other pieces of software the tool needs in order to work, like ingredients a recipe assumes you already have. A payload is the piece of text an attacker feeds in, hoping the target will treat it as instructions rather than as harmless data. A URL is a web address.

The tool injects the payload into the HTTP headers and sends the request to the target website.

Step 1: run crlfuzz against the target

Bash
▶ crlfuzz -u "http://target"

Line by line:

  • ▶ is just the prompt symbol shown in the report, the little marker before a typed command. You do not type it.
  • crlfuzz is the name of the program being run.
  • -u is an option (a flag) that tells the program the next thing is a URL to test.
  • "http://target" is the address being tested. The quotes keep the address together as one item.

Why this step: before you can demonstrate an attack, you need to know whether the bug is there at all. Running the scanner is the cheap first check. The tool then injects CRLF sequences into HTTP headers and sends the resulting requests to the target. If the website is vulnerable, the tool receives a response indicating that the injected payload was successfully executed. In other words, the scanner looks at what came back and checks whether its injected text was treated as a real header rather than as inert text.

From the original on infosecwriteups.com

Step 2: the cookie bomb

In the first attack scenario, the researcher injected a cookie bomb into the website. A cookie bomb aims to overwhelm a website's server by injecting a large number of cookies into the user's browser, which can make the site slow or unresponsive for the affected user. The everyday comparison: imagine a shop that asks you to carry a form for every item you have ever bought, and insists you hand over the whole stack at the door each time. Eventually the doorway jams.

The payload given as an example is:

HTTP
Set-Cookie: bomb=1Set-Cookie: bomb=2Set-Cookie: bomb=3…Set-Cookie: bomb=10000

What this shows:

  • Set-Cookie: is the header a server uses to give the browser a cookie.
  • bomb=1 is one cookie named bomb with the value 1.
  • The next Set-Cookie: bomb=2 is meant to be a second, separate header line. In a normal response each header sits on its own line, and the line break between them is exactly the CRLF the bug is about.
  • The … stands for the lines in between, which the report does not spell out.
  • Set-Cookie: bomb=10000 is the last one, so the example describes 10000 cookies.

This payload would inject 10000 cookies into the user's browser, potentially causing the website to become slow or unresponsive.

Step 3: trigger a Cloudflare WAF block

In the second scenario, the researcher set a cookie and triggered a Cloudflare WAF block. Cloudflare is a company whose services sit in front of many websites. A WAF (Web Application Firewall) is a filter that inspects incoming traffic and blocks requests that look like attacks, including injection attacks. When a WAF block is triggered, the website's server has detected potentially malicious activity and is blocking access to the website to protect it. Think of it as a bouncer at the door who turns away anyone whose coat looks suspicious.

The payload given as an example is:

HTTP
Set-Cookie: crlf=attack

What this shows:

  • Set-Cookie: again is the header that hands a cookie to the browser.
  • crlf is the cookie's name.
  • attack is its value.

This payload sets a cookie with the value attack, which may be detected as malicious by the website's server and trigger a Cloudflare WAF block. The report says the cookie value may be detected as malicious and trigger a Cloudflare WAF block.

Why the bug exists

A parameter is a named slot in a request that carries a value, for example the part of an address after a question mark. What the report does establish is that CRLF sequences could be injected into HTTP headers on the target. The likely cause is that user-controlled input was written into a response header without stripping or rejecting CR and LF characters. The second scenario shows that a WAF was in front of the site, and that the injected cookie value could itself be used to provoke a WAF block.

Impact

The report describes the impact of CRLF injection as diverse, ranging from cross-site scripting to information disclosure. It can also disable security restrictions such as XSS filters and the Same Origin Policy in victims' browsers, leaving them vulnerable to malicious attacks. The Same Origin Policy is the browser rule that stops a page from one site reading data belonging to another site; if it is disabled, that separation collapses. With the attack scenarios described, the researcher was able to show how quickly the site can be rendered unusable for a single user. The cookie bomb affects the individual user whose browser receives the injected cookies; the report does not claim a wider effect.

Timeline

Event Date
Submitted 16 Nov 2021
Accepted 17 Nov 2021
Triaged 17 Nov 2021
Needs more info 13 Dec 2021 (the researcher supplied more information)
Triaged again 19 Aug 2022, bounty 500 USD
Resolved / Closed not stated

A few of those words need unpacking. Submitted means the researcher sent the report to the programme. Accepted means the programme acknowledged it as worth looking at. Triaged means someone assessed it and confirmed it is a real issue. Needs more info means the programme asked questions and the researcher answered them. Bounty is the money paid for a valid report. Resolved / Closed is the final state; the report leaves that date blank.

Fix

The general guidance it gives is that developers should properly handle CRLF sequences and sanitise user-generated content, and that a WAF should be configured correctly so that it effectively protects against potential attacks.

Variants to test

The report lists two tools for further work: crlfuzz and the researcher's own payload collection at https://github.com/Proviesec/crlf-payloads. It also points to five public reports as prior art, meaning earlier examples of the same kind of finding:

Report Program Bounty
1575912 Cloudflare 3100 USD
446271 Twitter 2940 USD
197279 Airbnb 2500 USD
192667 Starbucks not stated
237357 Snapchat 500 USD

The report's closing tips translate into concrete tests:

  1. Study the mechanics first. Understand how CRLF injection works so you can recognise potential vulnerabilities and design effective test cases. A test case is a specific input you try, with a clear idea of what result would prove the bug.
  2. Scrutinise headers and cookies. CRLF injection often involves manipulating these elements.
  3. Test different browsers and applications. The same vulnerability may affect different browsers and applications in different ways, so test as many combinations as possible. A client here means the browser or app making the request.
  4. Report responsibly. Follow responsible disclosure guidelines and report the issue to the affected website's security team as soon as possible. Responsible disclosure means giving the owner a private chance to fix the problem before you talk about it publicly.

The researcher's HackerOne profile is https://hackerone.com/proviesec. HackerOne is a platform where organisations run bug bounty programmes and researchers submit reports.

Glossary

  • Bounty: money paid by a bug bounty programme for a valid security report.
  • Client: the browser or application that sends a request to a server.
  • Cloudflare: a company whose services sit in front of many websites, including a WAF.
  • Command-line tool: a program operated by typing its name and options into a text window.
  • Cookie: a small piece of text a website asks the browser to store and send back on later visits, used to remember things like a login.
  • Cookie bomb: an attack that floods a user's browser with a large number of cookies so the site becomes slow or unresponsive for that user.
  • CRLF: Carriage Return and Line Feed, two invisible characters that together mark the end of a line of text.
  • CRLF injection: getting CRLF characters into a place where line breaks matter, such as a response header, so that extra content can be injected.
  • Dependencies: other pieces of software a tool needs in order to run.
  • Flag: an option given to a command-line tool, such as -u.
  • HackerOne: a platform where organisations run bug bounty programmes and researchers submit reports.
  • Header: a short labelled line of housekeeping information in a web request or response, separate from the page content.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • HTTP response splitting: using CRLF injection to add extra headers to a response.
  • Information disclosure: leaking data that should have stayed private.
  • Log file: the running diary a server keeps of what happened to it.
  • Log splitting: inserting fake lines into a log file to mislead administrators and hide other attacks.
  • Parameter: a named slot in a request that carries a value.
  • Payload: the piece of text an attacker feeds in, hoping it will be treated as instructions.
  • Repository: a folder of source code published online that you can copy to your own machine.
  • Responsible disclosure: giving the owner a private chance to fix a problem before it is discussed publicly.
  • Same Origin Policy: the browser rule that stops a page from one site reading data belonging to another site.
  • Sanitise: strip out or neutralise dangerous characters in input before using it.
  • Test case: a specific input you try, with a clear idea of what result would prove the bug.
  • Triaged: assessed and confirmed as a real issue by the receiving programme.
  • URL: a web address.
  • WAF (Web Application Firewall): a filter in front of a website that blocks requests that look like attacks.
  • Web server: the computer that holds a website and answers requests for it.
  • XSS (cross-site scripting): getting an attacker's code to run inside someone else's browser in the context of a trusted site.

More by Proviesec

View all

3 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Request smuggling and header injection

The lesson behind this report.

A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.