Why it matters
ERB runs Ruby, so the caller can execute code on this server.
How to fix it
Keep template text in files on the server and pass the request value as a local the template renders.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
class MailPreviewController < ApplicationController
def show
render inline: params[:body]
end
endclass MailPreviewController < ApplicationController
def show
render :welcome, locals: { body: params[:body] }
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
- Unsafe reflection from request input (Ruby)
RubySeverity: High
trustivan-ruby-taint-unsafe-reflection - Regex injection from request input (Ruby)
RubySeverity: Medium
trustivan-ruby-taint-regex-injection - Code injection from request input (Ruby)
RubySeverity: High
trustivan-ruby-taint-code-injection - LDAP injection from request input (Ruby)
RubySeverity: High
trustivan-ruby-taint-ldap-injection - Open redirect from request input (Ruby)
RubySeverity: Medium
trustivan-ruby-taint-open-redirect - XPath injection from request input (Ruby)
RubySeverity: High
trustivan-ruby-taint-xpath-injection
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