Lab: Basic Filter Bypass
This lab demonstrates a reflected XSS vulnerability with a basic filter that attempts to block the word "script".
str_replace('script', '', $_GET['lname'])
Objective: Bypass the filter and execute a JavaScript alert.
if(isset($_GET["fname"]) && isset($_GET["lname"])){
$re = str_replace('script', '', $_GET['lname']);
echo $re;
}
script - try case variationsThis lab demonstrates why simple string replacement is an ineffective XSS prevention technique. Modern applications should use context-aware output encoding and proper sanitization libraries.
Real-world recommendation: Use HTMLPurifier or similar libraries that understand context and can properly neutralize XSS vectors.