-
-
Notifications
You must be signed in to change notification settings - Fork 679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal to Add "Cookie Bomb" Attack Vector to ASVS #1739
Comments
Link points to 8 year old situation. Have you tried it in practice yourself? If you write 2 cookies with max length (4k), you alread hit "431 - Request Header Fields Too Large" error. https://datatracker.ietf.org/doc/html/rfc6585#section-5 RFC does not say what the limit is, I have not seen it more than 8kB long time. Based on my experience it's not valid anymore. |
Browsers have those limit as well, different browsers a bit different, but you can not write endless amount of cookies to the browser. Based on my knowledge, for an application it is impossible to control it. You can only cleanup everything with:
|
The users can delete the cookies and then it would fix their issue. But the most recent write-ups that I found in HackerOne are these two: I've opened this issue to ensure comprehensiveness within the framework. |
So this is not large number of large cookies - it is exactly hitting this 8kB limit for the browser and then this browser will get always given error, which I call "Client-Based Denial of Service" (you need to infect each client separately). |
In this situation, often an application will not get the request, as web server serves the error (depends on solution). As a defense on my training I recommend to have filters on WAF:
|
While browsers do have a limit on the number and size of cookies they accept for a domain, it's important to understand that the application itself can play a significant role in controlling the cookies it sets. Even before the browser limits come into play, the application can decide not to set a cookie in the first place. The application can also decide on the size of each cookie. |
The attack surface is a lot wider - you can write matching cookie from every subdomain (if you have cookie writing solution there, like "XSS"). One "XSS" in Same-Site scope is enough and you can not defend against it with application itself. |
Configuring the WAF could be a solid solution. It's important to remember that while WAFs provide an essential layer of security, they should not be the sole line of defense. |
And it's not only about cookie length, some web servers also can not handle certain symbols in cookie values (nowadays browsers are getting more restrictive on the topic and you can not write all symbols to cookie value anymore). Example with Apache Tomcat which I reported 9 years ago: https://seclists.org/bugtraq/2014/Sep/51 |
This is just a type of XSS payload, and is fixed via normal XSS defense. |
First: #1739 (comment) Think about ISP giving for your internet connection hostname like Also the vector may come available when user controls some part of the value which will be written to a cookie (by the application). It stays valid even we merge requirement "one application per hostname" (#1299), as for cookies the scope is Site. |
This code is vulnerable to Cookie Bomb but is not vulnerable to XSS
|
I stand corrected, nice Iman!!!
|
Thanks for being open to feedback. |
Sometimes… 😉
|
Conclusion so far: requirement proposal: #1739 (comment) |
Hi folks, I read through the comments above. It seems to me that this would only be possible in two ways:
I am not convinced that 1) should be possible but I would welcome being corrected :) For 2) this is an untrusted/user-controlled input problem and we would need to either create a requirement or adapt an existing requirement along these lines. Do you disagree @ImanSharaf @elarlang @jmanico ? |
XSS allows for "cookie clearing" or "setting new cookies"
|
I can not actually understand what do you mean with that.
This is more input validation question and controllable by application. Even if you fix that, it does not solve to issue here. Let's say we have target site on hostname Cookie security policy is based on Site, which means an attacker can write cookies, mathcing to Example possibilities: From directly
From
If |
I just mean that an attacker can some how write directly into the cookie value/cookies collection in the victim's browser. As I said, this should conceptually not be possible although I guess you could do it through XSS but then the fix is to not have XSS.
I agree.
I don't agree. This seems to be the only situation that is actually directly a problem here.
Fix by preventing XSS (which they should already be doing)
Fix with input validation as we said above.
This seems really niche because it means the attacker has control of an app subdomain, no and also this:
Again, fix by preventing XSS
Pretty sure we require HSTS and also this which should hopefully cover this situation? So, in summary, I still think we need an input validation or sanitization requirement to address the indirect part of this issue. |
attack scope is same-site - "fix XSS on all subdomains" is outside of application scope and an application security should not depend on outside environment. Every a bit larger corporation has many subdomains for their main domain. |
So aside from sanitization when taking user input into a cookie, what additional protection/requirement are you advocating here @elarlang ? |
There not much else you can do - in this scenario you can not control the source (like go and fix the XSS). Another option is to use |
So this is kinda my point, as I said in #1739 (comment), we can create an input validation requirement but that is about it. Would you be comfortable for @ImanSharaf to try and draft a requirement? |
No, we can not - HTTP server just responds with 400 or 431 and this request don't even reach to the application. ... also, there is nothing to validate, as the application do not use this information. Just the web server fails to handle the request. |
The input validation is not for after the cookie has been bombed but rather to prevent it from happening. I mentioned this above #1739 (comment)
...
The examples which Iman brought were along this line. |
Aha, ok. I overlooked this part. I agree this should be fixed with input validation in the same application but for me it's covered by basic input validation rules. |
@ImanSharaf, do you think this is covered by existing input validation requirements or do you have a suggestion for an additional requirement? |
Some practice made me rethink some things... I think it makes sense to have separate requirement to address problems:
|
What do we think about the following requirement:
|
I like it, but can you use a different language than "the validation should be applied to the relevant parts of the derived value." I am not 100% sure what that means. |
Excellent
|
Any further comments @elarlang ? |
I propose a bit different direction:
|
@elarlang minor tweaks |
Sorry for the delay, this works for me. |
Created #1865. |
What is a Cookie Bomb?
A cookie bomb is an attack vector where an attacker has the capability of adding a large number of large cookies to a user for a specific domain and its subdomains. The purpose is that when the victim subsequently tries to access resources on the domain or its subdomains, they will always send large HTTP requests due to the excessive cookies. Since many servers and applications have limitations on the size of HTTP requests they can handle, these large requests may be rejected. This can lead to a Denial of Service (DoS) situation for the user, preventing them from accessing any service within that domain and its subdomains.
Why is this relevant?
There are real-world examples of this vulnerability such as the one that was found on Twitter (X), as detailed in this HackerOne report: https://hackerone.com/reports/57356. The vulnerability highlights the potential severity of the issue and showcases how even major platforms can be susceptible.
Proposed Verification Requirement:
Applications should have mechanisms in place to limit the number and size of cookies that can be set for a user.
The text was updated successfully, but these errors were encountered: