Skip to content
Smuggling / CRLF Disclosed report Advanced

HTTP Request Smuggling in Transform Rules using hexadecimal escape sequences in the concat() function

The Cloudflare Transform Rules engine allowed hexadecimal escape sequences in string functions like concat(), enabling injection of newlines into header values. An attacker could create a dynamic header rewrite rule to change the transfer encoding and perform HTTP request smuggling (TE.CL), bypassing security products such as Cloudflare Access and viewing internal origin server content.

Albert Pedersen Follow

Originally disclosed on HackerOne

Bounty$6,000incl. $3,000 bonus Critical 10.0 View original
  • Triaged in 3 days
  • Fixed in 4 days
  • Paid in 3 days
  • Disclosed after 3 months

Summary by the program

The Edge Rules engine used by Cloudflare Transform Rules features string modifying functions like lower() and concat(), which accepted hexadecimal-encoded characters such as ”\x0a\x0d“. This allowed for manipulation of request headers (e.g. injecting an additional header) and, as a consequence, made HTTP smuggling attack (TE.CL) possible. This vulnerability enabled an attacker to bypass security products such as Cloudflare Access and view the content of internal origin servers. This bug in hexadecimal parsing was fixed by the relevant engineering team. We rewarded this finding as critical as well as a bonus for a high quality, detailed report. Internal investigation confirmed that no other CF customer was affected by this attack. As a recommendation, we advise Cloudflare Access customers to always verify the Authorization JWT token before processing requests from the Cloudflare edge.

Summary by the researcher

Cloudflare's Ruleset Engine allows the use of hexadecimal escape sequences in string manipulation functions such as concat(). Due to a lack of output sanitation, this enabled an attacker to inject newlines into the header value. By creating a dynamic header rewrite rule with the value concat("-", "\x0d\x0aTransfer-Encoding: chunked"), it was possible to change the transfer encoding of the request. When combined with a POST body such as 0\r\n\r\nGET / HTTP/1.1\r\nHost: internal.example.com\r\n\r\n it made HTTP request smuggling extremely trivial. Additionally, the position of Transform Rules in the request flow meant it was possible to use internal headers to control many aspects of the request. A fix was rolled out within hours of the report being submitted. I would like to thank the teams at Cloudflare for their efforts.

The original report as published on HackerOne, by albertspedersen. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

Cloudflare's Ruleset Engine powers Transform Rules, part of the Edge Rules engine. Transform Rules let a customer rewrite parts of a request or response at the edge, and the engine exposes string manipulation functions such as lower() and concat() for building those values. The feature is meant to compose header values from literals and existing fields, not to introduce new structure into the request.

The report concerns HTTP request smuggling, specifically the TE.CL variant, arising from how those string functions handled hexadecimal escape sequences. The program rated the finding critical with a CVSS score of 10.0 and paid a bounty of 6,000 USD. It was disclosed on 2022-05-16.

Setup

The report does not describe accounts, roles, tooling or versions. The precondition that matters is a Transform Rule that performs a dynamic header rewrite whose value is built with concat(), which is a normal customer-facing capability of the product. The researcher's summary states that the position of Transform Rules in the request flow also made internal headers usable to control many aspects of the request.

Finding it

The researcher observed that the Ruleset Engine accepts hexadecimal escape sequences inside string manipulation functions such as concat(). Because the output of those functions was not sanitised, a newline could be placed into a header value. A header value that can contain a carriage return and line feed is no longer a value: it is a boundary between headers, and the engine was writing it into the request that goes onward to the origin.

Exploitation

Step 1: inject a new header through a dynamic header rewrite

The researcher created a dynamic header rewrite rule whose value was:

Text
concat("-", "\x0d\x0aTransfer-Encoding: chunked")

The concat() call joins a literal - with the bytes \x0d\x0a, a carriage return and line feed, followed by a new header line, Transfer-Encoding: chunked. The escape sequences were decoded by the engine and the result was written into the header value without sanitation, so the CRLF terminated the original header and the remainder became a header of its own. The effect was to change the transfer encoding of the request.

Step 2: supply a chunked body that contains a second request

With the request now declared as chunked, the researcher sent a POST body of the following form:

Text
0\r\n\r\nGET / HTTP/1.1\r\nHost: internal.example.com\r\n\r\n

