# How I Found a $90,000 Remote Code Execution Vulnerability in Google

Flask session cookie on Google DevSite leaked OAuth client_secret that also signed the cookie, enabling forged sessions and pickle deserialization RCE across multiple Google developer hosts.

- Payout: $90,000
- Severity: critical
- Program: Google
- Found by: Simon Köck
- Disclosed: 2026-10-12
- Write-up quality: 10/10
- Original: https://simonkoeck.com/writeups/google-devsite-flask-session-pickle-rce
- Library page: https://bugbountylibrary.com/r/blog%3Asimonkoeck-com-writeups-google-devsite-flask-session-pickle-rce
- Tags: area:web domain:web impact:internal-access impact:rce kind:bounty platform:blog sev:critical tech:python technique:chained technique:source-review vuln:auth-bypass vuln:deserialization vuln:rce vuln:secrets-leak

**Target:** Google DevSite OAuth flow endpoint /oauth2authorize and Flask session cookie handling
**Root cause:** The OAuth client_secret was embedded inside a pickle-serialized flow object stored in the Flask session cookie, and that same secret was reused as the Flask SECRET_KEY signing the cookie; the callback then unpickled attacker-controllable session data.
**Steps:**
1. Request `https://developers.google.com/oauth2authorize?return_url=%2F` and capture the `session=` cookie.
2. Split cookie into payload.timestamp.signature; base64url-decode payload (strip leading `.` for zlib) and decompress to JSON.
3. Decode the `" b"` bytes value to a pickle; `pickletools.dis` reveals `oauth2client.client.OAuth2WebServerFlow` with `client_id` and `client_secret`.
4. Derive signing key: `hmac.digest(client_secret, b"cookie-session", "sha1")` then HMAC-SHA1 over `payload.timestamp`; matches cookie signature.
5. Forge session JSON with attacker-chosen `google_oauth2_csrf_token` and `google_oauth2_flow_<csrf>` containing base64 pickle bytes.
6. Sign forged payload with derived key; send to callback; server unpickles and executes `__reduce__` callable (proved via `time.sleep(N)` timing).
**How found:** Noticed the Flask session cookie was ~1,200 bytes — unusually large for a CSRF token and return URL — decoded it (signed, not encrypted), spotted a pickle-serialized OAuth flow object containing client_secret, then hypothesized the secret doubled as the Flask SECRET_KEY and verified by recomputing the itsdangerous signature offline.
**Exploitation:** Attacker needs only an unauthenticated request to /oauth2authorize to obtain a signed cookie, extracts the OAuth client_secret from the pickle, derives the Flask signing key, forges a session with an arbitrary pickle under the flow key, and triggers unpickling on the callback — yielding unauthenticated RCE on developers.google.com and other DevSite hosts (firebase.google.com, developer.android.com, source.android.com, docs.partner.android.com).
**Escalation:** Same signing key and pickle sink worked across multiple DevSite hosts, broadening the blast radius from one subdomain to the whole developer docs platform.
**Insight:** When a framework cookie is signed-not-encrypted, always decode it: oversized cookies often hide serialized server-side objects. If any secret appears inside the signed payload, test whether that same secret is the signing key — self-signed secrets collapse integrity. Then look for deserialization sinks (pickle, Marshal, Java serialization) consuming that payload.

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

**Forged session with attacker pickle payload**

```
session = {
 "_permanent": True,
 "google_oauth2_csrf_token": "attacker-chosen",
 "google_oauth2_flow_attacker-chosen": {
 " b": base64.b64encode(attacker_blob).decode()
 },
}
```

**Sleep payload proving pickle RCE**

```
class Sleep:
 def __init__(self, seconds):
 self.seconds = seconds

 def __reduce__(self):
 return (time.sleep, (self.seconds,))
```

**Offline signature recomputation with leaked secret**

```
derived_key = hmac.digest(client_secret, b"cookie-session", "sha1")
expected = hmac.digest(
 derived_key,
 f"{payload}.{timestamp}".encode(),
 "sha1",
)
```

