WAF Bypass
Uppercase and Lowercase
Suppose the WAF filters union
using str_replace()
:
This filter only filters lowercase union
, so we can use things like UNION
or UNion
.
Keywords in MySQL are case-insensitive.
Database names, table names are case-sensitive.
Column names are case-insensitive. This is really weird.
Repeated String
Suppose the developer uses $sql = str_replace("union", "" , $sql);
and uppercase/lowercase is properly handled. We can still bypass this filter using unionunion
. Note that str_replace()
only removes union
once, so unionunion
becomes union
.
Doulbe URL Encoding
If the WAF only calls urldecode()
once, we can URL encode our payload twice to bypass the filter.
and/or
Suppose the WAF filters and
and or
:
The following payloads will be filtered:
We can bypass this filter using the following payload:
union
Suppose the WAF filters and
, or
, and union
:
The following payloads will be filtered:
We can bypass this filter using the following payload:
The ||
symbol expands the scope of select
, which has similar effect as union select
.
where
Suppose the WAF filters and
, or
, union
, and where
:
The following payloads will be filtered:
We can bypass this filter using the following payload:
Here limit 1,1
has the same functionality as where
. limit 1,1
means start from index 1 and only select 1 entry.
limit
Suppose the WAF filters and
, or
, union
, where
and limit
:
The following payload will be filtered:
We can bypass this filter using the following payload:
group by
Suppose the WAF filters and
, or
, union
, where
, limit
and group by
:
The following payload will be filtered:
We can bypass this filter using the following payload:
select and single quote
Suppose the WAF filters and
, or
, union
, where
, limit
, group by
, select
and single quote:
The following payload will be filtered:
We can bypass this filter using the following payload:
hex, unhex and substr
Suppose the WAF filters and
, or
, union
, where
, limit
, group by
, select
, single quote, hex
, unhex
, and substr
:
The following payload will be filtered:
We can bypass this filter using the following payload:
whitespace
Suppose the WAF filters and
, or
, union
, where
, limit
, group by
, select
, single quote, hex
, unhex
, substr
, and space:
The following payload will be filtered:
We can bypass this filter using the following payload:
Here /**/
is an empty comment, which is equivalent to a whitespace.
equal sign
Suppose the WAF filters and
, or
, union
, where
, limit
, group by
, select
, single quote, hex
, unhex
, substr
, space, and =
:
The following payload will be filtered:
We can bypass this filter using the following payload:
Here like
matches more results than =
, but we can use it just like =
anyway.
Last updated