missing-csrf-protection
A controller that accepts forged requests.
- Group
- Code
- Runs
- Runs under ur scan:
ur scan --rule missing-csrf-protection - Level
- warning
- Reads
- Every file
- Fix
- None: the safe form depends on what the value is meant to be
Why
A controller of ActionController::Base does not call protect_from_forgery, and the application does not load the defaults that turn it on, so another site can make a signed-in user's browser send it requests that change data. Call protect_from_forgery with: :exception in the base controller, or load_defaults 5.2 or later.
The fix, as Ur suggests it: call protect_from_forgery.
For agents
Protect every controller from forged requests with protect_from_forgery or the framework's defaults.
Example
app/controllers/application_controller.rbclass ApplicationController < ActionController::Base
before_action :authenticate
end
$ ur scan --rule missing-csrf-protection
warning[missing-csrf-protection]: `ApplicationController` does not protect its actions from forged requests, and no defaults do
--> ./app/controllers/application_controller.rb:1:1-3 module's top level
= hint: call protect_from_forgery
= see: Securing Rails Applications, 3.1 CSRF Countermeasures, Rails Guides (2025-10-01), https://guides.rubyonrails.org/security.html#csrf-countermeasures
scanned 1 file (no framework recognized)
missing-csrf-protection: 1 high, 0 medium
1 finding and 0 of medium confidence
Source
Securing Rails Applications, 3.1 CSRF Countermeasures, Rails Guides (2025-10-01).