general-injection-ruby-v2
3 rules · Keryn Software Licence · rules 0.8.0 · all packs
How to read a rule
- Severity
- How bad the finding is if it is real:
errorfails a default gate,warningandinfodo not. - Confidence
- P0 exploitable as written; P1 dangerous in context; P2 a heuristic or a posture check: confirm by reading the code.
- False-positive risk
- low: an exact API or flag, so hits are almost always real; medium: the pattern is legitimate in many programs, so check each hit; high: it finds a lead to confirm, so expect benign hits.
- Edge
- The relationship the finding sits on. reaches: content or traffic gets to a thing; calls: one thing invokes another; reads: one thing reads from another; writes: one thing writes to another; sends: data leaves for another party; grants: authority is given or left unchecked; depends_on: something relies on a component it does not verify; trusts: one party believes another without evidence. The boundary it crosses, when there is one: user->prompt (untrusted input reaching a prompt); model->code (model output reaching code, a shell, a query or a page); secret->outside (a secret leaving the trusted side); supply-chain (code, models or prompts pulled in from outside).
- Taxonomy chips
- References for readers who work in OWASP LLM 2025, OWASP Agentic, CWE or NIST AI RMF. They say where a rule belongs, not that a framework is satisfied.
keryn.general.ruby.sql-injection-request-multiline-literal
Section titled “keryn.general.ruby.sql-injection-request-multiline-literal”error ruby ruby, rails
A SQL string literal that spans several lines interpolates a request value (params, cookies, request headers) and is passed to an ActiveRecord query method or a raw connection call (where, joins, find_by_sql, execute, select_rows, Arel.sql, …). The finding sits on the line of the interpolation. The value can change the query. Use ? placeholders or hash conditions.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Move the value out of the SQL text: where(“age > ?”, limit), sanitize_sql_array([“… ?”, value]), or quote identifiers with connection.quote_column_name / quote_table_name after checking them against an allowlist.
References: https://guides.rubyonrails.org/security.html#sql-injection · https://api.rubyonrails.org/classes/ActiveRecord/Sanitization/ClassMethods.html
keryn.general.ruby.sql-interpolation-multiline-literal
Section titled “keryn.general.ruby.sql-interpolation-multiline-literal”warning ruby ruby, rails
A SQL string literal that spans several lines interpolates a value and is passed to an ActiveRecord query method or a raw connection call (where, joins, find_by_sql, execute, select_rows, Arel.sql, …). The finding sits on the line of the interpolation. If the value is attacker-controlled the query changes. Use ? placeholders or hash conditions; interpolate only constants and allowlisted identifiers.
Confidence P2: a heuristic or a posture check: confirm by reading the code. False-positive risk high: it finds a lead to confirm, so expect benign hits.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Move the value out of the SQL text: where(“age > ?”, limit), sanitize_sql_array([“… ?”, value]), or quote identifiers with connection.quote_column_name / quote_table_name after checking them against an allowlist.
References: https://guides.rubyonrails.org/security.html#sql-injection · https://api.rubyonrails.org/classes/ActiveRecord/Sanitization/ClassMethods.html
keryn.general.ruby.render-instance-variable-from-request
Section titled “keryn.general.ruby.render-instance-variable-from-request”warning ruby ruby, rails
A controller renders a template, action or file named by an instance variable that another method of the same controller (typically a before_action) assigns from params. A visitor then chooses which template or file is rendered, which can expose other views or, on older Rails, files outside the view path. Map the request value through an allowlist before rendering.
Confidence P2: a heuristic or a posture check: confirm by reading the code. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another.
Fix: Keep a fixed map of allowed templates (PAGES = {“about” => “pages/about”}) and render PAGES.fetch(params[:page]) or head :not_found; never pass the request value itself to render.
References: https://guides.rubyonrails.org/layouts_and_rendering.html#using-render · https://guides.rubyonrails.org/security.html#file-uploads