Re:How I bypassed Cloudflare's SQL Injection filter
by gskourou on Friday September 18, 2020 @04:47PM
(#24521745)
I have also seen backend application which strip out certain "bad" tags (i.e. <script>).
I remember being able to perform an XSS attack by sending a payload that looked like:
<sc<script>ript>alert(/XSS/)</sc<script>ript>
This passed the WAF inspection, but then got trimmed by the backend application and this is what was left:
<script>alert(/XSS/)</script>
written in the page source.
Maybe I'll write about that case too if I find where I put the attack evidence. You can anyway see that bad validation by the actual application programmers can disable the WAF's capabilities.
Re:How I bypassed Cloudflare's SQL Injection filter
by colejohnson66 on Friday September 18, 2020 @06:11PM
(#24522377)
Isn’t the correct solution to replace '<' and '>' with '<' and '>'?
Re:How I bypassed Cloudflare's SQL Injection filter
by yyyk on Saturday September 19, 2020 @02:45PM
(#24529594)
The correct solution is to apply Content-Security-Policy plus character escaping as needed.
Re:How I bypassed Cloudflare's SQL Injection filter
by krapp on Friday September 18, 2020 @06:14PM
(#24522397)
Yeah, escaping entities when rendering, using prepared statements in the database. It's not rocket science.
Re:How I bypassed Cloudflare's SQL Injection filter
by tannhaeuser on Saturday September 19, 2020 @02:33AM
(#24525623)
Or, you know, using ordinary SGML validation which has the capability to block disallowed elements since 1986.
If the WAF ships with too strict of a blacklist, legit input gets block (All the people named "O'Brian" that can't use a web app...) If an attacker can make an attack look close enough to pass the blacklist, they win. In this example, the attacker had to remove whitespace, remove a math operation sign (=), and send english letters with a few special characters that could be in normal text (quote, forward slash, asterisk).
WAFs will never catch everything, and if they are advertised as such, that is snake oil. But WAFs can help by providing a ready made blacklist that can supplement input validation inside the app, which does have context about what valid input should look like.