User Interface (UI) redress vulnerability (clickjacking) detected.
- Rule ID: javascript_express_ui_redress
- Languages: javascript
- Source: ui_redress.yml
Description
Using unsanitized user input to set X-Frame-Options or Content-Security-Policy HTTP headers puts your application at risk for UI redress attacks (clickjacking).
Remediations
✅ Prefer the most secure values when setting these headers
res.set('X-Frame-Options', 'DENY')
res.set('Content-Security-Policy', "frame-ancestors 'none'")
✅ Avoid using user input directly to set the headers, or use a safelist to guard against clickjacking
if (req.query.options === 'same') {
res.set('X-Frame-Options', 'SAME')
}
// safelist
if (['deny', 'sameorigin'].includes(req.query.options.toLowerCase)) {
res.set('X-Frame-Options', req.query.options)
}
Resources
Associated CWE
OWASP Top 10
Configuration
To skip this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --skip-rule=javascript_express_ui_redress
To run only this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --only-rule=javascript_express_ui_redress
Ready to take the next step? Learn more about Bearer Cloud.