Exposing the Lethal Power of the Refresh Token

Hey folks! In this writeup, I’m gonna show you how I managed to hijack user accounts by exploiting some sneaky gaps in how an app integrates with Google OAuth and Amazon Cognito. The short version is: if an app screws up how it handles your Google user_id and your tokens, you can end up taking over someone else’s account just by juggling emails and token refreshes. Let’s dig in!


Part 1: The Usual Google OAuth Flow

  1. User clicks “Sign in with Google.”
  2. Cognito returns tokens.
  3. App checks the IdToken for a username.
  4. App calls /v1/user/connect.

image.png


Part 2: Amazon Cognito for User Management

Under the hood, the app uses Amazon Cognito to store user profiles. Here’s where it matters: