Skip to content
OAuth / SSO Write-up Intermediate

Chaining OAuth2 Dynamic Client Registration to Full Account Takeo

The OAuth server allowed unauthenticated dynamic client registration with any redirect URI and no client secret, so an attacker could register a malicious client and phish a victim into approving it. The attacker then received an authorization code at their own webhook, exchanged it for tokens, and used the stolen token to access the victim's MCP server, including the ability to write emails as the victim.

Divakarvasani Follow

Published on medium.com

Every good hunt starts with mapping the full attack surface. I started with subdomain enumeration using subfinder:

Divakarvasani, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The OAuth server allowed unauthenticated dynamic client registration with arbitrary redirect URIs and public clients (no secret), and PKCE did not help because the attacker controlled both the client and the PKCE values.

Impact

An attacker could obtain tokens granting access to the victim's MCP server, enabling them to write emails as the victim and potentially read contacts, meetings, and call recordings, with 90-day persistence via refresh token.

What the attacker needed

Victim clicks a link; victim approves consent; attacker has a webhook

How it was found

  1. Discover the OAuth authorization server metadata at the well-known endpoint.
  2. Register a new OAuth client without authentication, using an attacker-controlled redirect URI.
  3. Craft an authorization URL with the registered client and desired scopes, and send it to a victim.
  4. Victim approves the consent page, and the authorization code is sent to the attacker's webhook.
  5. Exchange the authorization code for access and refresh tokens without a client secret.
  6. Use the stolen access token to call the MCP server and list available tools, including write_email.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

OAuth is a way for apps to ask a user for permission to access their data on another service. Here, the service let anyone create a new app without proving who they are, and it did not check where the app would send the user after they approved. So an attacker could make a fake app, trick a victim into approving it, and then receive a special code that let the attacker act as the victim.

What is OAuth / SSO?

Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.

More by Divakarvasani

View all

5 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

OAuth and single sign-on flaws

The lesson behind this report.

Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.