rails-views-helpers-v1
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.rails.views.link-to-href-from-request
Section titled “keryn.rails.views.link-to-href-from-request”warning generic ruby, rails, erb, haml, slim
link_to takes its href from a request value or from a record’s URL attribute. Rails escapes the attribute but does not check the scheme, so a javascript: or data: URL runs script when the visitor clicks the link. Validate the scheme (http/https only) before linking, or link to a route helper.
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).
Fix: Parse the URL (URI.parse) and accept only http and https before passing it to link_to, or build the link with a route helper. Escaping with h does not help: javascript: needs no special characters.
References: https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to · https://guides.rubyonrails.org/security.html#cross-site-scripting-xss
keryn.rails.views.content-tag-unescaped-name-or-attribute
Section titled “keryn.rails.views.content-tag-unescaped-name-or-attribute”warning generic ruby, rails, erb, haml, slim
content_tag builds markup whose tag name or attribute name comes from a request value or a record, or switches attribute escaping off (escape = false) around a dynamic value. Tag and attribute names are never escaped, so the value can add attributes such as onmouseover or break out of the tag. Use fixed tag and attribute names and keep escaping on.
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).
Fix: Pass a literal tag name and literal attribute keys (content_tag(:div, text, class: value)) and leave the escape argument at its default (true).
References: https://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-content_tag
keryn.rails.views.file-from-request-in-view
Section titled “keryn.rails.views.file-from-request-in-view”warning generic ruby, rails, erb, haml, slim
A view opens, reads or renders a file whose name comes from a request value (File.open, File.read, IO.read, render file:). A visitor chooses the path and can read any file the application can, including credentials. Look the file up by an allowlisted key in the controller instead.
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: reads one thing reads from another.
Fix: Move file access out of the view, map the request value through a fixed allowlist (DOCS.fetch(params[:doc])), and never pass a request value to render file:.
References: https://guides.rubyonrails.org/security.html#file-uploads · https://guides.rubyonrails.org/layouts_and_rendering.html#rendering-an-arbitrary-file