Denial of Service using Cookie Bombing
The website reflected values from GET parameters into cookies without size limits, allowing an attacker to set multiple large cookies. A victim visiting a crafted link would have all subsequent requests rejected by the server due to oversized headers, causing a denial of service.
Published on medium.com
{{media:0}}
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This write-up describes a denial of service found on a private HackerOne program. Because the program was private, the researcher refers to the target throughout as example.com. The affected feature is the site's handling of certain GET parameters: when a request carries one of these parameters, the server copies the supplied value into a cookie on the response. That behaviour is what the researcher turned against the site.
The technique used is cookie bombing. The idea, as the researcher explains it after reading filedescriptor's article on the subject, is that most servers reject a request whose headers reach roughly 8 KB, and that a single cookie can hold 4 KB of data. Set two cookies of 4 KB each on a victim's browser and every later request from that browser is rejected with the response "Request Header or Cookie too Large".
Setup
The researcher worked against the private program's main site, loading the home page in a browser and watching traffic through Burp proxy. Two tools are named: the Wappalyzer browser extension, used to see which technologies the site runs, and the Burp extension Param Miner, used to guess hidden GET parameters. No versions are given. The attack relies on the target reflecting GET parameter values into cookies, which the researcher established before going further.
Finding it
The first step on any target, as the researcher describes it, is to load the main page and observe the technologies in use with Wappalyzer. Then, with Burp proxying the traffic, the first request, a simple GET to the home page at WWW.EXAMPLE.COM, was inspected. Looking at its headers and response prompted the question of whether there were hidden GET parameters.
The screenshot shows Param Miner being used to brute force parameter names against the home page.
Param Miner identified a few parameters. The researcher does not list all of them, but the two that matter later are context and utm_source.
The second screenshot shows the parameters Param Miner identified.
Requests were then sent with those parameters and with unusual inputs. The response showed that the value supplied to these GET parameters was being written into a cookie on the response. That is the behaviour the whole attack rests on: input to a GET parameter becomes a cookie value.
Exploitation
Step 1: confirm that parameters set cookies
Send requests to the home page with the identified GET parameters and observe the Set-Cookie headers in the response. Any value passed in is reflected as a cookie value. This alone is not a vulnerability, but it is the primitive the rest of the attack needs.
Step 2: work out how to abuse it
A search for vulnerabilities that fit this behaviour led the researcher to filedescriptor's article on cookie bombs, a technique the researcher had not previously known. The plan taken from that article: make the victim's browser hold enough cookie data that the server rejects every subsequent request.
Step 3: send oversized values in the two parameters
The researcher set context and utm_source to long strings of a characters, 4 KB each, in a single request to the home page. The report shows the request as a URL:
Each parameter carries roughly 4 KB of padding, so the two cookies together push the request headers past the size most servers accept.
Step 4: observe the cookies in the browser
The screenshot shows the cookies as stored in the browser after the request. The report says the cookies set were analytics_source and site, holding the 4 KB of data supplied in the input. The server also set the cookies' validity to one year by default.
Step 5: observe the server rejecting later requests
The screenshot shows the server response carrying the larger cookie values. From that point, every request from the victim's browser is rejected until the cookies expire at the end of the one-year validity period, or until the victim deletes them manually from the browser.
With this proof of concept the researcher submitted the bug and received a $350 bounty.
Root cause
The design mistake is that the application takes user-controlled GET parameter values and stores them as cookie values, with a one-year lifetime by default. Because cookies are sent back by the browser on every request to the site, an attacker who can make a victim's browser issue one crafted request inflates the victim's request headers for the cookie lifetime. Once the headers exceed the server's limit, the server refuses the requests, and the victim cannot load the site at all. The report does not describe any server-side cap on cookie size or any validation of the parameter values, so the only limit in play is the server's header size limit, which the attack deliberately crosses.
Impact
A victim who follows a crafted link has two cookies of about 4 KB each set on the target domain, valid for one year by default. From then on the server rejects all of that victim's requests to the site with "Request Header or Cookie too Large", so the site is unusable in that browser until the cookies are deleted manually. The effect is limited to the victim's own browser and to the affected domain; the report does not describe any wider effect on the service or on other users.
Fix
The measure its description points to is to stop writing arbitrary parameter values into cookies: cap the length of any value copied into a cookie, and do not give such cookies a long lifetime when their content comes from user input.
Variants to test
- Run Param Miner against other endpoints and look for parameters whose values come back in
Set-Cookie. A positive result is a response where the value you supplied appears as a cookie value. - Send a single parameter with a 4 KB value and check the cookie's size and expiry. A positive result is a cookie of that size with a long expiry, which means one parameter may be enough if the server's header limit is low.
- Send two parameters with 4 KB values each, as in this report, and then reload the site. A positive result is the server rejecting the follow-up requests with a header or cookie too large error.
- Check whether the same reflection exists on other hosts or subdomains that share the cookie scope. A positive result is the oversized cookie being sent to, and rejected by, more than the original host.
What happened, in plain words
A security researcher found a way to make a website unusable for a single visitor, using nothing more than a specially crafted web link. The trick is called cookie bombing. The site had a feature that copied values from the address bar (the part of a URL after the ? sign) into small pieces of data that the browser stores and sends back to the site on every visit. Those pieces of data are called cookies. By putting a very large value into the address bar, the researcher could make the browser store very large cookies. Browsers send cookies back with every request, and servers refuse requests that carry too much data in their headers. Once the oversized cookies were stored, the server rejected every later request from that browser with the message "Request Header or Cookie too Large". The site stayed broken for that visitor for a year, or until they deleted the cookies by hand.
The researcher found this on a private bug bounty program on HackerOne. A bug bounty program is a scheme where a company invites independent researchers to look for security problems and pays them for valid findings. Because the program was private, the researcher calls the target example.com throughout the article instead of naming it. The finding earned a $350 bounty.
Background: the pieces you need to know
Before the steps make sense, here are the basic ideas, explained from zero.
- A URL and its query string. A web address like
https://www.example.com/?context=hellohas two parts. The part before the?says which page you want. The part after the?carries extra information, called parameters, in the formname=value, with several joined by&. The site's software can read those values and change what it sends back. - GET parameters. When your browser asks a server for a page, it uses a method called GET. Parameters sent in the URL like this are called GET parameters. They are visible to anyone who sees the link, which is why they are a common place to look for problems.
- A cookie. A cookie is a small label that a website asks your browser to keep. The server sends it in a response header called
Set-Cookie, and the browser stores it. On every later request to that same site, the browser automatically attaches the cookie back in aCookieheader. Cookies are how sites remember you between page loads, for example to keep you logged in. Think of them as sticky notes the site gives your browser and asks it to show at the door every time. - A header. Every request and response between a browser and a server carries headers: short lines of extra information such as what browser you use, what page you want, and which cookies you hold. Headers travel in front of the actual content.
- A proxy. A proxy is a tool that sits between your browser and the internet and lets you see and change every request and response. The researcher used Burp, a well-known proxy for security testing.
- A denial of service (DoS). A denial of service is any attack that stops a service from working for someone. It does not steal data; it makes the site unusable. Here the effect is limited to one visitor's browser rather than the whole site.
- A cookie bomb. A cookie bomb is a denial of service carried out by filling a victim's browser with oversized cookies, so that the server rejects their requests. The researcher learned the technique from an article by filedescriptor, which the report links to.
- A proof of concept (POC). A proof of concept is a concrete demonstration, such as a working link or a set of steps, that shows a reported bug really works.
The setup
The researcher worked against the private program's main site. The tools named in the report are:
- Wappalyzer, a browser extension that looks at a site and guesses which technologies it runs (for example which web server or framework). The researcher's habit on any new target is to load the home page and check this first.
- Burp, a proxy used to watch and inspect the traffic between the browser and the site.
- Param Miner, an extension for Burp that guesses hidden GET parameter names by trying many of them and watching how the server responds.
The report gives no versions for any of these tools. The attack relies on the site copying GET parameter values into cookies, which the researcher confirmed before going further.
Finding it
The first step, as the researcher describes it, is to load the main page and see what technologies the site uses with Wappalyzer. Then, with Burp in the middle watching the traffic, the first request was inspected: a simple GET to the home page at WWW.EXAMPLE.COM. Looking at its headers and its response raised the question of whether there were hidden GET parameters, ones the site accepts but does not advertise.
The screenshot shows Param Miner being used to brute force parameter names against the home page. Brute forcing here means trying a long list of likely names automatically and seeing which ones the server reacts to.
Param Miner identified a few parameters. The report does not list all of them, but the two that matter later are context and utm_source.
The second screenshot shows the parameters Param Miner identified.
Requests were then sent with those parameters and with unusual inputs. The response showed that the value supplied to these GET parameters was being written into a cookie on the response. That is the behaviour the whole attack rests on: whatever you put into a GET parameter comes back as a cookie value.
Exploitation
Step 1: confirm that parameters set cookies
Send requests to the home page with the identified GET parameters and watch the Set-Cookie headers in the response. Any value passed in is reflected as a cookie value. On its own this is not a vulnerability, but it is the building block the rest of the attack needs. The reason to check it first is that without this reflection there is nothing to abuse.
Step 2: work out how to abuse it
A search for vulnerabilities that fit this behaviour led the researcher to filedescriptor's article on cookie bombs, a technique the researcher had not known before. The plan taken from that article: make the victim's browser hold enough cookie data that the server rejects every later request. The reasoning is that most servers reject a request whose headers reach roughly 8 KB, and a single cookie can hold 4 KB of data. Two cookies of 4 KB each therefore push the request past the limit, and the server answers with "Request Header or Cookie too Large".
Step 3: send oversized values in the two parameters
The researcher set context and utm_source to long strings of a characters, 4 KB each, in a single request to the home page. The report shows the request as a URL:
Line by line:
https://www.example.com/is the home page of the target site.?starts the query string, the part of the URL that carries parameters.context=aaaa...(4 KB of a)...is the first parameter. Its name iscontextand its value is a very long run of the lettera, about 4 KB long. The site copies this value into a cookie.&separates one parameter from the next.utm_source=aaaa...(4 KB of a)...is the second parameter, again with about 4 KB ofaas its value.utm_sourceis a name normally used for marketing tracking, which is why it may not look suspicious at first glance.
Each parameter carries roughly 4 KB of padding, so the two cookies together push the request headers past the size most servers accept.
Step 4: observe the cookies in the browser
The screenshot shows the cookies as stored in the browser after the request. The report names the cookies set as analytics_source and site, each holding the 4 KB of data supplied in the input. The server also set the cookies' validity to one year by default. Validity, or expiry, is how long the browser keeps a cookie before discarding it. A one-year lifetime means the problem does not go away on its own for a long time.
Step 5: observe the server rejecting later requests
The screenshot shows the server response carrying the larger cookie values. From that point, every request from the victim's browser is rejected until the cookies expire at the end of the one-year validity period, or until the victim deletes them manually from the browser. The reason every request fails is that the browser attaches the cookies automatically to each one, so each request is now too large for the server to accept.
With this proof of concept the researcher submitted the bug and received a $350 bounty.
Why it works
The design mistake is that the application takes user-controlled GET parameter values and stores them as cookie values, with a one-year lifetime by default. Because cookies are sent back by the browser on every request to the site, an attacker who can make a victim's browser issue one crafted request inflates the victim's request headers for the cookie lifetime. Once the headers exceed the server's limit, the server refuses the requests, and the victim cannot load the site at all. The report does not describe any server-side cap on cookie size or any validation of the parameter values, so the only limit in play is the server's header size limit, which the attack deliberately crosses.
Who is affected
A victim who follows a crafted link has two cookies of about 4 KB each set on the target domain, valid for one year by default. From then on the server rejects all of that victim's requests to the site with "Request Header or Cookie too Large", so the site is unusable in that browser until the cookies are deleted manually. The effect is limited to the victim's own browser and to the affected domain; the report does not describe any wider effect on the service or on other users.
How to fix it
The measure its description points to is to stop writing arbitrary parameter values into cookies: cap the length of any value copied into a cookie, and do not give such cookies a long lifetime when their content comes from user input.
Things to try on other sites
- Run Param Miner against other endpoints and look for parameters whose values come back in
Set-Cookie. A positive result is a response where the value you supplied appears as a cookie value. - Send a single parameter with a 4 KB value and check the cookie's size and expiry. A positive result is a cookie of that size with a long expiry, which means one parameter may be enough if the server's header limit is low.
- Send two parameters with 4 KB values each, as in this report, and then reload the site. A positive result is the server rejecting the follow-up requests with a header or cookie too large error.
- Check whether the same reflection exists on other hosts or subdomains that share the cookie scope. A positive result is the oversized cookie being sent to, and rejected by, more than the original host.
Glossary
- Bug bounty program: a scheme where a company invites independent researchers to find security problems and pays them for valid findings.
- Private program: a bug bounty program that only invited researchers can see and report to.
- HackerOne: a platform that hosts bug bounty programs.
- Bounty: the money paid for a valid security report.
- URL: a web address; the part after
?is the query string. - Query string: the part of a URL after
?that carries parameters inname=valueform, joined by&. - GET parameter: a value passed in the URL when the browser asks a server for a page.
- Header: a short line of extra information sent with every request and response, such as cookies or browser details.
- Cookie: a small piece of data a site asks the browser to store and send back on every later request to that site.
Set-Cookie: the response header a server uses to ask the browser to store a cookie.- Cookie value: the content stored inside a cookie.
- Cookie expiry (validity): how long the browser keeps a cookie before discarding it.
- Proxy: a tool that sits between browser and internet so you can see and change traffic; Burp is one.
- Burp: a proxy tool used for security testing.
- Wappalyzer: a browser extension that guesses which technologies a site runs.
- Param Miner: a Burp extension that guesses hidden GET parameter names.
- Brute forcing: trying a long list of possibilities automatically until one works.
- Reflection: when a site copies a value you supplied back into its response, here into a cookie.
- Denial of service (DoS): an attack that stops a service from working for someone, without stealing data.
- Cookie bomb: a denial of service carried out by filling a victim's browser with oversized cookies so the server rejects their requests.
- Proof of concept (POC): a concrete demonstration that a reported bug really works.
- Root cause: the underlying design or coding mistake that makes a bug possible.
- Endpoint: a specific address on a site that accepts requests, such as the home page.
- Subdomain: a part of a domain in front of the main name, such as
shop.example.com. - Cookie scope: which hosts and paths a browser sends a given cookie to.