# Inject page in admin panel via Shopify.API.pushState with protocol invalid

DOM XSS in Shopify admin via Shopify.API.pushState accepting an invalid protocol in pathname, letting an attacker page postMessage a crafted path and execute script in the admin origin.

- Payout: $500
- Severity: low
- Program: Shopify
- Found by: tiago-danin
- Disclosed: 2020-12-27
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/868615
- Library page: https://bugbountylibrary.com/r/h1%3A868615
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:hackerone sev:low tech:rest technique:chained technique:incomplete-fix vuln:xss

**Target:** Shopify admin panel (your-store.myshopify.com/admin) postMessage handler Shopify.API.pushState
**Root cause:** The pushState pathname filter validated the path but did not correctly reject invalid protocols (e.g. `invalid:pages/xss`), so a crafted pathname bypassed the check and was used to navigate/execute in the admin origin.
**Steps:**
1. Open attacker-controlled page in a tab.
2. Run script that opens `location.origin+'/admin/themes'` in a new window via `window.open`.
3. Build postMessage payload `{message:'Shopify.API.pushState', data:{pathname:'invalid:pages/xss'}}`.
4. Repeatedly `ctx.postMessage(data)` every 500ms until `window.attackSuccess` is set.
5. Admin window processes pushState with invalid protocol pathname, triggering DOM XSS in admin origin.
**How found:** Prior report #662083 showed the pushState filter; researcher retested the filter with an invalid protocol prefix (`invalid:`) instead of a normal path, finding the protocol was not validated correctly.
**Exploitation:** Attacker lures an authenticated Shopify admin to a malicious page; the page opens the admin themes URL and spams postMessage with a pushState message whose pathname uses an invalid protocol. The admin handler fails to reject it, executing attacker script in the admin origin, which can read tokens and store config from the active admin session.
**Insight:** When a postMessage handler validates a pathname, test protocol-prefixed and scheme-like values (`invalid:`, `javascript:`, `data:`) — filters often check path shape but forget to reject arbitrary schemes.

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

**postMessage pushState payload with invalid protocol**

```
const ctx = window.open(location.origin+'/admin/themes', '_blank')
    const data = JSON.stringify({
        message: 'Shopify.API.pushState',
        data: {pathname: "invalid:pages/xss"}
```

**Attack trigger link and interval loop**

```
let interval;
    interval = setInterval(function(){
        if (window.attackSuccess) {
            clearInterval(interval)
        } else {
            ctx.postMessage(data)
        }
    }, 500)
}
attack()
```

