Microsoft Account Takeover: Reset Code Race Case
Microsoft's account-recovery flow did not reliably enforce attempt limits on short reset codes, so an attacker could make many guesses at once to bypass the intended rate limiting. This could have enabled account takeover, including where additional verification was involved.
medium.com
Published on medium.com
Bug Bounty
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.
Context
This is an analytical case study of a public disclosure, not the author's own discovery. The subject is a 2020 report by security researcher Laxman Muthiyah describing a weakness in Microsoft's account-recovery protections. The service did not reliably enforce its intended safeguards for short reset codes. Microsoft fixed the issue in November 2020 and, according to the researcher, awarded a $50,000 bounty.
The write-up is marked as AI-assisted: drafted with AI help from public sources, then reviewed and edited. It is intended for educational and defensive use only, and procedural reproduction details are intentionally omitted.

AI-generated illustration.
Setup
The disclosure does not describe a lab setup, test accounts, tooling or versions. What it establishes is the target feature: Microsoft's account-recovery flow, which issues short verification codes and is meant to limit repeated attempts against them. The report also notes that recovery and multi-factor verification can share infrastructure, which is relevant to the impact.
Finding it
The weakness was in the attempt controls around short verification codes. The intended protections did not reliably limit repeated attempts. The write-up frames the lesson plainly: a code's short lifetime, or handling on the client side, cannot replace robust attempt controls on the server.
Exploitation
The disclosure deliberately omits procedural reproduction details, so there are no requests, payloads or responses to reproduce here. What the report does convey is the shape of the problem: repeated attempts against a short code were not reliably bounded, and the protections that were supposed to stop that did not hold. The write-up frames the likely mechanism as concurrency: making every guess arrive at once, so that simultaneous validations could evade a counter that is not updated and checked as a single server-side operation.
Root cause
The defensive analysis recommends scoping attempt accounting to the recovery transaction and making it atomic. Network-based limits are only one layer; the recovery transaction needs its own bounded attempt budget. If the budget is updated and checked as separate steps, simultaneous validations can slip past it. The analysis also recommends single-use recovery state, so a successful verification cannot be reused.
Impact
The reported weakness could have enabled account takeover, including where additional verification was involved. Microsoft rated it Important and classified it as Elevation of Privilege involving multi-factor authentication bypass. No CVE was reported. Recovery weaknesses matter because one account can protect email, files and other services that trust it for sign-in.
Fix
Microsoft patched the flow in November 2020. The write-up does not describe the code change. Its defensive recommendations are:
- Count attempts per recovery ticket.
- Make the counter atomic. Update and check the budget as one server-side operation so simultaneous validations cannot evade it.
- Invalidate exhausted tickets. Require the user to begin a fresh recovery flow after the attempt budget is consumed.
- Treat client-side protection as supplementary. Decisions about attempts and recovery state belong on the server.
The pseudocode accompanying those points:
MAX_ATTEMPTS = 5def verify_reset_code(ticket_id, submitted): ticket = store.get(ticket_id) if ticket is None or ticket.expired(): return Fail("expired") attempts = store.atomic_increment(f"reset:{ticket_id}:attempts") if attempts > MAX_ATTEMPTS: store.invalidate(ticket_id) return Fail("locked") if not constant_time_eq(hash_code(submitted, ticket.salt), ticket.code_hash): return Fail("invalid") if not store.consume_once(ticket_id): return Fail("used") return Success(issue_reset_token(ticket.account_id))
Variants to test
The write-up does not list variants. The following follow from its defensive points and are worth trying on other targets:
- Concurrent submissions against one recovery ticket. Fire many code guesses at the same ticket simultaneously. A positive result is more attempts accepted than the stated budget, or a success after the budget should have been exhausted.
- Reuse of a successful verification. Submit a valid code, then submit it again on the same ticket. A positive result is a second success or a second reset token.
- Budget reset by restarting the flow. Exhaust the attempts, start a new recovery flow, and check whether the old ticket or its counter survives. A positive result is the old ticket still accepting guesses.
- Client-side attempt state. Intercept and replay the verification request outside the normal client. A positive result is the server accepting attempts the client would have blocked.
- Shared recovery and MFA infrastructure. Where recovery and multi-factor verification share a backend, test whether attempt accounting on one path affects the other. A positive result is a bypass of the second factor through the recovery path.
Credit and sources
Research by Laxman Muthiyah: How I Might Have Hacked Any Microsoft Account, published March 2021 with Microsoft's approval. Facts about the report are attributed to that source; the defensive analysis and pseudocode are the write-up author's own.
What happened, in plain words
Imagine you have a bank account, and one day you forget your password. The bank sends a short number to your phone, you type it in, and you get back into your account. That short number is the whole security of the recovery process. If someone else could guess it, they could get into your account too.
In 2020, a security researcher named Laxman Muthiyah published a report about Microsoft's account-recovery system. The system was supposed to stop people from guessing the short reset code over and over. According to the report, those protections did not reliably work. Microsoft fixed the problem in November 2020 and, according to the researcher, paid a $50,000 bounty for it.
This article is an analytical case study of that public disclosure. It is not the author's own discovery. The write-up was drafted with AI help from public sources and then reviewed and edited. It is meant for learning and for defending systems, and the step-by-step details needed to reproduce the attack are deliberately left out.

