Skip to content
Business logic Write-up Intermediate

When a One-Time Password Works Twice: A Password Reset Logic Flaw

A password reset verification code could be reused after a successful password change, allowing an attacker who obtained a valid code to reset the password again. The server accepted the replay and reported success.

Aliso Follow

Published on medium.com

Bug Bounty

Aliso, 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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

Password recovery is one of those flows that looks finished the moment a valid code is accepted. The application in this case used an email-based recovery process: a user entered their account email, requested a verification code, completed verification, and chose a new password. The final request carried three relevant pieces of information:

  • The account identifier.
  • The email verification code.
  • The new password value in the representation generated by the client.

The password field appeared to contain an encoded or hashed representation rather than plaintext. Its precise format was not the issue. The important question was whether the verification code still authorised another password change after the first reset succeeded.

Target identifiers and sensitive request values have been omitted from the write-up, and testing was limited to the researcher's own account.

Setup

The assessment was an authorised bug bounty engagement. Testing was carried out against a single account owned by the researcher, using an intercepting proxy to capture and replay the final password reset request. No other accounts, roles or versions are described.

The report was accepted through YesWeHack and classified as High severity, with a CVSS score of 7.4, under Business Logic Errors (CWE-840).

Finding it

Password recovery is often tested by asking whether an incorrect code gets rejected. That is necessary, but it does not cover the entire lifecycle of a valid code. The researcher's question was different:

What happens if a correct code is submitted again after it has already authorised a password change?

A code can be correct and still be invalid for the current operation. It may have expired, been superseded, or already have been consumed. The server needs to distinguish those states, and the suspicion was that this one did not.

Exploitation

Step 1: capture the final reset request

Using an intercepting proxy, the researcher captured the final password reset request for the test account and allowed it to complete normally. The application returned a success response.

Step 2: replay it with a different password

The request was then replayed, keeping the account and verification code unchanged while replacing the password field with a different client-generated value. The server returned success again.

The report included two request-and-response examples approximately 12 seconds apart. Both used the same verification code, but supplied different password values. No fresh code was requested between them.

The following simplified example illustrates the relationship between the requests. The route and values are placeholders, not the original target details:

HTTP
POST /example/password-reset
account=<owned-test-account>
validateCode=<code-A>
[redacted]
HTTP
POST /example/password-reset
account=<same-owned-test-account>
validateCode=<same-code-A>
[redacted]

The expected result for the second request was rejection because the code had already been used. Instead, the application reported another successful reset.

What the evidence establishes

The key finding was reuse after successful consumption should have occurred. That is a narrower and more useful claim than saying the code never expires. A replay shortly after the first reset demonstrates a failure to enforce single use; it does not establish the code's maximum lifetime.

The original report described repeated successful resets. The attached request pair documents the immediate replay behaviour. It does not independently demonstrate indefinite validity, a bypass of every expiry condition, or access to arbitrary accounts without first obtaining a valid code.

Another important reporting distinction is that an HTTP 200 response alone is not proof of a changed password. The application-level response here also reported success. For the strongest end-to-end evidence, a reproduction should additionally verify that the second password works and the first no longer does. That login comparison is not shown in the attached request pair.

Root cause

Without access to the server's source code, the exact internal implementation could not be confirmed. The observed behaviour was consistent with a validation process that checked whether the submitted code matched an issued code, but failed to enforce its consumed state after a successful password change.

A secure reset decision needs to answer more than "does this code match?" It also needs to establish that the code belongs to the intended account and purpose, remains within its validity period, and has not already authorised a completed operation. The final password-changing endpoint must enforce those conditions itself.

Impact

A password reset code temporarily grants authority to replace an account's password. Once that authority has been exercised, the code should stop working. If it remains usable, someone who has obtained the code may retain the ability to submit another reset after the legitimate reset has completed, while the code remains accepted.

That creates a conditional account-security risk: changing the password may not end the authority of a previously exposed reset code. A subsequent unauthorised reset could also prevent the legitimate user from signing in with the password they just chose.

