athena
Challenge
Athena is a hosted API console (“Test APIs without the setup”). The front end posts {method, url, headers, body} to /api/request, and the server makes the request for you. Requests to private addresses are refused with Private network addresses are not allowed.
Approach
This is exactly the kind of check my URL parsing differentials paper is about: a validator and a fetcher that each parse the same URL, and a flag waiting wherever they disagree. The error messages (Use an HTTP or HTTPS URL without credentials., URI authority must not contain a literal backslash.) read like a strict RFC 3986 parser, so I fingerprinted it with about twenty probes drawn from the paper’s categories. All of these were blocked: decimal, octal, hex and short IPv4 forms (2130706433, 017700000001, 0x7f.1, 127.1), IPv6 and IPv4-mapped loopback, ideographic full stops, circled digits, localhost., and userinfo and backslash authority splits.
A small helper kept the probing quick:
| |
Route 1: DNS
The filter only looks at the hostname as text. It never resolves it. http://127.0.0.1.nip.io/ came back with connect ECONNREFUSED 127.0.0.1:80, which proved the server was really reaching its own loopback. Scanning ports through nip.io turned up the app itself on 3000 and an internal service on 8080:
| |
http://127.0.0.1.nip.io:8080/v1/config returned the config, flag included.
Route 2: one decode too many
The flag’s name pointed at the intended bug, so I went back for it. The validator percent-decodes the host once, and the fetcher decodes it again:
| |
The validator sees %31%32%37.0.0.1, which isn’t an IP address, and allows it. The fetcher decodes again, gets 127.0.0.1, and connects. As controls, the single-encoded %31%32%37.0.0.1 and 127%2E0%2E0%2E1 are both blocked, so the double decode is what matters. This is the encoding family of differentials from the paper. The nip.io route is a different bug, a filter that never resolves names, but it reaches the same internal service.
Flag
flag{one_decode_too_many}