Description
A reflected cross-site scripting vulnerability exists where user-provided input is written directly to an HTTP response without proper sanitization.
Location
Issue
User input (from an HTTP request) is directly incorporated into the response without proper sanitization or escaping, allowing for a cross-site scripting attack. This is commonly known as reflected XSS.
Recommendation
To fix this issue:
- Implement proper HTML escaping before writing user input to responses
- Use a library like escape-html or DOMPurify to sanitize user-provided values
- Consider implementing Content Security Policy (CSP) headers as an additional defense layer
Example Fix
Replace:
With:
References
Description
A reflected cross-site scripting vulnerability exists where user-provided input is written directly to an HTTP response without proper sanitization.
Location
Issue
User input (from an HTTP request) is directly incorporated into the response without proper sanitization or escaping, allowing for a cross-site scripting attack. This is commonly known as reflected XSS.
Recommendation
To fix this issue:
Example Fix
Replace:
With:
References