# general-injection-ruby-text-v1

> general-injection-ruby-text-v1: 3 Keryn rules for generic (3 warning).

Source: https://keryn.dev/rules/general-injection-ruby-text-v1/

3 rules · Keryn Software Licence · rules 0.8.0 · [all packs](https://keryn.dev/rules/)

**How to read a rule**

- **Severity**: How bad the finding is if it is real: `error` fails a default gate, `warning` and `info` do 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-heredoc-interpolation

`warning` generic ruby, rails

A SQL heredoc (&lt;&lt;\~SQL / &lt;&lt;-SQL) interpolates a value that is not a record id, a quoted table or column name, or a number conversion. The heredoc is passed to the database as SQL text, so a value that reaches it from a request or a record breaks out of the statement (SQL injection). Use bind parameters (where(sql, id: value), sanitize\_sql\_array) instead of #&#123;...&#125;.

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](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another; it crosses the [`model->code`](https://keryn.dev/docs/edges/trust-boundaries/#model-to-code) boundary (model output reaching code, a shell, a query or a page).

[CWE-89](https://keryn.dev/taxonomies/cwe/#cwe-89-sql-injection) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling)

**Fix:** Replace each #&#123;...&#125; in the heredoc with a placeholder (? or :name) and pass the values as bind parameters; quote identifiers with connection.quote\_table\_name / quote\_column\_name when they cannot be fixed.

**References:** [https://guides.rubyonrails.org/security.html#sql-injection](https://guides.rubyonrails.org/security.html#sql-injection) · [https://api.rubyonrails.org/classes/ActiveRecord/Sanitization/ClassMethods.html](https://api.rubyonrails.org/classes/ActiveRecord/Sanitization/ClassMethods.html)

## keryn.general.ruby.process-stdin-from-request

`warning` generic ruby

A child process reads its standard input from a file whose name comes from the request (:in =&gt; params[...]). The visitor chooses which file on the server the command reads, including credentials and keys. Map the request value to a fixed allowlist of files, or pass the content instead of a path.

Confidence **P1**: dangerous in context. False-positive risk **low**: an exact API or flag, so hits are almost always real.

Edge inspected: [reads](https://keryn.dev/docs/edges/edge-kinds/#reads) one thing reads from another.

[CWE-73](https://keryn.dev/taxonomies/cwe/#cwe-73-external-control-of-file-name-or-path) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling)

**Fix:** Resolve the request value through a fixed map of allowed files (ALLOWED.fetch(params[:name])) or read the uploaded content and pass it with stdin\_data:.

**References:** [https://docs.ruby-lang.org/en/master/Open3.html](https://docs.ruby-lang.org/en/master/Open3.html) · [https://docs.ruby-lang.org/en/master/Process.html#method-c-spawn](https://docs.ruby-lang.org/en/master/Process.html#method-c-spawn)

## keryn.general.ruby.render-inline-unescaped-local

`warning` generic ruby, rails, erb

render inline: compiles an ERB template that prints a local without escaping (html\_safe, raw or &lt;%== %&gt;), and that local is a request value passed through locals:. The visitor's value is written into the page as markup (cross-site scripting). Print the local with &lt;%= %&gt; (escaped), or render a template file.

Confidence **P1**: dangerous in context. False-positive risk **low**: an exact API or flag, so hits are almost always real.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another; it crosses the [`model->code`](https://keryn.dev/docs/edges/trust-boundaries/#model-to-code) boundary (model output reaching code, a shell, a query or a page).

[CWE-79](https://keryn.dev/taxonomies/cwe/#cwe-79-cross-site-scripting) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling)

**Fix:** Remove html\_safe / raw from the inline template (or sanitize with an explicit tag list), or move the markup to a view file that escapes its locals.

**References:** [https://guides.rubyonrails.org/layouts_and_rendering.html#using-render-with-inline](https://guides.rubyonrails.org/layouts_and_rendering.html#using-render-with-inline) · [https://guides.rubyonrails.org/security.html#cross-site-scripting-xss](https://guides.rubyonrails.org/security.html#cross-site-scripting-xss)
