HP-UX — 1 vulnerability check
noctis ships 1 vulnerability check for HP-UX, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
HP-UX ftpd glob() expansion STAT buffer overflow
| CVE | CVE-2001-0248 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | ftp |
| Detection | script, tcp_open, tcp_send, tcp_close, sleep, match · highest QoD 75 |
| Feed | tests/vulnerabilities/hp-ux/CVE-2001-0248.yaml |
Detects the HP-UX ftpd STAT glob() stack overflow (CVE-2001-0248). After logging in (scan credentials, else anonymous), the test creates a long directory, sends `STAT ~/*` and reports the flaw when the session process dies without a reply while the FTP service still greets a new connection; it then removes the directory. When it cannot log in or create a directory, it falls back to the greeting banner: an HP-UX ftpd revision without a PHNE patch that contains the fix.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Opens a persistent TCP/TLS socket
- Sends
USER {{cred_username}}on the open socket - Sends
PASS {{cred_password}}on the open socket - Parses / computes the next value with a Rhai script
- Opens a persistent TCP/TLS socket
- Sends
USER anonymouson the open socket - Sends
PASS noctis@example.comon 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
- Parses / computes the next value with a Rhai script
- Sends
MKD {{dir_long}}on the open socket - Parses / computes the next value with a Rhai script
- … and 16 more steps — see the feed source below
References:
- https://nvd.nist.gov/vuln/detail/CVE-2001-0248
- http://www.cert.org/advisories/CA-2001-07.html
- http://www.securityfocus.com/bid/2552
- https://lwn.net/2001/0412/a/ftpglob.php3
Feed source — tests/vulnerabilities/hp-ux/CVE-2001-0248.yaml
# HP-UX ftpd glob() expansion STAT buffer overflow — CVE-2001-0248.
#
# HP-UX 10.x / 11.x legacy ftpd runs a STAT argument that starts with '~' through
# glob(), which also expands the other wildcards. Once the home directory holds a
# long directory name, `STAT ~/*` expands past the 512-byte command buffer and
# overflows the stack (COVERT-2001-02, CA-2001-07); a remote user able to create
# a directory gets code execution as the ftpd user. Fixed by PHNE_23947 (10.01 /
# 10.10), PHNE_23948 (10.20), PHNE_23949 (11.00), PHNE_23950 (11.11), PHNE_24394
# (10.24 VVOS) and PHNE_24395 (11.04 VVOS) — HPSBUX0107-162.
#
# Port of OpenVAS `pre2008/hpftp_glob_stat.nasl` (OID 1.3.6.1.4.1.25623.1.0.11372,
# GPL-2.0-only):
#
# 1. Log in on one persistent socket — scan credentials when given, anonymous
# (the NASL's default KB login) when there are none or they are refused.
# 2. Active check (QoD 75), as the NASL: MKD a 505-char directory (a 249-char
# one if refused) in the login directory, then `STAT ~/*`. The overflow
# kills the forked session: no STAT reply, nothing either to a NOOP sent 5 s
# later on the same socket, and a later write fails (broken pipe — a slow
# server keeps accepting writes) — while a fresh connection is still
# greeted with 220 (inetd is up). The NASL counts any empty first reply
# line as vulnerable, even a slow one. Not run at all (nothing written)
# when the banner names an ftpd without this code (vsftpd, ProFTPD,
# Pure-FTPd, Microsoft FTP, FileZilla, Serv-U) or an HP-UX ftpd with a
# fixing PHNE tag, where a dropped session would mean something else.
# 3. Cleanup: whenever an MKD was sent (even if its reply was lost), a fresh
# session logs in again and RMDs both names (550 on a missing one) (the
# NASL sends its RMDs on the dead socket, so they never reach the server
# and the long directory is left behind on a vulnerable host).
# 4. Banner fallback (QoD 70) when the active check could not run (no login,
# or MKD refused). Better than the NASL's banner test, whose regex wants
# "Version 10.x / 11.0" — HP-UX ftpd announces its own revision instead
# ("FTP server (Version 1.1.214.4(PHNE_36129) ...)"), so the NASL safe
# check essentially never fires. Flag the HP-UX ftpd revision series
# 1.x.21x.y (plus the NASL's own pattern) unless the banner carries a PHNE
# patch tag >= PHNE_23947 — every later ftpd patch supersedes the fix.
# HP's separately shipped WU-FTPD 2.6.1 ("Revision 1.002 Version
# wuftpd-2.6.1") is not this ftpd and is not flagged.
#
# Intrusive: writes two empty directories (removed afterwards) and, on a
# vulnerable host, crashes the session process — never the inetd listener.
# Tagged `category: rce` + `intrusive` so it can be excluded.
uid: c7e3e8d8-86f7-4dec-ad39-4ce74195bbd8
name: "HP-UX ftpd glob() expansion STAT buffer overflow (CVE-2001-0248)"
description: |
Detects the HP-UX ftpd STAT glob() stack overflow (CVE-2001-0248). After logging
in (scan credentials, else anonymous), the test creates a long directory, sends
`STAT ~/*` and reports the flaw when the session process dies without a reply
while the FTP service still greets a new connection; it then removes the
directory. When it cannot log in or create a directory, it falls back to the
greeting banner: an HP-UX ftpd revision without a PHNE patch that contains the fix.
cves: [CVE-2001-0248]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.10
tags: [ftp, hp-ux, ftpd, glob, stat, buffer-overflow, memory-corruption, rce, intrusive]
services: [ftp]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2001-0248"
- "http://www.cert.org/advisories/CA-2001-07.html"
- "http://www.securityfocus.com/bid/2552"
- "https://lwn.net/2001/0412/a/ftpglob.php3"
steps:
# ── 1. Login: scan credentials (user + password) or anonymous ────────────
- id: pick-login
action: script
code: |
cred_enabled && is_def_var("cred_username") && is_def_var("cred_password")
store_as: use_cred
- id: open
action: tcp_open
handle: ftp
port: "{{port}}"
read_banner: true
timeout_secs: 10
store_as: ftpo
- id: cred-user
action: tcp_send
condition: "use_cred == true"
handle: ftp
send: "USER {{cred_username}}\r\n"
store_as: cuser
- id: cred-pass
action: tcp_send
condition: "use_cred == true"
handle: ftp
send: "PASS {{cred_password}}\r\n"
store_as: cpass
- id: login-state
action: script
code: |
use_cred && is_def_var("cpass") && type_of(cpass.response) == "string"
&& ereg("(^|\n)230[ -]", cpass.response)
store_as: cred_ok
# Credentials absent or refused (they are request-wide and often meant for
# another service): fall back to anonymous on a fresh connection.
- id: reopen
action: tcp_close
condition: "cred_ok == false && use_cred == true"
handle: ftp
- id: reopen-anon
action: tcp_open
condition: "cred_ok == false && use_cred == true"
handle: ftp
port: "{{port}}"
read_banner: true
timeout_secs: 10
store_as: ftpo2
- id: anon-user
action: tcp_send
condition: "cred_ok == false"
handle: ftp
send: "USER anonymous\r\n"
store_as: auser
- id: anon-pass
action: tcp_send
condition: "cred_ok == false"
handle: ftp
send: "PASS noctis@example.com\r\n"
store_as: apass
- id: logged-in
action: script
code: |
cred_ok || (is_def_var("apass") && type_of(apass.response) == "string"
&& ereg("(^|\n)230[ -]", apass.response))
store_as: logged_in
# Banner triage before writing anything: no MKD / STAT on an ftpd that
# names itself as one without this code, or on an HP-UX ftpd carrying a
# PHNE patch tag that includes the fix.
- id: triage
action: script
code: |
let banner = "";
if is_def_var("ftpo2") && type_of(ftpo2.banner) == "string" { banner = ftpo2.banner; }
else if is_def_var("ftpo") && type_of(ftpo.banner) == "string" { banner = ftpo.banner; }
let unaffected = ereg("(?i)vsftpd|proftpd|pure-ftpd|microsoft ftp|filezilla|serv-u", banner);
let hp_rev = ereg("FTP server \\(Version 1\\.[0-9]+\\.21[0-9]\\.[0-9]+", banner)
|| ereg("FTP server.*[vV]ersion[^0-9]*(10\\.[0-9]+|11\\.0)", banner);
let phne = eregmatch("PHNE_([0-9]+)", banner);
let fixed = phne.len() == 2 && int(phne[1]) >= 23947;
#{ banner: banner, hp_rev: hp_rev, fixed: fixed, skip: unaffected || fixed }
store_as: pre
# Directory names: 505 + 4 ("MKD ") + 2 (CRLF) = 511, 249 + 6 = 255 — the
# NASL's crap(505) / crap(249), prefixed so an operator recognises them.
- id: dir-long
action: script
code: |
"noctisL" + crap(498)
store_as: dir_long
- id: dir-short
action: script
code: |
"noctisS" + crap(242)
store_as: dir_short
# ── 2. Active check: long directory + STAT ~/* ───────────────────────────
- id: mkd-long
action: tcp_send
condition: "logged_in == true && pre.skip == false"
handle: ftp
send: "MKD {{dir_long}}\r\n"
store_as: mkd1
- id: mkd-long-state
action: script
code: |
logged_in && is_def_var("mkd1") && type_of(mkd1.response) == "string"
&& ereg("(^|\n)257 ", mkd1.response)
store_as: mkd1_ok
# The server refused the long name: try a short one, as the NASL does.
- id: mkd-short
action: tcp_send
condition: "logged_in == true && pre.skip == false && mkd1_ok == false"
handle: ftp
send: "MKD {{dir_short}}\r\n"
store_as: mkd2
- id: mkd-state
action: script
code: |
mkd1_ok || (logged_in && is_def_var("mkd2") && type_of(mkd2.response) == "string"
&& ereg("(^|\n)257 ", mkd2.response))
store_as: mkd_ok
- id: stat-glob
action: tcp_send
condition: "mkd_ok == true"
handle: ftp
send: "STAT ~/*\r\n"
store_as: stat
# A slow server's late reply arrives in the socket buffer meanwhile.
- id: settle
action: sleep
condition: "mkd_ok == true"
duration_ms: 5000
- id: noop
action: tcp_send
condition: "mkd_ok == true"
handle: ftp
send: "NOOP\r\n"
store_as: noop
# Dead-socket proof: once the peer process is gone, the first write after its
# FIN draws a reset and the next write fails (sent == false, broken pipe).
- id: settle-2
action: sleep
condition: "mkd_ok == true"
duration_ms: 1000
- id: noop-2
action: tcp_send
condition: "mkd_ok == true"
handle: ftp
send: "NOOP\r\n"
store_as: noop2
- id: close
action: tcp_close
handle: ftp
# ── 3. Cleanup session — also proves the listener is still up ───────────
- id: clean-open
action: tcp_open
condition: "logged_in == true && pre.skip == false"
handle: clean
port: "{{port}}"
read_banner: true
timeout_secs: 10
store_as: alive
- id: clean-cred-user
action: tcp_send
condition: "logged_in == true && pre.skip == false && cred_ok == true"
handle: clean
send: "USER {{cred_username}}\r\n"
store_as: ccuser
- id: clean-cred-pass
action: tcp_send
condition: "logged_in == true && pre.skip == false && cred_ok == true"
handle: clean
send: "PASS {{cred_password}}\r\n"
store_as: ccpass
- id: clean-anon-user
action: tcp_send
condition: "logged_in == true && pre.skip == false && cred_ok == false"
handle: clean
send: "USER anonymous\r\n"
store_as: causer
- id: clean-anon-pass
action: tcp_send
condition: "logged_in == true && pre.skip == false && cred_ok == false"
handle: clean
send: "PASS noctis@example.com\r\n"
store_as: capass
- id: clean-rmd-long
action: tcp_send
condition: "logged_in == true && pre.skip == false"
handle: clean
send: "RMD {{dir_long}}\r\n"
store_as: rmd1
- id: clean-rmd-short
action: tcp_send
condition: "logged_in == true && pre.skip == false"
handle: clean
send: "RMD {{dir_short}}\r\n"
store_as: rmd2
- id: clean-quit
action: tcp_send
condition: "logged_in == true && pre.skip == false"
handle: clean
send: "QUIT\r\n"
store_as: cquit
- id: clean-close
action: tcp_close
handle: clean
# ── 4. Classify ──────────────────────────────────────────────────────────
- id: analyze
action: script
code: |
let banner = pre.banner;
let stat_r = "";
if is_def_var("stat") && type_of(stat.response) == "string" { stat_r = stat.response; }
let noop_r = "";
if is_def_var("noop") && type_of(noop.response) == "string" { noop_r = noop.response; }
let alive_b = "";
if is_def_var("alive") && type_of(alive.banner) == "string" { alive_b = alive.banner; }
let session_closed = (is_def_var("noop") && noop.sent == false)
|| (is_def_var("noop2") && noop2.sent == false);
let crashed = mkd_ok && !pre.skip && stat_r == "" && noop_r == ""
&& session_closed && ereg("^220[ -]", alive_b);
let banner_vuln = !mkd_ok && pre.hp_rev && !pre.fixed;
#{
crashed: crashed,
banner_vuln: banner_vuln,
banner: banner,
mkd: if mkd1_ok { "505-char directory created" } else { "249-char directory created" },
alive: alive_b
}
store_as: hpglob
- id: detect-stat-overflow
action: match
condition: "hpglob.crashed == true"
source: hpglob.alive
pattern: "^220[ -]"
on_match:
finding:
title: "HP-UX ftpd STAT glob() overflow — session process crashed on STAT ~/*"
description: "After login, the server accepted a long directory name and then dropped the session without replying to 'STAT ~/*'; a NOOP sent 5 s later on the same socket got nothing either and the socket was closed by the peer (broken pipe), while a new connection is still greeted: the forked ftpd process died while glob() expanded the long path — the stack overflow of CVE-2001-0248."
remediation: "Install PHNE_23948 (10.20), PHNE_23949 (11.00), PHNE_23950 (11.11) or a later ftpd patch (HPSBUX0107-162); restrict directory creation and disable anonymous write access until then."
confidence_delta: 0.80
qod: 75
evidence: "{{hpglob.banner}} | {{hpglob.mkd}} | STAT ~/* -> <no reply> | NOOP (5 s later) -> <no reply> | reconnect -> {{hpglob.alive}}"
- id: detect-banner
action: match
condition: "hpglob.banner_vuln == true"
source: hpglob.banner
pattern: "FTP server"
on_match:
finding:
title: "HP-UX ftpd STAT glob() overflow — unpatched HP-UX ftpd in banner"
description: "The FTP banner announces the HP-UX legacy ftpd without a PHNE patch level that includes the CVE-2001-0248 fix (PHNE_23947 or later). The active check could not run (no login, or directory creation refused); this is a version fingerprint."
remediation: "Install PHNE_23948 (10.20), PHNE_23949 (11.00), PHNE_23950 (11.11) or a later ftpd patch (HPSBUX0107-162)."
confidence_delta: 0.70
qod: 70
evidence: "Banner: {{hpglob.banner}}"