--- name: ajp-ghostcat description: Ghostcat (CVE-2020-1938) Apache Tomcat AJP connector file read/inclusion — abuse the AJP protocol on port 8009 to read files under the webapp (incl. WEB-INF/web.xml, config, source) and, if the app allows uploads, escalate to RCE by including an uploaded file. Tier 1 (RCE honors the authorization gate). Use when Tomcat AJP (8009) is exposed. --- # Ghostcat — Tomcat AJP File Read / RCE (CVE-2020-1938) Tomcat's AJP connector (default 8009) trusts request attributes a client can set, letting an attacker specify a file to read or include from within the web application — exposing secrets and, with an upload primitive, reaching RCE. ## Trigger phrases `ghostcat, cve-2020-1938, ajp, port 8009, tomcat ajp, ajp file read, web-inf` ## Preconditions Apache Tomcat with the AJP connector enabled and reachable (default port 8009), before **9.0.31 / 8.5.51 / 7.0.100**. File read is always available; RCE additionally needs a way to upload a file (any extension) into the webapp. ## Method 1. **Find AJP:** `nmap -p8009 --script ajp-* host` or `nmap -sV` showing `ajp13`. AJP often left exposed behind a load balancer. 2. **File read (safe PoC):** use the AJP file-read exploit to pull a sensitive in-app file: ``` python3 ghostcat.py -u TARGET -p 8009 -f WEB-INF/web.xml ``` Also read `WEB-INF/classes/application.properties`, `WEB-INF/web.xml` (routes/servlets, DB creds), source `.jsp`/`.class`, `META-INF/context.xml`. Metasploit: `auxiliary/admin/http/tomcat_ghostcat`. 3. **Escalate to RCE (gated):** if the app lets you upload any file (image/avatar/doc) whose path you can predict, upload a JSP payload with a benign extension, then use AJP file *inclusion* to execute it as JSP. Prove with a token-echo JSP, then remove it. ## Modern / rare techniques - **Config → deeper compromise:** `web.xml`/`context.xml` frequently hold DB creds, API keys, and the Tomcat manager path/creds → chain `tomcat-manager-deploy`. - AJP exposure is a misconfig in itself (should be bound to localhost) — report even file-read-only as high severity. ## Bypass / evasion AJP is binary, not HTTP — web WAFs usually don't inspect it; network ACLs are the control. Spoofed AJP attributes bypass HTTP-layer auth. ## Escalation / chaining Leaked manager creds → `tomcat-manager-deploy` (WAR webshell); DB creds → `database-enumeration`; source read → `source-code-review` for more bugs; upload+include → RCE → `linux-privesc`/`windows-privesc`. ## Backend & tooling Preferred Kali path (native / WSL+Kali / Kali-SSH / Kali-MCP / HexStrike / Metasploit-MCP). `ghostcat.py` (00theway), Metasploit `tomcat_ghostcat`, `nmap -p8009`. See `zazy-orchestrator`. ## Verification (background, before reporting) Re-read a second known file to confirm non-coincidental content; for RCE confirm with a benign token/OAST and reproduce, then clean up. Report true positives only. ## Evidence Open AJP port, retrieved `WEB-INF/web.xml` excerpt (redact secrets), Tomcat version, and any RCE PoC output. Remediation: upgrade Tomcat to a fixed version, disable the AJP connector if unused, bind AJP to localhost, set a `secret`/`secretRequired="true"` on the connector, network-restrict 8009.