Fix Insecure Mass Assignment tag_groups #33209
Open
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
discourse/app/controllers/tag_groups_controller.rb
Line 52 in fb7fa29
Operations that allow for mass assignment (setting multiple attributes of an object using a hash), such as
ActiveRecord::Base.new
, should take care not to allow arbitrary parameters to be set by the user. Otherwise, unintended attributes may be set, such as anis_admin
field for aUser
object.Fix the issue need to remove the use of
permit!
on line 112 and ensure that only explicitly permitted parameters are allowed for mass assignment. This can be achieved by directly merging the permitted attributes of thetag_group
parameter into theparams
object. Thepermit
call on line 115 already specifies the allowed attributes, so we can safely rely on it. The updatedtag_groups_params
method will no longer usepermit!
and will explicitly handle thetag_group
parameter in a secure manner.Rails guides: Strong Parameters