document.write() with User Input
Using document.write() to output user-controlled content directly into the HTML document stream.
Preview example – JAVASCRIPT
// User input from URL or form
const userName = new URLSearchParams(location.search).get('name');
// Vulnerable: document.write with user input
if (userName) {
document.write('<h1>Welcome ' + userName + '!</h1>');
// Attacker can use: ?name=<script>alert('XSS')</script>
}