The precondition matters. This finding did not demonstrate a way to obtain another user's code, bypass email access, or guess codes without restriction. The flaw concerned what an already valid code could do after use.

Fix

The central correction is to make successful use consume the reset authorisation. Code validation, password replacement, and code consumption should be coordinated so that two requests cannot both succeed using the same authorisation. A short expiry period is useful, but it does not replace single-use enforcement: a code that works repeatedly for a few minutes is still reusable.

An alternative design can exchange a verified code for a narrowly scoped, single-use reset token. That token must also be consumed when the password changes. Moving the authorisation into another token does not solve the problem unless its lifecycle is enforced.

A regression check should cover both sequential reuse and concurrent submissions. After one successful reset, another attempt using the same authorisation should fail.

These are remediation recommendations, not a claim that a particular fix has been deployed.

Variants to test

  • Sequential replay of the final reset request. Complete a reset, then resubmit the same account and code with a different password value. A positive result is a second application-level success response, ideally confirmed by logging in with the second password and failing with the first.
  • Concurrent submission of the same code. Fire two reset requests with the same code and different passwords at the same time. A positive result is both requests succeeding, which points to a race in the consumption step rather than a missing check.
  • Replay after a delay within the code's lifetime. Wait part of the validity window and replay. A positive result shows the code is reusable for its whole lifetime, which is a stronger claim than immediate replay alone.
  • Replay after the code's stated expiry. Resubmit once the code should have expired. A positive result would demonstrate that expiry is not enforced either, a separate finding from single-use failure.
  • Token-exchange designs. Where a verified code is exchanged for a reset token, replay the token after the password change. A positive result is the token still being accepted, showing the lifecycle problem was moved rather than fixed.
  • Other one-time flows. Apply the same question to email verification, MFA enrolment, invitation links and password change confirmations: after the token has done its job, can it do that job again? A positive result is any second successful state change using the same token.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 14 min read.

What happened, in plain words

A website let people reset a forgotten password by emailing them a short verification code. The idea behind such a code is simple: you use it once, you prove the account is yours, you set a new password, and the code stops working. That is what "one-time" means.

During an authorised bug bounty assessment, the researcher found that this website did not enforce that last part. After a password had already been changed successfully with a code, the very same code could be sent again, together with a different new password, and the server accepted it a second time. The report was accepted through YesWeHack and classified as High severity, with a CVSS score of 7.4, under Business Logic Errors (CWE-840).

A few words before we go further, because they come up constantly:

  • A bug bounty programme is an arrangement where a company invites outside testers to look for security problems in its systems and report them, usually for a reward. "Authorised" means the tester had permission to do this, which matters legally and ethically.
  • A server is the computer somewhere in the world that runs the website and answers the requests your browser sends. When you click a button, your browser sends a message to the server, and the server sends back a reply.
  • An API (Application Programming Interface) is the set of addresses and rules a website's own pages use to talk to its server. Think of it as the service counter of a shop: your browser fills in a form, and behind the scenes it hands a request across the counter and gets an answer back. Testers often talk to that counter directly instead of through the shop's front window.
  • A request is one such message: "please do this thing, here are the details". A response is the server's reply.
  • A verification code (also called a one-time password, or OTP) is a short secret, usually a handful of digits or letters, that is sent to you by email or text message. It proves you can read messages sent to that address or phone, which is a reasonable sign that the account is yours.
  • A token is a similar idea in a different shape: a longer string of characters that stands in for proof that something has already been checked. A cinema ticket is a good comparison. You buy it once, the attendant tears it or stamps it, and it cannot be used for a second film. A token that is never stamped is a ticket you can reuse.

The researcher tested only their own account, and the write-up leaves out the real website address and the sensitive values in the requests.

The question behind the finding

Most people who test password recovery ask one question: does the site reject a wrong code? That is necessary, but it only covers part of the story. A code has a whole life: it is created, sent, checked, and then it should be used up. Testing only the first part leaves the end of that life unexplored.