The leading 0\r\n\r\n is a zero-length chunk, which ends the chunked body. Everything after it is treated by the next hop as the start of a new request: GET / HTTP/1.1 with Host: internal.example.com. The researcher describes the combination of the injected Transfer-Encoding header and this body as making HTTP request smuggling extremely trivial.

Step 3: reach internal content

Because Transform Rules sit at a particular point in the request flow, the researcher could also use internal headers to control many aspects of the request. The program's summary records the consequence: the smuggling allowed an attacker to bypass security products such as Cloudflare Access and view the content of internal origin servers.

Root cause

The string manipulation functions accepted hexadecimal escape sequences and their output was not sanitised before being placed into a header value. A CRLF inside a value is interpreted by the receiving parser as the end of that header, so the attacker controls header structure rather than just header content. Declaring Transfer-Encoding: chunked on the front-end request while the back-end parses the body differently is the classic TE.CL desynchronisation, and here the front-end side of that disagreement was produced by the edge rule engine itself.

Why existing defences did not stop it is not described in the report. The report does not describe why existing defences did not stop it.

Impact

Under the conditions above, an attacker could manipulate request headers, including injecting additional headers, and smuggle a second request past the edge. The program states that this enabled bypassing security products such as Cloudflare Access and viewing the content of internal origin servers. The program also states that an internal investigation confirmed no other Cloudflare customer was affected by this attack.

Fix

The program states that the bug in hexadecimal parsing was fixed by the relevant engineering team, and the researcher notes that a fix was rolled out within hours of the report being submitted. As a separate recommendation, the program advises Cloudflare Access customers to always verify the Authorization JWT token before processing requests from the Cloudflare edge.

Variants to test

  1. Other string functions in the same engine. Try hexadecimal escapes in functions beyond concat(), such as case conversion or other modifiers, and check whether the decoded bytes reach the header value. A positive result is a response or downstream request in which the injected CRLF has created a new header line.
  2. Other escape syntaxes. Test whether the engine decodes alternative representations of carriage return and line feed, and whether the same lack of sanitation applies. A positive result is any decoded control character appearing in a header value.
  3. Other injection points. Apply the same reasoning to any rule action that writes attacker-influenced strings into a request or response, not only header rewrites. A positive result is a smuggled request observed by a listener you control, or a response that reflects the injected structure.
  4. Transfer-Encoding variants. Once a CRLF injection into headers is confirmed, test whether the front-end and back-end disagree on chunked framing, which is what turns header injection into smuggling.

Hunting notes

This class of bug hides in edge and CDN rule engines: features that let customers build header values from expressions are the natural place to look, because the engine is trusted to serialise the request correctly. During recon, look for products that expose string functions over request fields, and for documentation that mentions escape sequences or encoding in those functions. The signal is a function that decodes input and then writes it into protocol structure without validation.

On impact, the researcher showed more than a reflected newline: the injected Transfer-Encoding header plus a zero-length chunk and a following request demonstrated actual desynchronisation, and the program tied it to bypassing Cloudflare Access and reading internal origin content. The program rated the finding critical and awarded a bonus for a high quality, detailed report.

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. 14 min read.

What happened, in plain words

Cloudflare is a company that sits between visitors and websites. When you open a website that uses Cloudflare, your browser does not talk to the website's own server directly. It talks to Cloudflare first, and Cloudflare passes the request on. This is often called an "edge": a layer at the outer boundary of a network that handles traffic before it reaches the inner servers.

Cloudflare lets its customers write small rules that change requests as they pass through that edge. One of these features is called Transform Rules. A customer can say, for example, "take the value of this header and add something to it". A header is a small labelled line of information that travels with every web request, such as which website you want or what kind of browser you use. A rule that changes a header is called a header rewrite.

The researcher found that one of the string-building functions used in these rules, concat(), accepted special escape sequences written in hexadecimal (base-16) notation. In particular, it accepted \x0d and \x0a, which are the two invisible characters that mark the end of a line in HTTP, the protocol browsers and servers use to talk to each other. Because the result was not cleaned up before being placed into a header, an attacker could slip a line break into a header value. A line break inside a header value is dangerous: the receiving server reads it as "this header ends here, and a new one begins". That let the attacker add headers of their own choosing.

