# Unauthenticated SSRF in 3rd party module "cerdic/csstidy"

Unauthenticated SSRF via csstidy's bundled css_optimiser.php in Nextcloud Mail lets attackers fetch arbitrary URLs and write remote data as CSS files to a temp dir.

- Payout: $250
- Severity: medium
- Program: Nextcloud
- Found by: eg42
- Disclosed: 2022-09-03
- CVE: CVE-2022-31132
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/1595006
- Library page: https://bugbountylibrary.com/r/h1%3A1595006
- Tags: area:web domain:web impact:internal-access kind:bounty platform:hackerone sev:medium tech:php technique:chained technique:recon vuln:ssrf

**Target:** Nextcloud Mail app bundled cerdic/csstidy css_optimiser.php endpoint
**Root cause:** csstidy ships a publicly accessible test interface (css_optimiser.php) that fetches a user-supplied `url` parameter server-side without authentication or URL validation.
**Steps:**
1. Install Nextcloud Mail app
2. GET `http://example.com/apps/mail/vendor/cerdic/css-tidy/css_optimiser.php` (no auth)
3. Pass `?url=http://localhost/test` to make the server fetch internal URLs
4. To write remote data to disk: `?url=http://localhost/apps/richdocuments/docs/custom.css&custom=1&template=4` stores it under `/apps/mail/vendor/cerdic/css-tidy/temp/`
**How found:** Noticed the mail app bundles a third-party csstidy module that ships a public test interface; inspected the problematic line in css_optimiser.php handling the `url` parameter.
**Exploitation:** Unauthenticated attacker hits the exposed css_optimiser.php with a crafted `url` param; server fetches arbitrary internal/external URLs, enabling internal service probing and writing attacker-controlled remote content as CSS files into a temp directory for later chaining (e.g. LFI→RFI).
**Escalation:** Downloaded CSS files could be chained with an LFI to achieve RFI by hosting PHP code remotely; also used for internal network/router reconnaissance.
**Insight:** Bundled third-party vendor directories often ship example/test scripts (css_optimiser.php, phpinfo, demos) that inherit the app's web root and bypass auth — enumerate `/vendor/` paths of dependencies for leftover test harnesses.

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

**Unauthenticated SSRF via css_optimiser url parameter**

```
http://example.com/apps/mail/vendor/cerdic/css-tidy/css_optimiser.php?url=http://localhost/test
```

**Download remote data as CSS file**

```
http://example.com/apps/mail/vendor/cerdic/css-tidy/css_optimiser.php?url=http://localhost/apps/richdocuments/docs/custom.css&custom=1&template=4
```

