This vulnerability, commonly known as Basic Cross-Site Scripting (XSS), occurs when a web application fails to properly sanitize user input containing HTML and JavaScript tags. When untrusted data containing characters like <, >, and & is rendered directly into a webpage, a browser may execute it as active code, not just display it as text.

At its core, this flaw allows attackers to inject malicious scripts into web pages viewed by other users. These scripts execute within the victim's browser context, enabling actions like stealing session cookies, logging keystrokes, defacing websites, or redirecting users to malicious sites. The risk is highest in any part of an application that displays user-provided data without proper validation, such as comment sections, user profiles, or search result pages. Preventing Basic XSS requires a consistent strategy of output encoding or contextual escaping. Instead of trying to filter out 'bad' input, you should proactively encode all user-controlled data before inserting it into HTML. This means converting special characters into their safe HTML entity equivalents (e.g., < for <). Rely on well-tested libraries for your framework to perform this encoding, and never use insecure methods like `innerHTML` or `document.write()` with raw user input.
Impact: Read Application DataExecute Unauthorized Code or Commands
An attacker could insert special characters that are processed client-side in the context of the user's session.
Strategy: Output Encoding
Strategy: Attack Surface Reduction
Effectiveness: Defense in Depth
jspHigh