With that ability, the researcher could make a request look like it uses a different way of sending its body (chunked encoding, explained below). Combined with a carefully crafted body, this made it possible to hide a second, complete request inside the first one. This trick is called HTTP request smuggling. The smuggled request could then reach internal servers that are supposed to be protected by Cloudflare Access, a Cloudflare product that checks who is allowed in. The program rated the finding critical, with a CVSS score of 10.0, and paid a bounty of 6,000 USD. It was disclosed on 2022-05-16.

Context

What the product does

Cloudflare's Ruleset Engine is the part of Cloudflare that evaluates customer-written rules. Transform Rules are one feature built on top of it, and they are part of the Edge Rules engine. The point of Transform Rules is to let a customer rewrite parts of a request or a response while it is at the edge, before it continues on its journey. The engine offers string manipulation functions such as lower() (which turns text into lowercase) and concat() (which joins pieces of text together) so customers can build those values.

The intended use is to compose a header value out of fixed text and existing fields. For example, a rule might build a value from a dash and some other piece of information. The feature is not meant to let anyone introduce new structure into the request, such as extra headers or extra requests.

What kind of bug this is

HTTP request smuggling is a class of vulnerability where two systems that handle the same request disagree about where one request ends and the next one begins. Imagine a postal worker and a mailroom clerk reading the same envelope with different ideas about which lines are the address and which are the letter inside. If you can exploit that disagreement, you can hide an extra letter inside the first one, and the clerk will deliver it as if it were a genuine, separate piece of mail.

There are several variants of smuggling. This report concerns the TE.CL variant. TE stands for Transfer-Encoding, a header that tells the receiver how the body of the request is framed. CL stands for Content-Length, a header that gives the body size in bytes. TE.CL means the front-end system trusts the Transfer-Encoding header while the back-end system uses Content-Length, so the two disagree about the body. The report does not go into the details of the back-end side; what matters here is that the front-end side of the disagreement was produced by the edge rule engine itself.

The numbers

The program rated the finding critical, with a CVSS score of 10.0. CVSS is a standard scoring system for the severity of a security flaw, where 10.0 is the maximum. The bounty was 6,000 USD, and the report was disclosed on 2022-05-16.

Setup

The report does not describe accounts, roles, tooling or versions. The precondition that matters is a Transform Rule that performs a dynamic header rewrite whose value is built with concat(). "Dynamic" here means the value is computed by the rule rather than typed as a fixed string. This is a normal customer-facing capability of the product.

The researcher's summary also notes that the position of Transform Rules in the request flow made internal headers usable to control many aspects of the request. In other words, because the rules run at a particular point in the chain of systems that handle a request, the headers they produce can influence how later systems treat that request.

Finding it

The researcher observed that the Ruleset Engine accepts hexadecimal escape sequences inside string manipulation functions such as concat(). A hexadecimal escape sequence is a way of writing a character by its numeric code. \x0d means the character with code 13, which is a carriage return (CR), and \x0a means code 10, a line feed (LF). Together, CR and LF are the two characters that end a line in HTTP. They are usually written together as CRLF.

Because the output of those functions was not sanitised, a newline could be placed into a header value. Sanitising means checking and cleaning data before using it, for example by removing or escaping characters that have a special meaning. Here, nothing removed the CRLF, so it went straight into the request that the edge sent onward to the origin. The origin is the customer's own server, the one that actually holds the website content.

A header value that can contain a CRLF is no longer just a value. It is a boundary between headers. The receiving parser sees the CRLF and concludes that the current header has ended, and whatever follows is a new header. So the engine was effectively letting the attacker write header structure, not just header content.

Exploitation

Step 1: inject a new header through a dynamic header rewrite

The researcher created a dynamic header rewrite rule whose value was:

Text
concat("-", "\x0d\x0aTransfer-Encoding: chunked")

Line by line, in plain words:

  • concat( starts a call to the function that joins pieces of text together. Everything inside the brackets is the list of pieces to join, separated by commas.
  • "-" is the first piece: a single dash character, written as a fixed string in double quotes.
  • "\x0d\x0aTransfer-Encoding: chunked" is the second piece. It begins with the two escape sequences \x0d and \x0a, which the engine decodes into a carriage return and a line feed. After those invisible characters comes the visible text Transfer-Encoding: chunked, which is a complete header line.
  • The closing ) ends the function call.

So the rule builds a value that starts with a dash, then contains a line break, then contains a new header line. The escape sequences were decoded by the engine, and the result was written into the header value without sanitation. The CRLF terminated the original header, and the remainder became a header of its own. The effect was to change the transfer encoding of the request.