The researcher asked something different:

What happens if a correct code is submitted again after it has already authorised a password change?

A code can be correct and still be invalid for the operation in front of it. It may have expired (too much time has passed), it may have been replaced by a newer code, or it may already have been used. The server has to tell those situations apart. The suspicion here was that this server did not.

Understanding the normal flow

The application used an email-based recovery process. In order, a user:

  1. entered their account email,
  2. requested a verification code,
  3. completed verification with that code,
  4. chose a new password.

The final request, the one that actually changes the password, carried three relevant pieces of information:

  • The account identifier (which account is being reset).
  • The email verification code.
  • The new password value in the representation generated by the client.

That last point needs unpacking. "The client" means the part running on your own computer, normally the browser and the page's JavaScript. "The representation generated by the client" means the browser did some processing on the password before sending it, so the value on the wire was not the plain text the user typed. The password field appeared to contain an encoded or hashed representation rather than plaintext.

  • Plaintext is the password exactly as typed, for example the characters you see on screen.
  • Hashing is a one-way mathematical scramble: the same input always gives the same output, but you cannot turn the output back into the input. It is like putting a document through a shredder with a very distinctive pattern: you can compare two shreddings to see if the documents were the same, but you cannot rebuild the document.
  • Encoding is a reversible transformation, closer to translating a sentence into another alphabet. It hides nothing on its own; it just changes the form.

The precise format was not the issue. What mattered was whether the verification code still authorised another password change after the first reset had succeeded.

Replaying the completed operation

Step 1: capture the final reset request

An intercepting proxy is a tool that sits between your browser and the server, like a postal worker who is allowed to open every letter, read it, and even rewrite it before passing it on. The researcher used one to capture the final password reset request for the test account, then let it go through and complete normally. The application returned a success response.

Why do this? Because you cannot replay a message you have not kept a copy of. Capturing it gives you the exact text the browser sent, which you can then send again by hand.

Step 2: replay it with a different password

The request was then replayed, keeping the account and verification code unchanged while replacing the password field with a different client-generated value. The server returned success again.

The report included two request-and-response examples approximately 12 seconds apart. Both used the same verification code, but supplied different password values. No fresh code was requested between them.

The following simplified example illustrates the relationship between the requests. The route and values are placeholders, not the original target details:

HTTP
POST /example/password-reset
account=<owned-test-account>
validateCode=<code-A>
[redacted]

Line by line:

  • POST /example/password-reset is the request line. POST is the method, the verb that says "I am sending data and asking you to change something". /example/password-reset is the address on the server, the equivalent of a counter number in a shop. The word example signals that this is a stand-in, not the real site's address.
  • account=<owned-test-account> says which account is being reset. The angle brackets mark a placeholder: the real value was removed from the write-up. "Owned" here means the researcher's own account.
  • validateCode=<code-A> is the verification code, the one-time secret from the email. code-A is a label for it, not the real code.
  • [redacted] is the new password, already processed by the browser as described above. The 1` marks it as the first value.
HTTP
POST /example/password-reset
account=<same-owned-test-account>
validateCode=<same-code-A>
[redacted]

Line by line:

  • The first line is identical: same method, same address. This is the same operation being asked for a second time.
  • account=<same-owned-test-account> is the same account as before.
  • validateCode=<same-code-A> is the crucial part: the same code that was already used successfully. Nothing new was requested by email.
  • [redacted] is a different new password. The 2` marks it as the second value.

The expected result for the second request was rejection, because the code had already been used. Instead, the application reported another successful reset.

What the evidence establishes

The key finding was reuse after successful consumption should have occurred. In plain terms: the code should have been used up, and it was not.

That is a narrower and more useful claim than saying the code never expires. A replay shortly after the first reset demonstrates a failure to enforce single use; it does not establish the code's maximum lifetime. In everyday terms: showing that a ticket still works five minutes after the film started does not prove it will work next week.

