The Bouncer Who Only Read IPv4: SSRF in WordPress Playground’s CORS Proxy
The CORS proxy validated destinations using an IPv4-only lookup and pinned the resolved address only for ports 80 and 443, so a hostname with a public A record and a loopback AAAA record bypassed the private-IP check. An attacker could make the proxy connect to internal services on its own loopback, including a MySQL instance and a memcached-like service, and use it as an internal port scanner.
Published on medium.com
Cybersecurity
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
## Context
WordPress Playground ships with a CORS proxy: a server whose entire job is to take a URL and fetch it on the caller's behalf. That is useful for browser-based tooling, and it is also the classic SSRF shape, because "fetch whatever URL you are given" invites requests to places the caller should not reach.
Because of that, the proxy has a bouncer at the door. Before fetching, it validates that the destination is not a private or internal IP, so that strangers cannot use the errand boy to knock on the project's own back doors. The check lives in `url_validate_and_resolve()` in the open-source repository. Paraphrased from that function, the logic is:
```text
$ips = gethostbynamel($host);
foreach ($ips as $ip) {
if (is_private($ip)) reject();
}
curl_setopt($ch, CURLOPT_RESOLVE, array(
"$host:80:$resolvedIp",
"$host:443:$resolvedIp",
));
```
Two details in that snippet carry the whole bug: the resolver used for validation, and the ports covered by the pin.
{{media:0}}
## Setup
The researcher needed control of a hostname. A free DuckDNS subdomain was enough, configured with two records:
```text
A = [redacted] ← public, innocent, passes the check �
AAAA = ::1 ← "the proxy server's own localhost" 💀
```
The A record points at a public address so the validation sees something harmless. The AAAA record points at `::1`, the loopback of the machine running the proxy. Setting this up, per the write-up, took exactly two clicks in the DuckDNS interface.
{{media:1}}
{{media:2}}
No DNS rebinding, no TTL games and no timing window were required: the two records coexist permanently, so the same hostname resolves to a public IPv4 and to loopback over IPv6 at any moment.
## Finding it
The researcher read the open-source validation code and noticed two independent problems.
**The bouncer is monolingual.** `gethostbynamel()` is a PHP function that returns IPv4 addresses only, that is, A records. The validation therefore checks the English side of the business card and never flips it over. Every hostname can carry two sides:
- the A record (IPv4), which the bouncer checks;
- the AAAA record (IPv6), which the bouncer has never heard of.
So the bouncer reads `[redacted]`, concludes the destination is public, and lets the request through. Then curl, which speaks both address families, dials the IPv6 address `::1` instead. The errand boy delivers the package to his own house's mailroom, with the boss's blessing, in writing.
{{media:3}}
**The VIP pin only covers two doors.** The `CURLOPT_RESOLVE` entry is meant to stop DNS from changing between validation and fetch by pinning the hostname to the validated IP. But the pin is only applied to ports 80 and 443. On any other port there is no pin at all, so curl re-resolves the hostname itself and picks whichever address family it likes. The validated IP is not a rule, only a suggestion.
## Exploitation
### Step 1: confirm the baseline blocks
A literal private IP is rejected, which shows the bouncer works for the case it was written for:
```http
GET /?http://[redacted]:8080/ → 400 "Private IPs are forbidden"
```
A public IPv4 on an internal port is also covered by validation:
```http
GET /?http://[redacted]:3306/probe → 500 "Failed to connect to [redacted]:3306"
```
### Step 2: send the dual-stack hostname to an internal port
The bypass uses the same port, 3306, but the hostname that resolves to a public A record and to `::1` over IPv6:
```http
GET /?http://<redacted>.duckdns.org:3306/probe
→ 500 "curl_exec error: Received HTTP/0.9
when not allowed"
```
The error is the proof: curl connected to something that is not HTTP on the proxy's own loopback, consistent with the internal MySQL instance the proxy's rate limiter uses, at `[::1]:3306`. A connection was made and a reply was received.
### Step 3: probe a second internal service
A probe on port 11211 produced a connection that was established and then silently closed. Two internal services were reachable with one DNS trick and zero rebinding.
{{media:4}}
### Step 4: turn the proxy into a port scanner
Because the AAAA record can be set to `::ffff:<any IPv4>`, an IPv4-mapped IPv6 address, the proxy can be pointed at any IPv4 destination and its error messages distinguish open, closed and filtered states:
- AAAA = `::1` gives *"Received HTTP/0.9"*, so the port is **OPEN** and a service replied;
- AAAA = `::1` on port 49999 gives *"Failed to connect after 1003 ms"*, so the port is **CLOSED**;
- AAAA = `::ffff:[redacted]` gives *"Failed to connect after 538 ms"*, so the IPv4 address chosen by the attacker was dialled.
The last case is the significant one: an otherwise unreachable IPv4 address was contacted because the attacker asked the proxy to contact it. That is full destination control, one DNS record at a time.
{{media:5}}
## Root cause
The validation and the fetch disagree about what the hostname means. Validation resolves only A records through `gethostbynamel()`, while curl resolves both families and is free to prefer the AAAA record. The pin that should close that gap is scoped to ports 80 and 443, so on any other port curl performs its own resolution after validation has already passed.
Both defences fail for the same underlying reason: they assume the hostname has one address and that the fetch will use the address that was checked. The dual-stack hostname breaks the first assumption, and the port-scoped pin breaks the second. The report was closed as a duplicate of an earlier DNS rebinding report with the same root cause.
## Impact
Under the conditions shown, an attacker gets:
- protocol-speaking access to internal services, because the proxy relays arbitrary methods and bodies, so an attacker can hold conversations with internal daemons;
- a free internal port scanner with three distinguishable states (open, closed, filtered);
- no authentication and no user interaction, since the attacker fires the requests directly.
The write-up rates severity as Medium. The report was closed as a duplicate of an earlier submission, a DNS rebinding bypass of the same pin submitted four days before this one, so no bounty was paid.
{{media:6}}
## Fix
The report does not describe a fix that was applied. The lessons it draws point at what should change:
1. Validate both address families. A DNS-based check inherits all of DNS, so it must consider AAAA records as well as A records, or it protects only half the internet.
2. Pin the actual port. Pinning `host:80` and `host:443` while allowing any port is checking the lock on two doors of a thousand-door building.
3. Read the source. The validation logic was open source, and the flaw was visible in the file.
## Variants to test
- **Dual-stack hostname against any URL-fetching proxy.** Point a controlled hostname at a public A record and at `::1` (or an internal address) in AAAA, then request an internal port. A positive result is a connection error that reveals a non-HTTP reply, or a response from an internal service.
- **Non-standard ports against IP-pinned fetchers.** Repeat the request on ports other than 80 and 443. A positive result is the fetcher resolving the hostname itself instead of using the validated address, visible as a connection to the address you chose.
- **IPv4-mapped IPv6 for scanning.** Set AAAA to `::ffff:<target IPv4>` and vary the port. A positive result is distinguishable open, closed and filtered states in the error messages, which turns the fetcher into an internal port scanner.
- **Resolver disagreement in general.** Wherever validation and the HTTP client use different resolution paths, test hostnames whose records differ between families or change between lookups. A positive result is the client reaching an address that validation never saw.## What happened, in plain words
WordPress Playground is a project that lets people run WordPress in a web browser without installing anything. To make that work, it ships with a small helper server called a **CORS proxy**. A proxy is a middleman: instead of your browser contacting a website directly, it asks the proxy to do it, and the proxy hands back the result. This particular proxy has one simple job: you give it a web address, and it fetches that address for you.
That job is convenient, and it is also dangerous. If a server will fetch any address anyone gives it, someone will eventually ask it to fetch addresses that are private to the server's own network, places outsiders should never reach. This kind of attack has a name: **SSRF**, short for Server-Side Request Forgery. The attacker does not break in directly; they trick the server into making requests on their behalf, from a position of trust inside the network.
To prevent that, the proxy has a guard at the door. Before fetching anything, it checks whether the destination is a private or internal address, and refuses if it is. The guard lives in a function called `url_validate_and_resolve()` in the project's open-source code, meaning anyone can read it.
A researcher read that code, spotted two flaws in the guard, and used them to make the proxy talk to services on its own machine. The report was then closed as a duplicate: another researcher had submitted a DNS rebinding bypass of the same pin four days earlier. No bounty was paid.
{{media:0}}
## The setup
Before explaining the flaws, it helps to know two pieces of background: what a DNS record is, and what IPv4 and IPv6 are.
Every time you type a name like `example.com` into a browser, something has to translate that name into a numeric address the computers can actually use. That translation service is called **DNS** (Domain Name System), and the entries it holds are called **DNS records**. Think of DNS as a phone book: you look up a name, you get a number.
There are two versions of the numbering system in use on the internet. **IPv4** addresses look like `[redacted]` and are the older, more familiar format. **IPv6** addresses look like `::1` and are the newer format, created because the world ran out of IPv4 addresses. A single hostname can have a record for each: an **A record** holds the IPv4 address, and an **AAAA record** (pronounced "quad-A") holds the IPv6 address. A hostname with both is called **dual-stack**.
All the researcher needed was control of one hostname. They registered a free subdomain with a service called DuckDNS, which lets anyone point a hostname at addresses of their choosing, and set two records on it:
```text
A = [redacted] ← public, innocent, passes the check �
AAAA = ::1 ← "the proxy server's own localhost" 💀
```
Line by line:
- `A = [redacted]` sets the IPv4 address to a public, harmless-looking address. The comment notes it is "public, innocent, passes the check", because the guard will look at this side and see nothing suspicious.
- `AAAA = ::1` sets the IPv6 address to `::1`. That is the standard shorthand for **loopback**, meaning "this same machine". When a server contacts `::1`, it is contacting itself. The comment calls it "the proxy server's own localhost", which is exactly the private place the guard is supposed to protect.
So the hostname has a split personality: publicly it looks like an ordinary internet address, but over IPv6 it points back at the proxy's own machine. Setting this up, according to the write-up, took exactly two clicks in the DuckDNS interface.
{{media:1}}
{{media:2}}
An important detail: this trick needs no timing. There is a well-known attack called **DNS rebinding**, where an attacker keeps changing what a hostname resolves to, hoping to slip past a check between the moment it is validated and the moment it is used. Here nothing changes. The A and AAAA records sit there permanently, side by side, so the same hostname always resolves to a public IPv4 address and to loopback over IPv6 at the same time.
## Finding it
The researcher read the open-source validation code and found two independent problems.
**Problem one: the guard only speaks IPv4.** The function used for the check is `gethostbynamel()`, a PHP function (PHP is the programming language WordPress is written in) that returns IPv4 addresses only. It looks up A records and nothing else. The write-up puts it as reading the English side of a business card and never flipping it over. So the guard sees `[redacted]`, decides the destination is public, and lets the request through. Then the actual fetching tool, curl, which understands both address families, dials the IPv6 address `::1` instead. The errand boy delivers the package to his own house's mailroom, with the boss's blessing, in writing.
{{media:3}}
**Problem two: the pin only covers two doors.** The code also contains a `CURLOPT_RESOLVE` setting. This is a way of telling curl: "do not look up this hostname yourself, use this exact address that I already checked." It is meant to stop DNS from changing between the check and the fetch. But the pin is only applied to ports 80 and 443, the standard ports for ordinary web traffic. On any other port there is no pin at all, so curl looks up the hostname itself and picks whichever address family it likes. The validated address is not a rule, only a suggestion.
A **port** is a numbered channel on a computer, like an extension number on a phone line. One machine can run many services at once, each listening on its own port: web servers usually on 80 and 443, databases on ports like 3306, and so on. Restricting the pin to two ports means every other service on the machine is unprotected.
## Exploitation
### Step 1: confirm the baseline blocks
Before trying anything clever, the researcher checked that the guard works for the obvious case. A literal private address should be rejected:
```http
GET /?http://[redacted]:8080/ → 400 "Private IPs are forbidden"
```
This is a single HTTP request. `GET` is the basic method a browser uses to ask for something, and the address after the `?` is the URL the researcher wants the proxy to fetch. `[redacted]` is the IPv4 way of writing "this same machine", the equivalent of `::1` in IPv6, and `8080` is a common port for development servers. The response is `400`, an HTTP status code meaning the request was refused as invalid, with the message "Private IPs are forbidden". The guard caught it. Good.
A public IPv4 address on an internal port is also covered:
```http
GET /?http://[redacted]:3306/probe → 500 "Failed to connect to [redacted]:3306"
```
Here the address is public (`[redacted]`) but the port is `3306`, the standard port for MySQL, a popular database. The response is `500`, meaning the server hit an error while handling the request, with the message "Failed to connect to [redacted]:3306". The validation passed because the address is public, and the connection failed. This shows the guard is not blocking based on the port alone.
### Step 2: send the dual-stack hostname to an internal port
The bypass uses the same port, 3306, but swaps in the hostname that resolves to a public A record and to `::1` over IPv6:
```http
GET /?http://<redacted>.duckdns.org:3306/probe
→ 500 "curl_exec error: Received HTTP/0.9
when not allowed"
```
What happens, step by step:
1. The proxy receives the request and runs its validation. It looks up the hostname with `gethostbynamel()`, which returns only the IPv4 side: `[redacted]`. That is public, so the check passes.
2. The proxy hands the URL to curl to fetch. Because the port is 3306, not 80 or 443, no pin applies, so curl does its own lookup and sees both the IPv4 and the IPv6 address. It picks the IPv6 one, `::1`, the proxy's own loopback.
3. Curl connects to whatever is listening on port 3306 of the proxy's own machine. That is consistent with a MySQL database, the one the proxy's rate limiter uses (a rate limiter is a component that slows down or blocks clients making too many requests).
4. MySQL does not speak HTTP, the language curl expects. It sends back its own protocol greeting, and curl complains: "Received HTTP/0.9 when not allowed".
That error message is the proof. Curl connected to something that is not a web server, on the proxy's own loopback, and received a reply. A connection was made and data came back. The guard had been walked straight past.
### Step 3: probe a second internal service
A probe on port 11211 produced a connection that was established and then silently closed. Port 11211 is the standard port for Memcached, a common in-memory caching service. Two internal services were reachable with one DNS trick and zero rebinding.
{{media:4}}
### Step 4: turn the proxy into a port scanner
There is a further twist. IPv6 has a notation called **IPv4-mapped IPv6**: an address of the form `::ffff:<IPv4 address>` means "the IPv4 address written in IPv6 style". Because the AAAA record can be set to `::ffff:<any IPv4>`, the researcher could point the proxy at any IPv4 destination they liked, and the proxy's error messages would reveal whether something was listening there.
That turns the proxy into a **port scanner**: a tool that probes a range of ports to discover which ones have services running. The three outcomes were distinguishable:
- AAAA = `::1` gives *"Received HTTP/0.9"*, so the port is **OPEN** and a service replied;
- AAAA = `::1` on port 49999 gives *"Failed to connect after 1003 ms"*, so the port is **CLOSED**;
- AAAA = `::ffff:[redacted]` gives *"Failed to connect after 538 ms"*, so the IPv4 address chosen by the attacker was dialled.
The last case is the significant one: an otherwise unreachable IPv4 address was contacted because the attacker asked the proxy to contact it. That is full destination control, one DNS record at a time.
{{media:5}}
## Root cause
The validation and the fetch disagree about what the hostname means. Validation resolves only A records through `gethostbynamel()`, while curl resolves both families and is free to prefer the AAAA record. The pin that should close that gap is scoped to ports 80 and 443, so on any other port curl performs its own resolution after validation has already passed.
Both defences fail for the same underlying reason: they assume the hostname has one address and that the fetch will use the address that was checked. The dual-stack hostname breaks the first assumption, and the port-scoped pin breaks the second. The report was closed as a duplicate of an earlier DNS rebinding report with the same root cause.
## Impact
Under the conditions shown, an attacker gets:
- protocol-speaking access to internal services, because the proxy relays arbitrary methods and bodies, so an attacker can hold conversations with internal daemons;
- a free internal port scanner with three distinguishable states (open, closed, filtered);
- no authentication and no user interaction, since the attacker fires the requests directly.
The write-up rates severity as Medium. The report was closed as a duplicate of an earlier submission, a DNS rebinding bypass of the same pin submitted four days before this one, so no bounty was paid.
{{media:6}}
## Fix
The report does not describe a fix that was applied. The lessons it draws point at what should change:
1. Validate both address families. A DNS-based check inherits all of DNS, so it must consider AAAA records as well as A records, or it protects only half the internet.
2. Pin the actual port. Pinning `host:80` and `host:443` while allowing any port is checking the lock on two doors of a thousand-door building.
3. Read the source. The validation logic was open source, and the flaw was visible in the file.
## Variants to test
- **Dual-stack hostname against any URL-fetching proxy.** Point a controlled hostname at a public A record and at `::1` (or an internal address) in AAAA, then request an internal port. A positive result is a connection error that reveals a non-HTTP reply, or a response from an internal service.
- **Non-standard ports against IP-pinned fetchers.** Repeat the request on ports other than 80 and 443. A positive result is the fetcher resolving the hostname itself instead of using the validated address, visible as a connection to the address you chose.
- **IPv4-mapped IPv6 for scanning.** Set AAAA to `::ffff:<target IPv4>` and vary the port. A positive result is distinguishable open, closed and filtered states in the error messages, which turns the fetcher into an internal port scanner.
- **Resolver disagreement in general.** Wherever validation and the HTTP client use different resolution paths, test hostnames whose records differ between families or change between lookups. A positive result is the client reaching an address that validation never saw.
## Glossary
- **A record**: the DNS entry that holds a hostname's IPv4 address.
- **AAAA record**: the DNS entry that holds a hostname's IPv6 address (pronounced "quad-A").
- **CORS proxy**: a server that fetches web addresses on behalf of a browser, used to get around browser restrictions on cross-site requests.
- **curl**: a widely used command-line tool and library for making network requests, which understands both IPv4 and IPv6.
- **DNS**: the Domain Name System, the internet's phone book, translating names into numeric addresses.
- **DNS rebinding**: an attack where a hostname's address is changed between the moment it is checked and the moment it is used, to slip past validation.
- **Dual-stack**: a hostname or machine that has both an IPv4 and an IPv6 address.
- **DuckDNS**: a free service that lets anyone point a subdomain at addresses of their choosing.
- **gethostbynamel()**: a PHP function that looks up a hostname and returns only its IPv4 addresses.
- **HTTP**: the language browsers and web servers use to exchange requests and responses.
- **HTTP status code**: a number in a response saying what happened, such as 400 for a refused request or 500 for a server error.
- **IPv4**: the older internet address format, written like `[redacted]`.
- **IPv6**: the newer internet address format, written like `::1`.
- **IPv4-mapped IPv6**: an IPv6 address of the form `::ffff:<IPv4>`, meaning an IPv4 address written in IPv6 style.
- **Loopback**: the address a machine uses to contact itself, `[redacted]` in IPv4 and `::1` in IPv6.
- **Memcached**: a common in-memory caching service, usually on port 11211.
- **MySQL**: a popular database system, usually on port 3306.
- **Open source**: software whose code is published and can be read by anyone.
- **PHP**: the programming language WordPress is written in.
- **Port**: a numbered channel on a computer, like a phone extension, on which a particular service listens.
- **Port scanner**: a tool that probes ports to discover which ones have services running.
- **Rate limiter**: a component that slows down or blocks clients making too many requests.
- **SSRF (Server-Side Request Forgery)**: a vulnerability where an attacker tricks a server into making requests on their behalf, often to internal systems.
- **TTL**: time to live, how long a DNS answer may be cached before it must be looked up again.