Why does changing the transfer encoding matter? Transfer-Encoding is the header that tells the receiver how to read the body. The value chunked means the body is sent in pieces, each piece preceded by its length written in hexadecimal, and the body ends with a piece of length zero. If an attacker can add this header, they can decide how the next system will read the body, and that is the first half of a smuggling attack.

Step 2: supply a chunked body that contains a second request

With the request now declared as chunked, the researcher sent a POST body of the following form:

Text
0\r\n\r\nGET / HTTP/1.1\r\nHost: internal.example.com\r\n\r\n

Line by line, in plain words:

  • 0 is the length of the first chunk, written in hexadecimal. A chunk of length zero is special: it means "the body ends here".
  • \r\n is the carriage return and line feed that ends that chunk-size line. In this notation the two characters are written as escapes rather than as real line breaks, so the whole body can be shown on one line.
  • The second \r\n is the empty line that follows the zero-length chunk and completes the end of the chunked body.
  • GET / HTTP/1.1 is the start of a brand new HTTP request: the method GET, the path /, and the protocol version HTTP/1.1.
  • \r\n ends that request line.
  • Host: internal.example.com is a header telling the receiver which host the request is for. internal.example.com is a placeholder name used in the report.
  • \r\n\r\n is the empty line that ends the headers of this second request.

The leading 0\r\n\r\n is a zero-length chunk, which ends the chunked body. Everything after it is treated by the next hop as the start of a new request: GET / HTTP/1.1 with Host: internal.example.com. The next hop is the next system in the chain, the one that receives the request after the edge. The researcher describes the combination of the injected Transfer-Encoding header and this body as making HTTP request smuggling extremely trivial.

Why does this work? The front-end system reads the body as chunked, sees the zero-length chunk, and considers the request finished. The back-end system, using a different rule for where the body ends, keeps reading and finds the GET / HTTP/1.1 line. It treats that line as the beginning of a new request that arrived on the same connection. That new request was never meant to exist, and it can be aimed at internal destinations.

Step 3: reach internal content

Because Transform Rules sit at a particular point in the request flow, the researcher could also use internal headers to control many aspects of the request. The program's summary records the consequence: the smuggling allowed an attacker to bypass security products such as Cloudflare Access and view the content of internal origin servers.

Cloudflare Access is a product that acts like a door check: it decides whether a visitor is allowed to reach an internal application. If a request can be smuggled past that check, the smuggled request arrives at the internal server as though it had already passed the door. The internal origin servers are the machines inside the customer's network that hold the actual content, which are normally not reachable from the outside at all.

Root cause

The string manipulation functions accepted hexadecimal escape sequences, and their output was not sanitised before being placed into a header value. A CRLF inside a value is interpreted by the receiving parser as the end of that header, so the attacker controls header structure rather than just header content. Declaring Transfer-Encoding: chunked on the front-end request while the back-end parses the body differently is the classic TE.CL desynchronisation, and here the front-end side of that disagreement was produced by the edge rule engine itself.

Why existing defences did not stop it is not described in the report. The report does not describe why existing defences did not stop it. "Opaque" means the engine did not look inside the string or interpret it; it just passed it along. "Serialising" means turning the internal representation into the actual bytes that go on the wire.

Impact

Under the conditions above, an attacker could manipulate request headers, including injecting additional headers, and smuggle a second request past the edge. The program states that this enabled bypassing security products such as Cloudflare Access and viewing the content of internal origin servers. The program also states that an internal investigation confirmed no other Cloudflare customer was affected by this attack.

Fix

The program states that the bug in hexadecimal parsing was fixed by the relevant engineering team, and the researcher notes that a fix was rolled out within hours of the report being submitted. As a separate recommendation, the program advises Cloudflare Access customers to always verify the Authorization JWT token before processing requests from the Cloudflare edge.

A JWT, or JSON Web Token, is a compact, signed piece of data that a server can check to confirm who a request comes from and that the data has not been tampered with. The advice is to check that token on the origin side, rather than assuming that anything arriving from the edge has already been checked.

Variants to test

