Skip to content
Account takeover Write-up Intermediate

0 Click ATO with the Sandwich Attack

Roni Carta Follow

Published on landh.tech

Bounty$5,000 View original

I’d like to share with you an intriguing story from my journey in the field of bug bounty hunting. This story happened one night collaborating with my friend Snorlhax where we were testing a new application of one of our target.

Roni Carta (@0xLupin), on landh.tech

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

The target was a web application belonging to one of the author's bug bounty targets, tested together with his friend Snorlhax. The feature at the centre of the story is the password reset flow. Normally, such a flow sends an email to the user containing a reset token embedded in a URL. That token should be unique per user and unguessable. The application under test used a UUID as the reset token, and specifically a UUID Version 1 rather than the more common random Version 4.

That choice is what made the feature attackable. A V1 UUID is derived from a timestamp and the MAC address of the machine that generated it, so it is predictable rather than random. The author calls the resulting technique the "Sandwich Attack" and describes using it to obtain a 0 Click Account Take Over (ATO). He presented the vulnerability at HacktivityCon 2022 in Las Vegas and on the French channel Underscore_.

Or watch on YouTube
From the original on landh.tech
Or watch on YouTube

Setup

The author did not want to go through the lengthy process of creating a new account on the application, so he asked Snorlhax for one of his account credentials. Snorlhax provided a link to the password reset feature so the author could set his own password. Seeing that link, with a UUID as the token, was the moment the author knew the feature could be attacked.