The original report described repeated successful resets. The attached request pair documents the immediate replay behaviour. It does not independently demonstrate indefinite validity, a bypass of every expiry condition, or access to arbitrary accounts without first obtaining a valid code.

Another important reporting distinction is that an HTTP 200 response alone is not proof of a changed password. Here is why that matters. Every web response carries a three-digit status code. 200 is the standard code for "the request was received and handled". But a site can send 200 while its own message inside the reply says "wrong code". So a tester has to read the application-level response, the actual content of the reply, not just the status code. In this case the application-level response also reported success.

For the strongest end-to-end evidence, a reproduction should additionally verify that the second password works and the first no longer does. That login comparison is not shown in the attached request pair. In other words: the best proof is to try logging in with the new password and then with the old one, and see which one the site accepts. That step was not included in the evidence shown.

Keeping these boundaries clear makes the technical explanation more credible. A report that claims only what it can show is taken more seriously than one that overreaches.

Why reuse matters

A password reset code temporarily grants authority to replace an account's password. Once that authority has been exercised, the code should stop working. Compare it to a signed permission slip at an office: once it has been used to collect the key, it should be filed away, not left on the desk for anyone to pick up.

If it remains usable, someone who has obtained the code may retain the ability to submit another reset after the legitimate reset has completed, while the code remains accepted. That creates a conditional account-security risk: changing the password may not end the authority of a previously exposed reset code. A subsequent unauthorised reset could also prevent the legitimate user from signing in with the password they just chose.

The precondition matters. This finding did not demonstrate a way to obtain another user's code, bypass email access, or guess codes without restriction. The flaw concerned what an already valid code could do after use. Think of it as a door that locks properly, but whose key keeps working after you have changed the lock: the problem is not how someone got the key, it is that the key was never retired.

The likely implementation gap

Without access to the server's source code, the exact internal implementation could not be confirmed. Testers usually see only the outside of the building, not the wiring inside.

The observed behaviour was consistent with a validation process that checked whether the submitted code matched an issued code, but failed to enforce its consumed state after a successful password change. In other words, the server asked "is this a code I handed out?" and never asked "has this particular code already done its job?".

A secure reset decision needs to answer more than "does this code match?" It also needs to establish that the code belongs to the intended account and purpose, remains within its validity period, and has not already authorised a completed operation. The final password-changing endpoint must enforce those conditions itself. The endpoint is the specific address on the server that handles one operation, here the one that actually writes the new password. It is the last checkpoint, so it cannot rely on an earlier page having done the checking.

How to address the flaw

The central correction is to make successful use consume the reset authorisation. Code validation, password replacement, and code consumption should be coordinated so that two requests cannot both succeed using the same authorisation. A short expiry period is useful, but it does not replace single-use enforcement: a code that works repeatedly for a few minutes is still reusable.

An alternative design can exchange a verified code for a narrowly scoped, single-use reset token. That token must also be consumed when the password changes. Moving the authorisation into another token does not solve the problem unless its lifecycle is enforced. "Narrowly scoped" means the token is allowed to do one small thing only, not everything on the account.

A regression check should cover both sequential reuse and concurrent submissions. After one successful reset, another attempt using the same authorisation should fail.

  • A regression check is an automated test kept in the codebase so that a bug, once fixed, cannot quietly come back later.
  • Sequential means one after the other, as in the replay described above.
  • Concurrent means at the same moment. Two requests fired simultaneously can slip past a check that only works when they arrive one at a time, because both may read "not used yet" before either one writes "used".

These are remediation recommendations, not a claim that a particular fix has been deployed. "Remediation" simply means the repair.

What I took away

This finding came from examining what remained possible after an operation had succeeded. Most testing stops at "did the action work?". This one asked "what can still be done now that it has worked?".