AI-generated illustration.
Before going further, a few words that will come up constantly:
- Account recovery is the feature that lets you get back into an account when you cannot log in, usually by proving you control a phone number or email address.
- A verification code (also called a reset code or one-time code) is a short string of digits that the service sends you and that you type back in. It is short on purpose, so it is easy to type, and it expires quickly, so it cannot be used forever.
- A rate limit is a rule that says "you may only try this a certain number of times in a certain period". A website login that locks you out after five wrong passwords is using a rate limit.
- A race condition is a bug where two things happen at almost the same moment and the system gets confused about the order. Think of two people grabbing the last seat on a train at the same instant: each one checks "is it free?" and both see "yes" before either one sits down.
Setup
The disclosure does not describe a lab setup, test accounts, tooling or software versions. What it does establish is the target feature: Microsoft's account-recovery flow. That flow issues short verification codes and is meant to limit how many times someone can try to guess them. The report also notes that recovery and multi-factor verification can share the same underlying infrastructure, which matters for the impact.
A quick explanation of the pieces involved:
- The server is the computer owned by Microsoft that holds your account and makes the decisions. When you log in, your browser talks to the server.
- The client is the program on your side, usually your browser. Anything the client decides can, in principle, be changed by a determined attacker, because the attacker controls their own browser.
- Multi-factor authentication (MFA) means logging in with more than one proof: your password plus, say, a code on your phone. It is a second lock on the door.
- Infrastructure here means the shared machinery behind these features. If recovery and MFA run on the same machinery, a weakness in one can affect the other.
Finding it
The weakness was in the attempt controls around short verification codes. In plain terms: the system was supposed to count how many times someone tried a code and stop them after a few tries. The intended protections did not reliably limit repeated attempts.
The write-up frames the lesson simply. A code that expires quickly, or protection that lives in the browser, cannot replace solid attempt controls on the server. Why not? Because the expiry only limits how long a code is valid, not how many guesses fit into that window, and because anything enforced in the browser can be bypassed by someone who does not use the normal browser at all.
Exploitation
The disclosure deliberately omits the procedural reproduction details, so there are no requests, payloads or responses to reproduce here. What the report does convey is the shape of the problem: repeated attempts against a short code were not reliably bounded, and the protections meant to stop that did not hold.
The write-up frames the likely mechanism as concurrency: making every guess arrive at once, so that simultaneous validations could slip past a counter that is not updated and checked as a single server-side operation.
Here is the idea in everyday terms. Suppose a guard has a clipboard and a rule: "after five visitors, the door closes". If five people arrive together, each one asks the guard "how many have come in so far?", each hears "four", and each is let through, because the guard only writes the new number down after everyone has already walked past. The count is correct in the end, but five people got in when only one should have. That is what "not atomic" means: the check and the update were separate steps, and simultaneous requests could fit in the gap between them.
Root cause
The defensive analysis recommends scoping attempt accounting to the recovery transaction and making it atomic.
- Scoped to the recovery transaction means the count belongs to one specific recovery attempt, not just to the network address or the browser session. If the count is only per network address, an attacker can change address, or the count can be shared with innocent users behind the same address.
- Atomic means "all or nothing, as one indivisible step". A database operation that adds one to a counter and returns the new value in a single action is atomic. Two separate actions, read then write, are not.
Network-based limits are only one layer. The recovery transaction needs its own bounded attempt budget. If the budget is updated and checked as separate steps, simultaneous validations can slip past it. The analysis also recommends single-use recovery state, so a successful verification cannot be reused. In other words, once a code has been used successfully, the system must mark it as spent, so that the same code cannot be presented again to get a second reset.
Impact
The reported weakness could have enabled account takeover, including where additional verification was involved. Account takeover means someone else gains control of your account, and with it everything that account can reach. Microsoft rated the issue Important and classified it as Elevation of Privilege involving multi-factor authentication bypass. No CVE was reported. A CVE is a public catalogue number given to a known security flaw so people can refer to it unambiguously.
Recovery weaknesses matter because one account can protect email, files and other services that trust it for sign-in. If your email account falls, the attacker can often reset passwords on other sites that send recovery links to that email, so a single weak recovery flow can cascade.
Fix
Microsoft patched the flow in November 2020. The write-up does not describe the code change. Its defensive recommendations are:
- Count attempts per recovery ticket. Network-based limits are only one layer; the recovery transaction needs its own bounded attempt budget. A ticket here is the server-side record of one recovery attempt, the thing that ties the code to your request.
- Make the counter atomic. Update and check the budget as one server-side operation so simultaneous validations cannot evade it.
- Invalidate exhausted tickets. Require the user to begin a fresh recovery flow after the attempt budget is consumed.
- Treat client-side protection as supplementary. Decisions about attempts and recovery state belong on the server.
The pseudocode accompanying those points:
MAX_ATTEMPTS = 5def verify_reset_code(ticket_id, submitted): ticket = store.get(ticket_id) if ticket is None or ticket.expired(): return Fail("expired") attempts = store.atomic_increment(f"reset:{ticket_id}:attempts") if attempts > MAX_ATTEMPTS: store.invalidate(ticket_id) return Fail("locked") if not constant_time_eq(hash_code(submitted, ticket.salt), ticket.code_hash): return Fail("invalid") if not store.consume_once(ticket_id): return Fail("used") return Success(issue_reset_token(ticket.account_id))
Line by line, in plain words:
MAX_ATTEMPTS = 5sets the budget: five tries per recovery ticket.def verify_reset_code(ticket_id, submitted):defines the function that checks a submitted code. It receives the ticket identifier and the code the user typed.ticket = store.get(ticket_id)looks up the recovery ticket in the server's storage.if ticket is None or ticket.expired():checks whether the ticket exists and is still valid.return Fail("expired")refuses the attempt if the ticket is missing or too old.attempts = store.atomic_increment(f"reset:{ticket_id}:attempts")adds one to this ticket's attempt counter and returns the new value, in a single indivisible operation. This is the atomic part: two simultaneous requests cannot both read the same old number.if attempts > MAX_ATTEMPTS:checks whether the budget has been exceeded.store.invalidate(ticket_id)throws the ticket away once the budget is gone, so it cannot be used again.return Fail("locked")tells the caller the ticket is locked.if not constant_time_eq(hash_code(submitted, ticket.salt), ticket.code_hash):compares the submitted code, hashed with the ticket's salt, against the stored hash. Hashing turns a value into a fixed-length fingerprint that cannot easily be reversed; a salt is a random value mixed in so that identical codes do not produce identical fingerprints. Constant-time comparison takes the same amount of time whether the values match or not, so an attacker cannot learn anything from how long the check takes.return Fail("invalid")refuses a wrong code.if not store.consume_once(ticket_id):tries to mark the ticket as used, exactly once. If it was already used, this fails.return Fail("used")refuses a code that has already been spent.return Success(issue_reset_token(ticket.account_id))only on a correct, first-time use, issues the reset token for the account. A token is a temporary credential, like a stamped ticket, that proves you are allowed to do something.
Variants to test
The write-up does not list variants. The following follow from its defensive points and are worth trying on other targets. These are ideas for testing systems you are authorised to test, not instructions for attacking anyone.
- Concurrent submissions against one recovery ticket. Fire many code guesses at the same ticket simultaneously. A positive result is more attempts accepted than the stated budget, or a success after the budget should have been exhausted. This is the race condition from the start of the article: many guesses arriving at once.
- Reuse of a successful verification. Submit a valid code, then submit it again on the same ticket. A positive result is a second success or a second reset token.
- Budget reset by restarting the flow. Exhaust the attempts, start a new recovery flow, and check whether the old ticket or its counter survives. A positive result is the old ticket still accepting guesses.
- Client-side attempt state. Intercept and replay the verification request outside the normal client. A positive result is the server accepting attempts the client would have blocked. Replay means sending the same request again, as if pressing send twice.
- Shared recovery and MFA infrastructure. Where recovery and multi-factor verification share a backend, test whether attempt accounting on one path affects the other. A positive result is a bypass of the second factor through the recovery path.
Credit and sources
Research by Laxman Muthiyah: How I Might Have Hacked Any Microsoft Account, published March 2021 with Microsoft's approval. Facts about the report are attributed to that source; the defensive analysis and pseudocode are the write-up author's own.
Glossary
- Account recovery: the feature that lets you regain access to an account when you cannot log in, usually by proving you control a phone number or email address.
- Account takeover: a situation where someone other than the owner gains control of an account and everything it can reach.
- Atomic: done as one indivisible step, so that two simultaneous operations cannot both see the same old state.
- Attempt budget: the maximum number of tries allowed for one recovery attempt before it is locked.
- Backend: the server-side part of a system that users do not see directly.
- Bounty: a payment made by a company to a researcher who reports a security flaw.
- Client: the program on the user's side, usually a browser.
- Concurrency: two or more operations happening at effectively the same moment.
- Constant-time comparison: a comparison that takes the same time whether values match or not, so timing reveals nothing.
- CVE: a public catalogue number for a known security flaw.
- Elevation of Privilege: a class of flaw where someone gains more access than they should have.
- Hash: a fixed-length fingerprint of a value that cannot easily be reversed.
- Infrastructure: the shared machinery behind features, such as the servers and storage that recovery and MFA may both use.
- Invalidate: to mark something as no longer usable.
- MFA (multi-factor authentication): logging in with more than one proof, such as a password plus a code on your phone.
- MFA bypass: getting past the second factor without legitimately satisfying it.
- One-time code: a short code meant to be used once and then discarded.
- Pseudocode: code written to explain logic rather than to run as-is.
- Race condition: a bug where simultaneous operations interfere because the system checks and updates state in separate steps.
- Rate limit: a rule limiting how many times an action may be attempted in a period.
- Recovery ticket: the server-side record of one recovery attempt, tying a code to a request.
- Replay: sending the same request again.
- Reset token: a temporary credential that proves permission to reset an account.
- Salt: a random value mixed into a hash so identical inputs do not produce identical fingerprints.
- Server: the computer that holds the account and makes the security decisions.
- Single-use state: a record that can be consumed exactly once and then refuses further use.
- Transaction: a single logical operation, here one recovery attempt from start to finish.
- Verification code: a short string of digits sent to the user and typed back to prove control of a phone or email.