The tools involved were:

  1. A Ruby script written by the author's brother Holmes, which generates all UUIDs between two given points. It is open sourced at https://github.com/Lupin-Holmes/sandwich.
  2. ffuf, an open-source fuzzing tool (https://github.com/ffuf/ffuf), used to send the generated identifiers to the reset password endpoint.

No versions, headers or full request and response captures are given in the report.

Finding it

The reset link Snorlhax sent contained a UUID as the token. UUIDs are common and are sometimes used as password reset tokens, but this one was a UUID Version 1. There are five versions of UUIDs, with V1 and V4 the most common. V1 uses the timestamp and MAC address, while V4 uses random numbers. A V1 token is therefore not unguessable in the way a reset token should be, which is what made the author suspect the feature.

A V1 UUID is constructed in six sections: High, Mid, Low, Clock Sequence, Node ID, and UUID version.

UUIDv1
UUIDv1 From the original on landh.tech

The Node ID corresponds to the MAC address of the system generating the identifier. If two consecutive UUIDs are generated on the same device, this part stays the same, as does the Clock Sequence.

Unchanged
Unchanged From the original on landh.tech

When High, Mid and Low are combined, they reveal a timestamp represented in hexadecimal value.

High Mid Low
High Mid Low From the original on landh.tech

With some basic mathematics it is possible to subtract the offset between the Gregorian Calendar and the Julian Calendar and then divide by 1000 to get an Epoch timestamp.

Calculations
Calculations From the original on landh.tech

From that, the date can easily be recovered with a converter such as https://www.epochconverter.com/.

date
date From the original on landh.tech

VerSprite's article "How Secure are UUIDs" (https://versprite.com/blog/universally-unique-identifiers/) introduces the Sandwich Attack as a method to brute force unique identifiers. In that methodology the attacker first triggers a reset token email to their own account, generating the first "slice of bread" UUID. They then use the victim's email address to send a password reset, which is the "filling". Finally they send another reset password email to their own account, creating the final "slice". The victim's reset token is now sandwiched between two known points, which establishes a time range for brute forcing.

Exploitation

Step 1: Obtain a reset link and identify the token format

The author received a password reset link from Snorlhax and set his own password with it. The token in the URL was a UUID Version 1, which exposed a timestamp and the generating machine's MAC address.

Step 2: Sandwich the victim's token

The team found themselves in exactly the scenario described by VerSprite. The victim's token was now bounded by two known UUIDs.

Step 3: Generate the candidate range

Holmes wrote a Ruby script that generates all UUIDs between two given points. In this case the API returned two tokens with a difference of 100,000 possibilities, so the search space was 100,000 candidate UUIDs.

That’s not him
That’s not him From the original on landh.tech

Step 4: Fuzz the reset endpoint

Using the generator and ffuf, the team produced the list of possible identifiers and fuzzed the API of the Reset Password endpoint with them. The report does not include the ffuf command line or the request format.

Step 5: Take over the account

Of the 100,000 possibilities, the correct token was found. The team completed a full account takeover without any user interaction. The program classified it as a High vulnerability and paid a bounty of $5000.

Root cause

The reset token was a UUID Version 1. V1 UUIDs embed a timestamp and the MAC address of the generating host, so tokens issued close together in time are highly predictable. An attacker who can trigger resets for their own account around a victim's reset request learns the two endpoints of the range and only has to enumerate the identifiers in between. The report does not describe any server-side rate limiting or other control that would have stopped the enumeration; the only obstacle was the size of the range.

The author also notes an important caveat: multiple machines could potentially generate password reset tokens for the same endpoint. The team sent 30 reset password requests and examined the Clock and MAC address values of each token. They found 6 machines generating these tokens, which multiplied their brute force possibilities by 6. In other words, several machines issuing tokens multiplied the brute force possibilities by 6.

Impact

An attacker who can reach the password reset feature and knows a victim's email address can take over the account with no interaction from the victim. The reset token was a V1 UUID, and the attacker could trigger resets for their own account to bracket the victim's token. In this case the range was 100,000 candidates, and 6 machines were generating tokens. The program rated it High and paid $5000.

Fix

The report does not state what the application changed. The clear implication is that reset tokens should not be predictable identifiers such as V1 UUIDs; a random token (for example a V4 UUID or a cryptographically random value) removes the timestamp and MAC address that make the sandwich possible. Rate limiting on the reset endpoint would also reduce the feasibility of enumerating a range.

Variants to test

  1. Check the format of password reset tokens on other targets. A positive result is a token that decodes as a V1 UUID, with a timestamp and a stable Node ID across consecutive requests.
  2. Trigger two resets for your own account around a reset for a second account you control, then generate the UUIDs in between and fuzz the reset endpoint. A positive result is that the middle account's token is found within the range.
  3. Send a batch of reset requests (the author used 30) and compare Clock Sequence and Node ID values. A positive result is several distinct MAC addresses, which tells you how much the search space is multiplied.
  4. Look for other features that use UUIDs as unguessable values, such as invitation links, email verification links or API keys. A positive result is any such value that is a V1 UUID rather than a random one.
  5. Measure the gap between two consecutive self-issued tokens. A small gap means a small sandwich range and a practical brute force.

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. 11 min read.

What happened, in plain words

A website had a "forgot my password" feature. When you click that link, the site emails you a special web address that contains a long code. Clicking that address lets you set a new password. The code is supposed to be a secret that nobody else can guess, like a key that only fits your door.

On this particular site, the code was not random. It was built partly from the exact moment in time it was created and partly from a hardware fingerprint of the computer that made it. That means if you know roughly when a code was made, you can work out the rest. The author of this story used that weakness to guess another person's reset code and take over their account, without the victim doing anything at all. The site's owners treated it as a serious (High) issue and paid a $5000 bounty.

The author calls the trick the "Sandwich Attack": you make your own reset code, then the victim's code is made, then you make another of your own. The victim's code is now "sandwiched" between two codes you know, so you only have to search the small gap in between.

Background: what a password reset is, and what a token is

When you forget your password, most websites do not let you just type a new one. That would let anyone who knows your email address take over your account. Instead they send a message to your email inbox. The message contains a link with a long, hard-to-guess code in it. That code is called a token. Only someone who can read your email can click the link and set a new password.

A token is like a cloakroom ticket: it is a short piece of text that stands in for proof that you are allowed to do something. If someone else can guess or copy your ticket, they can collect your coat. So a good token must be unguessable: long, random, and different every time.

The feature at the centre of this story is exactly that reset flow. The author and his friend Snorlhax were testing a web application that belonged to one of the author's bug bounty targets. Bug bounty means a company invites outside testers to look for security problems and pays them for reporting real ones.

The moment the author spotted the problem

The author did not want to spend time creating a brand new account on the application, because the sign-up process was long. So he asked Snorlhax for one of his existing accounts. Snorlhax sent back a link to the password reset feature so the author could set his own password on that account.

That link was the clue. The token inside it was a UUID, a "Universally Unique Identifier". UUIDs are common and are sometimes used as reset tokens. But this one was a particular kind: a UUID Version 1. There are five versions of UUIDs, and V1 and V4 are the most common. V1 is built from a timestamp and a MAC address. V4 is built from random numbers. A V1 token is therefore not truly unguessable, and that is what made the author suspect the feature could be attacked.

Or watch on YouTube
From the original on landh.tech
Or watch on YouTube

The author presented this vulnerability at HacktivityCon 2022 in Las Vegas and on the French channel Underscore_.

How a Version 1 UUID is built

A V1 UUID is constructed in six sections: High, Mid, Low, Clock Sequence, Node ID, and UUID version.

UUIDv1
UUIDv1 From the original on landh.tech

Think of it like a receipt printed by a shop till. Part of the receipt is the date and time, part is the serial number of the till, and a small part says which model of till it is. If you know the shop and roughly when you paid, you can work out the receipt number.

The Node ID corresponds to the MAC address of the system that generated the identifier. A MAC address is a hardware fingerprint burned into a network card, a bit like a car's registration plate. If two consecutive UUIDs are generated on the same device, this part stays the same, as does the Clock Sequence.

Unchanged
Unchanged From the original on landh.tech

When High, Mid and Low are combined, they reveal a timestamp represented in hexadecimal value. Hexadecimal is just a way of writing numbers using sixteen symbols (0 to 9 and A to F) instead of ten. It is a compact notation, like writing a long number in shorthand.

High Mid Low
High Mid Low From the original on landh.tech

With some basic mathematics it is possible to subtract the offset between the Gregorian Calendar and the Julian Calendar and then divide by 1000 to get an Epoch timestamp. An Epoch timestamp is simply the number of seconds that have passed since a fixed starting point (1 January 1970). It is the way computers usually store a moment in time.

Calculations
Calculations From the original on landh.tech

From that, the date can easily be recovered with a converter such as https://www.epochconverter.com/.

date
date From the original on landh.tech

So a V1 UUID is not a secret at all. It is a timestamp plus a machine fingerprint, dressed up to look random.

The Sandwich Attack

VerSprite's article "How Secure are UUIDs" (https://versprite.com/blog/universally-unique-identifiers/) introduces the Sandwich Attack as a method to brute force unique identifiers. Brute force means trying every possibility in turn until one works, like trying every key on a big ring until a door opens.

In that methodology the attacker first triggers a reset token email to their own account, generating the first "slice of bread" UUID. They then use the victim's email address to send a password reset, which is the "filling". Finally they send another reset password email to their own account, creating the final "slice". The victim's reset token is now sandwiched between two known points, which establishes a time range for brute forcing.

Why does this matter? Because the two slices tell you the start and end of the time window. Since V1 UUIDs are built from time, every UUID made in that window is a candidate. You do not have to guess the whole internet; you only have to guess the small slice in the middle.

The tools used

The team relied on two tools:

  1. A Ruby script written by the author's brother Holmes, which generates all UUIDs between two given points. It is open sourced at https://github.com/Lupin-Holmes/sandwich.
  2. ffuf, an open-source fuzzing tool (https://github.com/ffuf/ffuf), used to send the generated identifiers to the reset password endpoint.

Ruby is a programming language. Fuzzing means sending lots of automatically generated inputs to a system to see which one gets a different, useful response. Open source means the code is published publicly so anyone can read and reuse it.

No versions, headers or full request and response captures are given in the report.

Exploitation, step by step

Step 1: Obtain a reset link and identify the token format

The author received a password reset link from Snorlhax and set his own password with it. The token in the URL was a UUID Version 1, which exposed a timestamp and the generating machine's MAC address. That is the moment the feature went from "normal" to "suspicious".

Step 2: Sandwich the victim's token

The team found themselves in exactly the scenario described by VerSprite. The victim's token was now bounded by two known UUIDs. The two known tokens act like bookends: whatever the victim's token is, it must sit between them in time.

Step 3: Generate the candidate range

Holmes wrote a Ruby script that generates all UUIDs between two given points. In this case the API returned two tokens with a difference of 100,000 possibilities, so the search space was 100,000 candidate UUIDs. An API (Application Programming Interface) is the part of a website that accepts requests from software rather than from a human clicking buttons. It is like a service counter: you hand over a request, it hands back a response.

That’s not him
That’s not him From the original on landh.tech

A search space of 100,000 sounds large, but a computer can try that many values in a short time. Compare it to a combination lock with 100,000 settings: too many for a person by hand, trivial for a script.

Step 4: Fuzz the reset endpoint

Using the generator and ffuf, the team produced the list of possible identifiers and fuzzed the API of the Reset Password endpoint with them. An endpoint is a specific address on a server that accepts a particular kind of request, like a specific counter in a large office. The report does not include the ffuf command line or the request format.

Step 5: Take over the account

Of the 100,000 possibilities, the correct token was found. The team completed a full account takeover without any user interaction. Account takeover (ATO) means logging in as someone else and controlling their account. "0 Click" means the victim did not have to click anything, open an email, or do anything at all. The program classified it as a High vulnerability and paid a bounty of $5000.

Why it worked

The reset token was a UUID Version 1. V1 UUIDs embed a timestamp and the MAC address of the generating host, so tokens issued close together in time are highly predictable. An attacker who can trigger resets for their own account around a victim's reset request learns the two endpoints of the range and only has to enumerate the identifiers in between. The report does not describe any server-side rate limiting or other control that would have stopped the enumeration; the only obstacle was the size of the range.

Rate limiting is a control that stops a client from making too many requests in a short time, like a bouncer who only lets a few people in per minute. Without it, a script can try thousands of guesses.

A caveat: more than one machine

The author also notes an important caveat: multiple machines could potentially generate password reset tokens for the same endpoint. The team sent 30 reset password requests and examined the Clock and MAC address values of each token. They found 6 machines generating these tokens, which multiplied their brute force possibilities by 6. In other words, several machines issuing tokens multiplied the brute force possibilities by 6.

Think of it like a shop with six tills. If you know the time window but not which till printed the receipt, you have to check the sequence from every till. The search space grows accordingly.

Impact

An attacker who can reach the password reset feature and knows a victim's email address can take over the account with no interaction from the victim. The reset token was a V1 UUID, and the attacker could trigger resets for their own account to bracket the victim's token. In this case the range was 100,000 candidates, and 6 machines were generating tokens. The program rated it High and paid $5000.

Fix

The report does not state what the application changed. The clear implication is that reset tokens should not be predictable identifiers such as V1 UUIDs; a random token (for example a V4 UUID or a cryptographically random value) removes the timestamp and MAC address that make the sandwich possible. Cryptographically random means random in a way that is designed to be unpredictable even to someone who knows how the generator works. Rate limiting on the reset endpoint would also reduce the feasibility of enumerating a range.

Variants to test

  1. Check the format of password reset tokens on other targets. A positive result is a token that decodes as a V1 UUID, with a timestamp and a stable Node ID across consecutive requests.
  2. Trigger two resets for your own account around a reset for a second account you control, then generate the UUIDs in between and fuzz the reset endpoint. A positive result is that the middle account's token is found within the range.
  3. Send a batch of reset requests (the author used 30) and compare Clock Sequence and Node ID values. A positive result is several distinct MAC addresses, which tells you how much the search space is multiplied.
  4. Look for other features that use UUIDs as unguessable values, such as invitation links, email verification links or API keys. A positive result is any such value that is a V1 UUID rather than a random one.
  5. Measure the gap between two consecutive self-issued tokens. A small gap means a small sandwich range and a practical brute force.

Glossary

  • Account takeover (ATO): logging in as another person and controlling their account.
  • API (Application Programming Interface): the part of a service that accepts requests from software rather than from a human clicking buttons.
  • Brute force: trying every possible value in turn until one works.
  • Bug bounty: a programme where a company pays outside testers for reporting real security problems.
  • Clock Sequence: one of the six sections of a V1 UUID; it stays the same across consecutive UUIDs from the same device.
  • Cryptographically random: random in a way designed to be unpredictable even to someone who knows how the generator works.
  • Endpoint: a specific address on a server that accepts a particular kind of request.
  • Epoch timestamp: the number of seconds since 1 January 1970, the way computers usually store a moment in time.
  • ffuf: an open-source fuzzing tool used to send many generated inputs to a system.
  • Fuzzing: sending lots of automatically generated inputs to a system to see which one gets a different, useful response.
  • Hexadecimal: a way of writing numbers using sixteen symbols (0 to 9 and A to F).
  • High: a severity rating used by bug bounty programmes for serious issues.
  • MAC address: a hardware fingerprint burned into a network card, used to identify a device on a network.
  • Node ID: the section of a V1 UUID that corresponds to the MAC address of the generating machine.
  • Open source: code published publicly so anyone can read and reuse it.
  • Password reset token: a long code sent by email that proves you are allowed to set a new password.
  • Rate limiting: a control that stops a client from making too many requests in a short time.
  • Ruby: a programming language.
  • Sandwich Attack: a technique where the attacker brackets a victim's token between two of their own, narrowing the search to a small time range.
  • Search space: the total number of possible values an attacker has to try.
  • Token: a short piece of text that stands in for proof that you are allowed to do something.
  • Unguessable: impossible or impractical for someone else to predict.
  • UUID (Universally Unique Identifier): a long identifier, usually written in hexadecimal, used to label things uniquely.
  • UUID Version 1 (V1): a UUID built from a timestamp and a MAC address, so it is predictable.
  • UUID Version 4 (V4): a UUID built from random numbers, so it is not predictable.
  • 0 Click: an attack that succeeds without the victim doing anything at all.

More by Roni Carta

View all

3 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.