These are directions for further research, written for someone learning how to look for similar bugs.

  1. Other string functions in the same engine. Try hexadecimal escapes in functions beyond concat(), such as case conversion or other modifiers, and check whether the decoded bytes reach the header value. A positive result is a response or downstream request in which the injected CRLF has created a new header line.
  2. Other escape syntaxes. Test whether the engine decodes alternative representations of carriage return and line feed, and whether the same lack of sanitation applies. A positive result is any decoded control character appearing in a header value.
  3. Other injection points. Apply the same reasoning to any rule action that writes attacker-influenced strings into a request or response, not only header rewrites. A positive result is a smuggled request observed by a listener you control, or a response that reflects the injected structure.
  4. Transfer-Encoding variants. Once a CRLF injection into headers is confirmed, test whether the front-end and back-end disagree on chunked framing, which is what turns header injection into smuggling.

Hunting notes

This class of bug hides in edge and CDN rule engines. A CDN, or content delivery network, is a network of servers spread around the world that caches and delivers content close to visitors; Cloudflare's edge is an example of this idea. Features that let customers build header values from expressions are the natural place to look, because the engine is trusted to serialise the request correctly. If the engine gets that wrong, everything downstream inherits the mistake.

During recon, which means the early information-gathering phase of a security assessment, look for products that expose string functions over request fields, and for documentation that mentions escape sequences or encoding in those functions. The signal is a function that decodes input and then writes it into protocol structure without validation.

On impact, the researcher showed more than a reflected newline. A reflected newline is a line break that simply comes back in a response, which on its own is often minor. Here, the injected Transfer-Encoding header plus a zero-length chunk and a following request demonstrated actual desynchronisation, meaning the two systems really did disagree about the request boundaries. The program tied it to bypassing Cloudflare Access and reading internal origin content. The program rated the finding critical and awarded a bonus for a high quality, detailed report.

Glossary

  • API: an interface that lets one piece of software ask another to do something, like a service counter where you make a request and get a defined response.
  • Back-end: the system further along the chain that finally processes a request, as opposed to the front-end that receives it first.
  • Bounty: a payment made by a company to a researcher who reports a security flaw.
  • CDN (content delivery network): a network of servers placed around the world to deliver content close to visitors.
  • Chunked encoding: a way of sending a body in pieces, each preceded by its length in hexadecimal, ending with a piece of length zero.
  • Cloudflare Access: a Cloudflare product that checks whether a visitor is allowed to reach an internal application.
  • concat(): a function that joins several pieces of text into one string.
  • Content-Length: a header giving the size of the request body in bytes.
  • CRLF: carriage return followed by line feed, the two characters that end a line in HTTP.
  • CVSS: a standard scoring system for the severity of a security flaw, from 0 to 10.
  • Desynchronisation: a state where two systems handling the same request disagree about where it starts or ends.
  • Dynamic header rewrite: a rule that computes a new header value at run time rather than using a fixed string.
  • Edge: the outer layer of a network that handles traffic before it reaches the inner servers.
  • Escape sequence: a way of writing a character by a code, such as \x0d for carriage return.
  • Header: a labelled line of information sent with an HTTP request or response.
  • Hexadecimal: base-16 notation, using digits 0 to 9 and letters A to F.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • HTTP request smuggling: a class of attack where two systems disagree about request boundaries, allowing a hidden extra request to be slipped through.
  • JWT (JSON Web Token): a compact, signed piece of data used to confirm who a request comes from and that it has not been tampered with.
  • lower(): a function that converts text to lowercase.
  • Origin server: the customer's own server that holds the actual website content.
  • Parser: the part of a system that reads incoming data and works out its structure.
  • POST: an HTTP method used to send data in the body of a request.
  • Recon: the early information-gathering phase of a security assessment.
  • Ruleset Engine: the Cloudflare component that evaluates customer-written rules.
  • Sanitise: to check and clean data before use, removing or escaping characters with special meaning.
  • Serialise: to turn an internal representation into the actual bytes sent over the network.
  • String manipulation function: a function that builds or changes text, such as joining or changing case.
  • TE.CL: a smuggling variant where the front-end trusts Transfer-Encoding and the back-end uses Content-Length.
  • Transform Rules: a Cloudflare feature that rewrites parts of a request or response at the edge.
  • Transfer-Encoding: a header that tells the receiver how the body is framed, for example as chunked.

More by Albert Pedersen

View all

6 more disclosed reports, best first.

More from Cloudflare Public Bug Bounty

View all

The newest disclosed reports for this program.

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.