Why it matters
The caller controls part of the statement, so they can change what it selects, updates or deletes.
How to fix it
Pass the value as a bind parameter (where("status = ?", value) or where(status: value)) instead of interpolating it into the string.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
class OrdersController < ApplicationController
def index
@orders = Order.where("status = '#{params[:status]}'")
end
endclass OrdersController < ApplicationController
def index
@orders = Order.where(status: params[:status])
end
endWhat TrustIvan reads
Runs on repository scans of Ruby source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- Command injection from request input (Ruby)
RubySeverity: High
trustivan-ruby-taint-command-injection - Path traversal from request input (Ruby)
RubySeverity: High
trustivan-ruby-taint-path-traversal - SSRF from request input (Ruby)
RubySeverity: High
trustivan-ruby-taint-ssrf - XSS from request input (Ruby)
RubySeverity: High
trustivan-ruby-taint-xss - Deserialization from request input (Ruby)
RubySeverity: High
trustivan-ruby-taint-deserialization - Open redirect from request input (Ruby)
RubySeverity: Medium
trustivan-ruby-taint-open-redirect
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation