CSC/ECE 517 Fall 2017/E1784 Fix mass assignments reported by Brakeman.rb: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 29: Line 29:


[[File:Ddhghghg.png]]
[[File:Ddhghghg.png]]
==== params.permit!  ====
[[File:1fdgdfgdfg.png]]


==== Parameters come from other objects  ====
==== Parameters come from other objects  ====
Line 42: Line 39:


[[File:Sdfsvvv.png]]
[[File:Sdfsvvv.png]]
==== params.permit!  ====
[[File:1fdgdfgdfg.png]]


== Reference ==
== Reference ==
#https://apidock.com/rails/ActiveModel/MassAssignmentSecurity/ClassMethods/attr_accessible
#https://apidock.com/rails/ActiveModel/MassAssignmentSecurity/ClassMethods/attr_accessible

Revision as of 23:47, 25 October 2017

Expertiza Background

Expertiza is a web application where students can submit and peer-review learning objects (articles, code, web sites, etc). It is used in select courses at NC State and by professors at several other colleges and universities.

Project Description

With the help of mass assignment, when we create or update certain object, we do not need to write an assignment statement for each attribute. But mass assignment could cause security vulnerabilities. Hackers could add other parameters to do some bad things. Rails 4 introduces strong parameters, which is a new approach to protect mass assignment. So our group needs to resolve all these "Unprotected mass assignment" issues according to Brakeman report.

Implementation

Problem 1: Potentially dangerous attribute available for mass assignment

Previsouly, only two attributes :parent_id, :node_object_id are protected. So we removed the two attributes so that all attributes in all models will be mass assignment protected.

Problem 2: Mass assignment is not restricted using attr_accessible

If there was no protection at all in the model file. We just added "attr_acessible".

Problem 3: Unprotected mass assignment

We modified the code in an unobtrusive way, i.e. processing the mass assignment parameters with a function without changing them directly.

Parameters come from requests

Fix unprotected mass assignment in update


Fix unprotected mass assignment in new

Parameters come from other objects

Fix unprotected mass assignment in create


Fix unprotected mass assignment in new

params.permit!

Reference

  1. https://apidock.com/rails/ActiveModel/MassAssignmentSecurity/ClassMethods/attr_accessible