That is a valuable habit when reviewing authentication workflows. A security token's lifecycle includes issuance, validation, expiration, replacement, and consumption. Testing only the happy path leaves several of those transitions unexplored.

  • Issuance is the moment the code is created and sent.
  • Validation is the check that the code is genuine.
  • Expiration is the point after which it should stop being accepted.
  • Replacement is when a newer code makes an older one void.
  • Consumption is the moment it is used up for good.

For password recovery, one small question exposed the missing boundary:

After a one-time code has done its job, can it do that job again?

Variants to test

These are other ways to ask the same question, useful for anyone testing a similar feature.

  • Sequential replay of the final reset request. Complete a reset, then resubmit the same account and code with a different password value. A positive result is a second application-level success response, ideally confirmed by logging in with the second password and failing with the first.
  • Concurrent submission of the same code. Fire two reset requests with the same code and different passwords at the same time. A positive result is both requests succeeding, which points to a race in the consumption step rather than a missing check. A race condition is when two actions happen so close together that the program's checks get confused about the order.
  • Replay after a delay within the code's lifetime. Wait part of the validity window and replay. A positive result shows the code is reusable for its whole lifetime, which is a stronger claim than immediate replay alone.
  • Replay after the code's stated expiry. Resubmit once the code should have expired. A positive result would demonstrate that expiry is not enforced either, a separate finding from single-use failure.
  • Token-exchange designs. Where a verified code is exchanged for a reset token, replay the token after the password change. A positive result is the token still being accepted, showing the lifecycle problem was moved rather than fixed.
  • Other one-time flows. Apply the same question to email verification, MFA enrolment, invitation links and password change confirmations: after the token has done its job, can it do that job again? A positive result is any second successful state change using the same token. MFA stands for multi-factor authentication, logging in with more than one proof, such as a password plus a code from an app.

Glossary

  • API: the set of addresses and rules a website's pages use to talk to its server; the service counter behind the shop window.
  • Application-level response: the actual content of a server's reply, as opposed to just its status code.
  • Authorised assessment: testing done with the target's permission, typically through a bug bounty programme.
  • Bug bounty programme: an arrangement where a company invites outside testers to find and report security problems, usually for a reward.
  • Client: the part of a system running on the user's own machine, normally the browser and its JavaScript.
  • Concurrent: happening at the same moment.
  • Consumption: the moment a one-time code or token is used up and should stop working.
  • CVSS: a standard scoring system for rating the severity of a security flaw; 7.4 is in the High range.
  • CWE-840: a catalogue entry for Business Logic Errors, flaws where the code does what it was written to do but the rules themselves are wrong or incomplete.
  • Encoding: a reversible transformation of data into another form; it hides nothing by itself.
  • Endpoint: the specific address on a server that handles one operation.
  • Expiration: the point after which a code or token should no longer be accepted.
  • Hashing: a one-way scramble of data; the same input always gives the same output, but the output cannot be turned back into the input.
  • HTTP 200: the standard status code meaning the request was received and handled; it does not by itself prove the intended change happened.
  • Intercepting proxy: a tool placed between browser and server that can read, pause and modify requests and responses.
  • Issuance: the moment a code or token is created and sent.
  • MFA: multi-factor authentication, logging in with more than one kind of proof.
  • One-time password (OTP): a short secret sent by email or text that should work exactly once.
  • Plaintext: data in its original, unprocessed form, such as a password exactly as typed.
  • Race condition: a flaw where two actions happening almost simultaneously confuse a program's checks.
  • Regression check: an automated test that ensures a fixed bug does not return.
  • Remediation: the repair of a security flaw.
  • Replay: sending a request again that was already sent once.
  • Request: a message from browser to server asking it to do something.
  • Response: the server's reply to a request.
  • Sequential: one after the other.
  • Server: the remote computer that runs a website and answers requests.
  • Single use: a rule that a code or token may succeed exactly once.
  • Token: a string of characters that stands in for proof something has already been checked; like a cinema ticket that should be stamped on use.
  • Validation: the check that a submitted code or token is genuine.
  • Verification code: see one-time password.
  • YesWeHack: a bug bounty platform through which this report was accepted.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.