Piercing the Cloud Armor – The 8KB Bypass in Google Cloud Platform WAF
kloudle.com
kloudle.com
Your application has to be made secure, the WAF cannot do it for you.
At best a third party managed WAF provides speed for sticking plaster to be put over a newly discovered vulnerability, but as all WAFs can essentially be thought of as advanced string parsing without the context of what your app thinks of as good or bad, then there will always be some false negatives that affect your app.
Security engineering cannot be purchased as an afterthought, it needs to be something your engineers practise as commonly as observability and testing.
The WAF took away at least 99% of our random nighttime pages from the bad payloads. Best investment we made for oncall quality of life.
People say "security in depths", but WAFs add nothing that don't 100% _have_ to be mitigated down the stack - this 8K limit is just another part of the joke.
None of them defend against everything, and there is an important nugget in your post: “defense in depth.” You should also filter requests that make it through the WAF. But, getting rid of even 90% of bogus requests before they hit your app servers seems worthwhile.
For every defense in depth, there's an org that's put up a WAF rule in front of an unpatched application and called it good, only yo be owned days later. False sense of security is the thing to stress here, because there is no depth.
Don’t get me wrong, serverless is pretty amazing until you get to a certain scale. The cloud really has that going for it.
Most site on the internet are either run by a tiny team with no dedicated security expert or no tech team at all (someone asked a friend/freelancer to put up a Wordpress site). They aren’t applying security patches and subscribing to the developer mailing lists. A WAF service (like CloudFlare) ensures that older, unpatched, infrastructure is protected. Yes, they should be patching their deployment, but try asking a small business to pay for their web guy to spend a few fours a month ensuring everything is secure. Not going to happen.
From my perspective as someone with a good understanding of web security. I run a WAF service on my sites so that if there is a zero day on part of my stack We are protected immediately before we have time to patch the component, which I will do. That is invaluable to me and my business.
Finally developers do make mistakes and accidentally introduce vulnerabilities. A WAF helps to ensure against that, although you should still be auditing your code.
It ensures that they're protected against a trivial and fairly outdated set of threats. You might say that's better than nothing, but questionable protection leading to a sense of security is more dangerous than having nothing and knowing it (also, false positives).
> We are protected immediately
Look at the recent log4j vulnerabilities. Hosted WAFs didn't "immediately" address the issue (though they were fairly quick). However, to the best of my knowledge they were unable to fully mitigate the threat. For example, if you look at CloudFlare's wording on rule 2c5413e155db4365befe0df160ba67d7:
> In addition to the above rules we have also released a fourth rule that will protect against a much wider range of attacks at the cost of a higher false positive rate. For that reason we have made it available but not set it to BLOCK by default
It's clear that, by default, their updated rules didn't fully mitigate the issue. Also, it IS NOT clear, whether the extra rule did fully mitigate the issue.
Fundamentally, having a WAF in the face of log4j did nothing for you. You still have to patch everything, you still had to try and figure out if you'd been compromised, and you still had to update/alert your clients/customers.
Isn’t a WAF getting access to pre-public intelligence and updating their rules accordingly? I was under the impression that major vendors like Cloudflare and Google were able to block zero-days before the public announcements.
Rules for remotely exploitable vulnerabilities like log4j are typically crafted within hours of a CVE being released, and deployed as quickly as possible to minimize false positives. I'm not sure I'd consider such threats "outdated".
> However, to the best of my knowledge they were unable to fully mitigate the threat ... Fundamentally, having a WAF in the face of log4j did nothing for you.
If you're only able to mitigate 9X% of a rapidly evolving zero-day and not 100%, should you not use a WAF at all? Security is about reducing risk, and raising the cost for attackers.
Cloudflare tracked and responded to active exploitation attempts[1] in the wild with updated rules, while imploring customers to patch, e.g., from our second CVE (CVE-2021-45046) post[2] discussing additional rules we deployed:
"This vulnerability is actively being exploited and anyone using Log4J should update to version 2.16.0 as soon as possible, even if you have previously updated to 2.15.0. The latest version can be found on the Log4J download page."
> You still have to patch everything, you still had to try and figure out if you'd been compromised, and you still had to update/alert your clients/customers.
Yes, of course. Nobody is arguing otherwise. Such is the nature of these massive vulnerabilities that pop up every few years.
[1] - https://blog.cloudflare.com/exploitation-of-cve-2021-44228-b...
[2] - https://blog.cloudflare.com/protection-against-cve-2021-4504...
My take is now to configure WAF at a generic level with minimal impact on application functionalities. And yes, the value of WAF’s is overrated. Cause with proper development guidelines like using ORM instead of writing plain SQL queries, you can throw away half of the default policies which revolve around SQL injections.
For large organizations, having a WAF does add some value. With security it’s all about adding layers of protection wherever possible.
For example if you discover a vulnerability in your code that is being exploited you can push a WAF rule to block the easiest ways to trigger it. Or if you use a common library like log4j you can rely on rulesets that are updated for you. Likely before your smaller team has time to react.
In that time you should be rushing to fix your application or update dependencies and deploy the new version.
You deploy a WAF as part of a defense in depth strategy, with one of the best use-cases being situations where you have legacy web systems that nobody is maintaining. Additionally, you can get TLS upscaling, easy HTTP rewrite capabilities, DDoS protection, and other granular controls with some SaaS offerings. So while it's true that a WAF won't stop a determined attacker, there are certainly benefits to operating them, particularly in large enterprise environments.So make sure you bake in security through your code, and then when you are done, you can afford to make a decision about whether you need to put the thinnest possible veil over that.
See: https://reqbin.com/Article/ContentLength
"If the value of the Content-Length header is zero, or if neither the Transfer-Encoding header nor the Content-Length header is specified, then the message has no body. "
Whether that’s a good trade-off I’m not sure. Folks know this is a thing so if someone really wants to get past it they will. But it’s proven effective enough at neutralising a lot of bots and other annoying traffic whenever I’ve resorted to using it.
AWS has the same bypass (documented). The WAF provided by cloud providers is more to protect their infrastructure from noise than clients. Unfortunately this type of restrictions are never evaluated. You can really tell if a WAF provider is serious when reviewing the whitelisting. (i.e. not just a on/off).
As for query parameters in GET requests, I'm not entirely sure about Cloud Armor's limits there. I'll check and get back to you.
Pad your POST query by 8k and you are through!