Lab: Extended Filter Bypass Challenge
This lab demonstrates a reflected XSS vulnerability with an extended filter that blocks 'script', 'img', and 'image' tags in the First Name parameter.
'script''img''image'str_replace(array('script','img','image'), '', $_GET['fname'])
Objective: Bypass all three filters 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','img','image');
$re = str_replace($arr, '', $_GET['fname']);
echo $re;
}
svg, body, iframe, object, embed<scr<script>ipt>onmouseover, onfocus, onloadScRiPt, iMgThis lab demonstrates the fundamental weakness of blacklist-based filtering:
For effective XSS prevention: