# Site-wide CSRF on Safari due to CORS misconfiguration (not localhost)

Flawed Referer regex accepted domains with trailing `{`/`}`, and Safari resolves such hosts, enabling site-wide CSRF to change victim email.

- Payout: $300
- Severity: medium
- Program: CS Money
- Found by: nnez
- Disclosed: 2020-10-27
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/975983
- Library page: https://bugbountylibrary.com/r/h1%3A975983
- Tags: area:web domain:web impact:integrity kind:bounty platform:hackerone sev:medium tech:rest technique:parser-differential technique:recon vuln:csrf

**Target:** Web app Referer-based CSRF protection on new.cs.money/cs.money
**Root cause:** Referer validation regex matched the trusted domain as a prefix without anchoring, so `new.cs.money{.attacker.com` passed; no SameSite/Origin/Content-Type checks existed.
**Steps:**
1. Login to `new.cs.money` in Safari (Steam auth).
2. Navigate to `new.cs.money{.withgoogle.com` (Safari resolves the `{` host).
3. Inject a form POSTing to `https://new.cs.money/change_email` with `email=nnez+attacker@wearehackerone.com`.
4. Submit; Referer `new.cs.money{...` passes the regex check.
5. Verify email changed at `/th/csgo/personal-info`.
**How found:** Noticed Referer-based anti-CSRF; tested regex behavior and found trailing `{`/`}` bypassed validation; recalled Safari's lenient host parsing for weird characters from CORS research.
**Exploitation:** Attacker hosts a page on a domain like `new.cs.money{.attacker.com`; Safari loads it, and a form auto-submits to the target endpoint. The Referer header begins with the trusted domain plus `{`, satisfying the flawed regex, so the state-changing request succeeds with the victim's cookies.
**Escalation:** Same flawed check used across all endpoints, so any state-changing action (e.g. cash-out) is potentially CSRF-able site-wide.
**Insight:** When a target validates Referer/Origin by prefix or unanchored regex, test boundary characters (`{`, `}`, `@`, `.`) that some browsers (Safari) accept in hostnames to craft a lookalike origin that still passes the check.

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

**CSRF form PoC changing victim email**

```
var FormEl = `
<form action="https://new.cs.money/change_email" method="POST">
        <input type="hidden" name="email" value="nnez+attacker@wearehackerone.com" />
        <button type="submit" style="font-size:28pt;z-index:99999">Submit</button>
    </form>
`;
var Div = document.createElement('div');
Div.innerHTML = FormEl;
document.body.appendChild(Div);
```

