HTML injection with security filters that can be bypassed
This lab demonstrates HTML injection vulnerabilities where basic security filters are implemented but can be bypassed using various techniques. The application filters dangerous HTML tags and attributes but doesn't prevent all attack vectors.
Objective: Bypass security filters to achieve HTML injection and potentially XSS.
// Vulnerable: Basic filters that can be bypassed
function process_html_input_with_filters($input) {
$dangerous_tags = ['script', 'iframe', 'object', 'embed', 'form'];
$dangerous_attributes = ['onload', 'onerror', 'onclick', 'onmouseover'];
$dangerous_protocols = ['javascript:', 'data:', 'vbscript:'];
// Basic filter check (can be bypassed)
$is_dangerous = false;
foreach ($dangerous_tags as $tag) {
if (stripos($input, '<' . $tag) !== false) {
$is_dangerous = true;
break;
}
}
// Still vulnerable to bypass techniques
if (!$is_dangerous) {
return $input;
}
}
The following are filtered:
These tags should work:
<h1>Hello</h1> - Heading<p>Paragraph</p> - Paragraph<div>Container</div> - Container<span>Inline</span> - InlineUse these payloads to bypass the security filters: