Unsanitized user input in raw HTML strings (XSS)

Description

Applications should not include unsanitized user input in responses. This can allow cross-site scripting (XSS) attacks.

Remediations

❌ Avoid including user input directly in the response:

render html: "<h1>#{params[:title]}</h1>"

✅ Sanitize user input when including it in a response:

render html: "<h1>#{strip_tags(params[:title])}</h1>"

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_rails_render_using_user_input

To run only this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --only-rule=ruby_rails_render_using_user_input