# SSRF via filter bypass due to lax checking on IPs

Enclosed alphanumeric Unicode digits like ⑯⑨。②⑤④。⑯⑨｡②⑤④ bypass Nextcloud's ThrowIfLocalIp filter and resolve to AWS metadata IP 169.254.169.254, enabling SSRF.

- Payout: $250
- Severity: medium
- Program: Nextcloud
- Found by: obitorasu
- Disclosed: 2023-02-10
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/1702864
- Library page: https://bugbountylibrary.com/r/h1%3A1702864
- Tags: area:web domain:web impact:data-leak impact:internal-access kind:bounty platform:hackerone sev:medium tech:aws technique:parser-differential technique:unicode-normalization vuln:ssrf

**Target:** Nextcloud server IP validation (ThrowIfLocalIp) used by SSRF-prone fetch endpoints
**Root cause:** filter_var(FILTER_VALIDATE_IP) rejects the Unicode-enclosed-alphanumeric string so the private/reserved range checks are skipped, but the downstream HTTP client/resolver normalizes it to 169.254.169.254.
**Steps:**
1. Read prior report 1608039 and inspect ThrowIfLocalIp in Nextcloud source.
2. Note filter_var only blocks when it validates as IP; non-IP strings fall through unchecked.
3. Build local harness calling ThrowIfLocalIp($_GET['ip']) echoing Pass on bypass.
4. Send `?ip=⑯⑨。②⑤④。⑯⑨｡②⑤④` (enclosed alphanumerics with ideographic/fullwidth dots).
5. Observe Pass echoed, meaning filter bypassed; resolver maps it to 169.254.169.254.
6. Confirm 8.8.8.8/8.8.4.4 still pass and 100.100.100.200 is blocked as control.
**How found:** After reading a prior SSRF report, re-read the highlighted ThrowIfLocalIp code and noticed the filter only acts when filter_var validates the input as an IP, so non-IP representations skip all range checks; hypothesized alphanumeric/Unicode payloads and tested in a local harness.
**Exploitation:** Attacker supplies the enclosed-alphanumeric host to any Nextcloud feature that fetches a user-controlled URL; the filter passes it, the HTTP client resolves it to 169.254.169.254, and the response (AWS IMDS credentials/metadata) is returned to the attacker.
**Insight:** When a denylist gate is conditioned on 'input parses as an IP', any representation the parser rejects but the downstream resolver accepts (Unicode enclosed alphanumerics, fullwidth dots) bypasses it entirely; test the gap between validator and resolver.

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

**Alphanumeric SSRF payload resolving to AWS metadata IP**

```
An example can be using `⑯⑨。②⑤④。⑯⑨｡②⑤④` which would allow an attacker to read crucial metadata if the server is hosted on the AWS platform. The above payload will resolve to the magic IP of AWS namely `169.254.169.254` but bypasses all the filtering present in the code itself.
```

