Skip to content

Independent cybersecurity briefing

Latest

RSS
Breaches, bounties, zero-days, and AI.

Bug Bounty Write Ups

Instagram Account Takeover: Racing the 6-Digit Code

*AI-assisted: drafted with AI help from public sources, then reviewed and edited. This is an analytical case study of a public disclosure, not my own discovery.*

Adam Hale, ZeroDay Times editorBy Adam Hale3 min read

Still life for “Instagram Account Takeover: Racing the 6-Digit Code”: a magnifier and a sealed envelope, dark grove, Desk mark, signal CASE. [ BUG BOUNTY ] badge.

AI-generated illustration

A $30,000 Facebook bounty: Instagram’s recovery codes were rate limited per source, so concurrency plus more IPs bought a million guesses

AI-assisted: drafted with AI help from public sources, then reviewed and edited. This is an analytical case study of a public disclosure, not my own discovery.

A six-digit code was the only thing standing between an attacker and an Instagram account takeover. In 2019, Laxman Muthiyah showed that Instagram’s mobile password-recovery flow throttled guesses per source but never capped guesses per code, so parallel requests from many IP addresses could cover the whole code space. Facebook fixed it and paid $30,000.

Disclaimer: * Educational and defensive use only. This was patched in 2019. Reproduction details are intentionally omitted.*

Vulnerability Overview

  • Type: Broken brute-force protection on a password-recovery code (rate limit bypass via concurrency and IP rotation)
  • CWE (analytical mapping, not from the source): CWE-307 (Improper Restriction of Excessive Authentication Attempts), CWE-362 (Race Condition)
  • CVE: None (hosted service)
  • Severity/Bounty: Severity rating not reported. Bounty: $30,000 from Facebook

How the Instagram Account Takeover Worked (high level)

The web reset flow used links and held up. The mobile flow sent a six-digit code by SMS instead. Six digits is one million possibilities, and each code stayed valid for 10 minutes.

There was a rate limit. In the researcher’s first test, roughly a quarter of a 1,000-request burst got through and the rest were throttled. But two things were missing. Throttled sources were slowed, never blocked. And the limit was keyed to the source, not to the code being guessed.

So the attack became arithmetic. He reports about 200 guesses per IP before throttling. Send them concurrently from many addresses and no single source ever trips the limit. In his test, 1,000 machines sent 200,000 guesses, a fifth of the code space, inside the window. His estimate for a full attack: about 5,000 IPs and roughly $150 of cloud compute.

Business Impact

A working attack meant full takeover of any account with a phone number on file; the victim would only see an SMS they never requested. Private messages, creator income and brand accounts were all exposed.

Facebook first could not reproduce it; a proof-of-concept video of 200,000 accepted requests changed that.

Fixing Instagram-Style Reset Code Brute Force (my own analysis)

1. Budget guesses per code, not per IP. Attackers can rent IPs, not extra attempts.

2. Count before you compare. The attempt counter must be incremented atomically and committed before checking the guess, or parallel requests all read “0 attempts so far”.

3. Cap code issuance per account. Otherwise each fresh code is a fresh budget.

# Pseudocode: the guess budget belongs to the code, not to the caller's IP
MAX_TRIES = 5
def verify_recovery_code(account_id, submitted, request):
    rec = recovery_codes.get_active(account_id)        # one live code per account
    if rec is None or rec.expires_at < now():
        return reject("code_invalid")
    tries = recovery_codes.increment_attempts(rec.id)  # atomic UPDATE ... RETURNING, committed now
    if tries > MAX_TRIES:
        recovery_codes.revoke(rec.id)                  # burn it; a new code must be requested
        alert("recovery_bruteforce", account_id, request.ip)
        return reject("code_invalid")
    if not constant_time_equals(rec.code_hash, hash_code(submitted)):
        return reject("code_invalid")                  # the failed attempt is already counted
    if not recovery_codes.consume_once(rec.id):        # compare-and-set: single use
        return reject("code_invalid")
    return issue_reset_session(account_id)
# Issuance cap: N codes/account/day keeps odds near N*5 in a million
# Test: 1,000 parallel guesses from 1,000 IPs -> at most 5 compared, then code revoked

Key Takeaways

  • A rate limit keyed to IP addresses protects your servers, not your users’ accounts.
  • Brute-force counters must survive concurrency: increment first, compare second.

Credit & Sources

Found by Laxman Muthiyah. Primary source: his write-up How I Could Have Hacked Any Instagram Account (The Zero Hack; the page now shows a later update date): flow, rate-limit observations, test scale, cost estimate and $30,000 reward. Date context: SecurityWeek, 15 July 2019. Facts come from those sources; analysis and code are original.

Next breakdown: another real bug bounty case. Follow @masimshahzad for daily bug bounty breakdowns.

First published by Adam Hale on Medium.

Sources

Share

Corrections and tips:[email protected]