dangerous-accessible-attribute

attr_accessible letting a request set a privilege or a foreign key.

Group
Code
Runs
Runs under ur scan: ur scan --rule dangerous-accessible-attribute
Level
warning
Reads
Every file
Fix
None: which attributes a request may set is the application's decision

Why

attr_accessible lists the attributes new, create, and update_attributes take from a hash, so a controller that passes params[:user] lets a request set every one of them. Listing admin or role lets a user grant themselves a privilege, banned lets them lift a ban, and a foreign key such as account_id lets them move a record into another account. Leave such attributes out of attr_accessible and set them in code that checks who may, or list them only for a role with as:.

The fix, as Ur suggests it: set the attribute in code that checks who may, not through attr_accessible.

For agents

List in attr_accessible only attributes any user may set, never privileges or foreign keys.

Example

app/models/user.rb
class User < ActiveRecord::Base
  attr_accessible :name, :email, :admin
end
What Ur prints
$ ur scan --rule dangerous-accessible-attribute
warning[dangerous-accessible-attribute]: `attr_accessible` lets a request set `:admin`, which grants a privilege
  --> ./app/models/user.rb:2:3 `attr_accessible :name, :email, :admin`
  = hint: set the attribute in code that checks who may, not through `attr_accessible`
  = see: Ruby on Rails Security Guide, 6.1 Mass Assignment, Rails Guides (2025-10-01), https://guides.rubyonrails.org/v3.2/security.html#mass-assignment
scanned 1 file (no framework recognized)
  dangerous-accessible-attribute: 1 high, 0 medium
1 finding and 0 of medium confidence

Try it in the playground →

Source

Ruby on Rails Security Guide, 6.1 Mass Assignment, Rails Guides (2025-10-01).