CWE-79
Cross-site scripting (XSS)
Keep text from users and other services from becoming executable content in a browser.
What can go wrong
A browser may run untrusted script with the same access as the page where it appears. The script could read data available to that page or perform actions through a signed-in session.
Check your application
Check who controls the value, how the page renders it, and who can view the result. The viewer's permissions affect which data and actions are exposed.
How to fix it
- Display plain text through your framework's normal escaped text rendering.
- Match output encoding to where the value appears. For links from untrusted sources, allow only the URL schemes your feature needs.
- Use a maintained HTML sanitizer where a feature needs to preserve user-provided formatting.