# SSRF protection bypass

Nextcloud's SSRF filter was bypassed using IPv4-mapped IPv6 addresses, letting an authenticated user read internal-network files via the calendar app.

- Payout: $100
- Severity: medium
- Program: Nextcloud
- Found by: foobar7
- Disclosed: 2020-03-14
- CVE: CVE-2020-8138
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/736867
- Library page: https://bugbountylibrary.com/r/h1%3A736867
- Tags: area:web domain:web impact:data-leak impact:internal-access kind:bounty platform:hackerone sev:medium tech:php technique:parser-differential vuln:ssrf

**Target:** Nextcloud server SSRF filter (calendar/dav apps)
**Root cause:** The SSRF blocklist did not normalize IPv4-mapped IPv6 addresses like `[0:0:0:0:0:ffff:127.0.0.1]`, so loopback/internal IPs embedded in IPv6 form passed the filter.
**Steps:**
1. Authenticate to Nextcloud as a low-privileged user.
2. Submit a calendar subscription/import URL pointing to `http://[0:0:0:0:0:ffff:127.0.0.1]:80/secret.ics`.
3. The server fetches the URL, bypassing the SSRF filter, and returns internal content.
4. Run `python nextcloud_ssrf.py http://192.168.0.105/nextcloud/nextcloud/ admin "[password]" http://[0:0:0:0:0:ffff:127.0.0.1]:80/secret.ics` to automate.
**How found:** Likely observed that the SSRF filter blocked plain `127.0.0.1` but not the IPv6-embedded equivalent, then tested the mapped-address form against the calendar fetch.
**Exploitation:** Authenticated user supplies an IPv4-mapped IPv6 URL to the calendar app; the server performs the request against internal/loopback hosts, exfiltrating internal files and enabling actions as the server.
**Insight:** When testing SSRF blocklists, try IPv4-mapped IPv6 forms (`[::ffff:127.0.0.1]`, `[0:0:0:0:0:ffff:7f00:1]`) and other alternate encodings the filter may not normalize before comparison.

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

**IPv6-mapped IPv4 SSRF bypass URL**

```
http://[0:0:0:0:0:ffff:127.0.0.1]/thefile
```

**Exploit script invocation with bypass URL**

```
python nextcloud_ssrf.py http://192.168.0.105/nextcloud/nextcloud/ admin "[password]" http://[0:0:0:0:0:ffff:127.0.0.1]:80/secret.ics
```

