Insecure Use of Language/Framework API
This category covers the following Ruby/Rails APIs:
Using APIs securely
About insecure use of language/framework APIs
Fixing Insecure Use of Object#send
The following methods are dangerous if used incorrectly:
send
try
__send__
public_send
Option A: Using Object#send
securely
Go through the issues that GuardRails identified in the PR/MR
An example of an insecure usage of
send
is shown belowmethod = params[:method]
@result = User.send(method.to_sym)Modify the code like shown below:
args = params["args"] || []
@result = User.send(:method, *args)Ship it 🚢 and relax 🌴
Fixing Insecure Use of Symbols
The following methods can cause extensive memory consumption that lead to Denial of Service.
to_sym
literal_to_sym
intern
symbolize_keys
symbolize_keys!
Option A: Using Symbols Securely
Go through the issues that GuardRails identified in the PR/MR
An example of an insecure usage of
symbols
is shown belowsymbolized = params[:value].to_sym
allowlist the expected symbols like shown below:
valid_values = ["valid", "values", "here"]
if valid_values.include? params[:value]
symbolized = params[:value].to_sym
endShip it 🚢 and relax 🌴