Skip to content

    Type a page, a command such as keryn scan, or a rule id.

    general-injection-ruby-text-v1

    View as Markdown

    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: 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

    Section titled “keryn.general.ruby.sql-heredoc-interpolation”

    warning generic ruby, rails

    A SQL heredoc (<<~SQL / <<-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 #{…}.

    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; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-89 LLM05

    Fix: Replace each #{…} 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://api.rubyonrails.org/classes/ActiveRecord/Sanitization/ClassMethods.html

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

    Section titled “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 => 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 one thing reads from another.

    CWE-73 LLM05

    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/Process.html#method-c-spawn

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

    Section titled “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 <%== %>), 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 <%= %> (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 one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-79 LLM05

    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/security.html#cross-site-scripting-xss