Manual HTML sanitization detected.
- Rule ID: ruby_lang_manual_html_sanitization
- Languages: ruby
- Source: manual_html_sanitization.yml
Description
Sanitizing HTML manually is error prone and can lead to Cross Site Scripting (XSS) vulnerabilities.
Remediations
❌ Avoid manually escaping HTML:
sanitized_user_input = user.Input
.gsub('<', '<')
.gsub('>', '>')
html = "<strong>#{sanitized_user_input}</strong>"
✅ Use a HTML sanitization library:
html = sanitize("<strong>#{user.Input}</strong>")
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=ruby_lang_manual_html_sanitization
To run only this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --only-rule=ruby_lang_manual_html_sanitization
Ready to take the next step? Learn more about Bearer Cloud.