# Stealing Users OAuth authorization code via redirect_uri

Path traversal in OAuth redirect_uri let attacker redirect victims to their own booth.pm product page, leaking the authorization code via Google Analytics query strings.

- Payout: $2,000
- Severity: high
- Program: pixiv
- Found by: kuzu7shiki
- Disclosed: 2023-03-22
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/1861974
- Library page: https://bugbountylibrary.com/r/h1%3A1861974
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:hackerone sev:high tech:oauth technique:chained vuln:open-redirect vuln:path-traversal

**Target:** OAuth authorize endpoint oauth.secure.pixiv.net and booth.pm redirect_uri handling
**Root cause:** redirect_uri validation only checked the host/prefix and did not normalize path traversal sequences, so `callback/../../../../ja/items/<id>` resolved to an attacker-controlled product page on the same origin.
**Steps:**
1. Attacker publishes a shop/product on booth.pm and configures their own Google Analytics tracking ID on the product page.
2. Craft authorize URL with `redirect_uri=https%3A%2F%2Fbooth.pm%2Fusers%2Fauth%2Fpixiv%2Fcallback/../../../../ja/items/<attacker_product_id>` and any `state`.
3. Send link to victim; victim logs in via pixiv OAuth.
4. Server redirects to `https://booth.pm/ja/items/<id>?code=<authcode>&state=...`; attacker reads the code from GA real-time reports.
**How found:** Noticed the redirect_uri was a path under booth.pm and tested whether path traversal segments could escape the callback path to another same-origin page the attacker controls, then realized GA on that page would capture the query string.
**Exploitation:** Victim authenticates through the OAuth flow; the authorization code is appended to the redirect target URL. Because the redirect lands on the attacker's product page which loads attacker-controlled Google Analytics, the full URL including `code` is sent to the attacker's GA property, yielding the code for token exchange and account takeover.
**Insight:** When redirect_uri validation is prefix/host-based, try `callback/../..` traversal to reach any same-origin page you control that logs query strings (analytics, referrer, share widgets) to exfiltrate the code without an open redirect.

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

**Malicious authorize URL with path traversal redirect_uri**

```
https://oauth.secure.pixiv.net/v2/auth/authorize?client_id=a1Z7w6JssUQkw5Hid0uIDeuesue9&redirect_uri=https%3A%2F%2Fbooth.pm%2Fusers%2Fauth%2Fpixiv%2Fcallback/../../../../ja/items/[attacker's product id]&response_type=code&scope=read-works+read-favorite-users+read-friends+read-profile+read-email+write-profile&state=%3A1a38b53563599621ce25094661b1c4458ddb52d79d771149
```

**Path traversal redirect_uri payload**

```
redirect_uri=https%3A%2F%2Fbooth.pm%2Fusers%2Fauth%2Fpixiv%2Fcallback/../../../../ja/items/4503924
```

