This vulnerability occurs when an application fails to properly sanitize user-supplied input before displaying it within an error message web page. If special characters used in web scripts are not neutralized, an attacker can inject malicious code that executes in a user's browser.
Many web applications use custom error pages, such as 403 Forbidden or 404 Not Found pages, which can unintentionally include unsanitized input from a user's request. When an attacker can trigger an error and their input—containing JavaScript or HTML—is reflected directly into the error page's response, it creates a classic Cross-Site Scripting (XSS) opportunity. To prevent this, developers must treat all data displayed in error pages as untrusted. This means rigorously validating and encoding or escaping any user-controlled input before it is rendered, even in error-handling contexts, to ensure script code is displayed as harmless text rather than executed by the browser.
Impact: Read Application DataExecute Unauthorized Code or Commands
Strategy: Output Encoding
Strategy: Attack Surface Reduction
Effectiveness: Defense in Depth