HTML injection attacks through file upload functionality
This lab demonstrates HTML injection vulnerabilities that can be exploited through file upload functionality. Attackers can upload files containing malicious HTML content or reference uploaded files that get processed and rendered by the browser.
Objective: Use file upload functionality to achieve HTML injection and potentially XSS.
// Vulnerable: Direct output without validation
function process_uploaded_html($input) {
if (empty($input)) {
return "No input provided.";
}
// Vulnerable: Direct output without encoding
return $input;
}
No files uploaded yet.
malicious.html - Upload HTML file<h1>Hello</h1> - Basic HTML<script>alert(1)</script> - JavaScript<img src="x" onerror="alert(1)"> - XSSUpload these files to test HTML injection vulnerabilities:
This page has been compromised.