cross-site-scripting

Untrusted input printed as HTML without escaping.

Group
Code
Runs
Runs under ur scan: ur scan --rule cross-site-scripting
Level
warning
Reads
Every file
Fix
None: the safe form depends on what the value is meant to be

Why

A value from a request is marked safe with html_safe or raw, or rendered as inline HTML, so whoever sends it can put scripts in the page another user sees. Let the view escape it, or clean it with sanitize.

The fix, as Ur suggests it: let the view escape it.

For agents

Never mark input html_safe or render it as raw HTML; let the view escape it.

Example

app/controllers/search_controller.rb
class SearchController < ApplicationController
  def index
    flash[:notice] = "No results for #{params[:q]}".html_safe
  end
end
What Ur prints
$ ur scan --rule cross-site-scripting
warning[cross-site-scripting]: `params`, a request parameter, reaches `html_safe`
  --> ./app/controllers/search_controller.rb:3:22 method `index`
  = step 1: ./app/controllers/search_controller.rb:3:40 `params`, a request parameter,
  = step 2: ./app/controllers/search_controller.rb:3:22 interpolated into a string
  = hint: let the view escape it
  = see: Securing Rails Applications, 7.3 Cross-Site Scripting (XSS), Rails Guides (2025-10-01), https://guides.rubyonrails.org/security.html#cross-site-scripting-xss
scanned 1 file (no framework recognized)
  cross-site-scripting: 1 high, 0 medium
1 finding and 0 of medium confidence

Try it in the playground →

Source

Securing Rails Applications, 7.3 Cross-Site Scripting (XSS), Rails Guides (2025-10-01).