Skip to content
OAuth / SSO Write-up Advanced

Hacking an exchange with OAuth and bypassing 2FA

The OAuth implementation in Peatio was vulnerable to state fixation, allowing an attacker to link their Weibo account to a victim's Peatio account. Additionally, the SMS two-factor authentication activation endpoint lacked proper two-factor checks, enabling an attacker to bypass 2FA and potentially hijack accounts.

sakurity.com

Published on sakurity.com

UPDATE: Once again - no one was hacked in reality and the audit was conducted for free. This post is simply an attack scenario.

The author, on sakurity.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 library did not properly validate the state parameter, and the SMS authentication controller failed to enforce two-factor authentication on the update action.

Impact

An attacker could hijack any user's account, bypass two-factor authentication, and potentially steal funds from the exchange's hot wallet, though the admin panel had limited capabilities.

What the attacker needed

Victim clicks a link; attacker has a Weibo account; victim has a Peatio account

How it was found

  1. Set the OAuth state parameter to an arbitrary value and use the attacker's authorization code with the same state to link the attacker's Weibo account to the victim's Peatio account.
  2. If the victim already has a Weibo account linked, exploit Weibo's open redirect to leak the authorization code via the Referer header or fragment, then use it to log in as the victim.
  3. Send a request to the SMS authentication update endpoint to activate a new SMS authenticator without providing a valid two-factor code.
  4. Brute-force the OTP codes for Google Authenticator or SMS to bypass two-factor authentication.
  5. Create a support ticket with a malicious link to lure the admin into visiting the attacker's page.
  6. Use the hijacked admin account to create a large fiat deposit and accept it, then buy and withdraw cryptocurrencies.

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.

This report describes two security flaws in a cryptocurrency exchange. First, the login system that lets users connect their Weibo social media account could be tricked into linking an attacker's Weibo account to a victim's exchange account. Second, the system for enabling SMS-based two-factor authentication (a second password sent by text message) could be bypassed because the step that checks for an existing second factor was missing on the activation request.

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.

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.