How Egor Homakov Generated Free Money on Starbucks Gift Cards
A race condition in Starbucks' gift card transfer feature allowed two concurrent transfer requests to both read the same source balance before either deduction was committed, so the destination card was credited twice. An attacker could generate spendable credit without paying for it.
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
Starbucks lets a customer register an account and link multiple physical gift cards to it. From that account you can check the balance of each linked card and transfer money from one card to another. It is the same shape of feature that appears on dozens of platforms handling any kind of balance: loyalty points, wallet credit, in-game currency. It is the same shape of feature that appears on dozens of platforms handling any kind of balance.
Egor Homakov, founder of Sakurity, found the bug in May 2015. His own account is at Hacking Starbucks for unlimited coffee. It is still the example most security courses reach for when race conditions come up.

Setup
The setup was cheap: three physical Starbucks cards, five dollars loaded onto each one, nine dollars total spent to test a theory.

No custom tooling was involved. The method was two separate browsers, both logged into the same account with two different session cookies, both pointed at the transfer endpoint, fired as close to simultaneously as he could manage by hand.
Finding it
The reasoning starts from how any system moves money, or any limited resource, between two places. It has to do three separate things in sequence:
- Check that the source actually has enough balance to cover the transfer.
- Move that amount to the destination.
- Subtract it from the source.
Those are three distinct steps, which means there is a gap of time, however small, between the first check and the final deduction. If the server can be made to start processing a second, identical transfer request before it has finished subtracting the balance from the first one, both requests can read the source card as having its original, undiminished balance at the exact same moment, and both can go on to credit the destination card in full. You pay for one transfer and get two.

Exploitation
Step 1: Prepare the cards
Three physical cards, five dollars on each.
Step 2: Open two sessions
Two separate browsers, logged into the same account with two different session cookies, both pointed at the transfer endpoint.
Step 3: Fire both transfers at once
Both requests ask to move the full five dollars from card A to card B, fired as close to simultaneously as possible by hand, so that both land inside the same narrow window before the first one's deduction has been written and committed.
Step 4: Repeat until the timing lines up
It did not work on the first try. By his own account it took five failed attempts before the timing lined up, and the sixth request was the one that landed both transfers inside the same window.
Step 5: Result
On that sixth attempt, card A, sitting at a five dollar balance, transferred its full five dollars to card B twice, concurrently. Card B ended up holding fifteen dollars instead of ten. Nine dollars spent on three physical cards had turned into real, spendable credit that was never actually paid for.
Root cause
The check-then-deduct sequence is not atomic. The balance check and the deduction are separate steps, so two concurrent requests can both pass the check against the same undiminished balance before either deduction is committed.
Impact
Nothing about the technique is limited to small amounts or a handful of cards. The same timing attack applied to larger transfers, repeated automatically rather than by hand across many accounts, could generate credit fast enough to be sold on for real money at a discount, entirely outside Starbucks' own books. A five-dollar card trick and a scripted, large-scale fraud operation are the same underlying bug; the only difference is whether anyone automated it before a defender noticed. The severity was never about the nine dollars spent to prove it.
Fix
The fix, once Starbucks engaged with it properly, took about ten days. The standard defences against this bug class:
- Lock the specific row being modified during the entire check-then-deduct sequence, so a second request has to wait its turn rather than reading stale data.
- Wrap the whole sequence in a single atomic database transaction, so the check and the deduction cannot be pulled apart by timing at all.
Neither is exotic engineering. The fix is usually simple once someone is forced to think about concurrent requests specifically, and the bug exists almost every time purely because nobody was forced to think about it until a researcher with two browser windows did it for them.
Variants to test
Any endpoint that checks a balance, a stock count, a usage limit, a redemption count, anything with a number that is allowed to go down, is worth testing with the exact same request fired twice at once rather than once in sequence. Sequential testing tells you the logic works; it never tells you whether the logic survives two people asking at the same time.
Concretely:
- Balance transfers. Send the same transfer request twice concurrently from two sessions. A positive result is the destination credited twice while the source is debited once.
- Redemption and coupon codes. Fire the same redeem request concurrently. A positive result is the value credited more than once for a single code.
- Stock or inventory decrement. Fire the same purchase or reservation request concurrently. A positive result is more units sold or reserved than exist.
- Usage limits and quotas. Fire the same quota-consuming request concurrently. A positive result is more usage recorded than the limit allows.
In each case, expect failures before success: the window is narrow, and repeated attempts are part of the method.
What happened, in plain words
Starbucks runs a website where you can create an account and attach physical gift cards to it. Once a card is attached, you can look up how much money is on it and move money from one card to another. This is the same kind of feature you see on lots of sites that hold a balance for you: loyalty points, wallet credit, in-game currency. This is the same kind of feature you see on dozens of platforms that hold a balance for you.
Egor Homakov, the founder of a security company called Sakurity, found a flaw in that transfer feature in May 2015. His own account of it is at Hacking Starbucks for unlimited coffee. It is still the example most security courses reach for when the topic of race conditions comes up.
A race condition is a bug where a system does two things at almost the same moment and gets confused about the order. A simple everyday comparison: two people reach into the same fridge at the same time, both see one carton of milk, and both take it. Each person checked first, and neither check saw the other. The result is two portions of milk from one carton.
What Homakov showed is that if you ask Starbucks to move the same five dollars twice at virtually the same instant, the system can pay out both times while only taking the money once. He spent nine dollars on three cards to prove it, and the proof turned into fifteen dollars of spendable credit that was never actually paid for.

Setup
The setup was cheap: three physical Starbucks cards, five dollars loaded onto each one, nine dollars total spent to test a theory.

No custom tooling was involved. The method was two separate browsers, both logged into the same account with two different session cookies, both pointed at the transfer endpoint, fired as close to simultaneously as he could manage by hand.
A few of those words need unpacking if you have never done this kind of testing.
- A session cookie is a small piece of text your browser stores after you log in. The website hands it to your browser, your browser sends it back with every request, and that is how the site knows which account is asking. If you log in on two different browsers, each one gets its own cookie, and the site treats them as two separate logged-in visitors, even though both belong to the same person.
- An endpoint is simply the address on the server that a particular action is sent to. When you click a button that moves money, your browser sends a request to a specific address, and that address is the endpoint. You do not need to know its exact name to follow the story; what matters is that both browsers were pointed at the same one.
- A request is the message your browser sends to the server: "please move five dollars from card A to card B". The server reads it, does the work, and sends back a response.
Why two browsers rather than one? Because a single browser tab tends to send one request and wait for the answer before doing anything else. Two separate browsers, each with its own cookie, let him press the button in both at nearly the same moment, so the server receives two requests almost together instead of one after the other. That near-simultaneity is the whole point of the exercise.
Finding it
The reasoning starts from how any system moves money, or any limited resource, between two places. It has to do three separate things in sequence:
- Check that the source actually has enough balance to cover the transfer.
- Move that amount to the destination.
- Subtract it from the source.
Those are three distinct steps, which means there is a gap of time, however small, between the first check and the final deduction. If the server can be made to start processing a second, identical transfer request before it has finished subtracting the balance from the first one, both requests can read the source card as having its original, undiminished balance at the exact same moment, and both can go on to credit the destination card in full. You pay for one transfer and get two.
Think of a shop assistant who checks the till, walks to the safe to fetch the money, and only then writes down that the till is lighter. If a second customer asks during that walk, the assistant checks the till again, still sees the full amount, and hands out a second payout. The bookkeeping catches up too late.

Exploitation
Step 1: Prepare the cards
Three physical cards, five dollars on each.
Why three cards and not two? The report does not explain the third card's role in the test. What it does say is that the total outlay was nine dollars, and that the proof produced fifteen dollars of credit on card B.
Step 2: Open two sessions
Two separate browsers, logged into the same account with two different session cookies, both pointed at the transfer endpoint.
This step exists purely to get two requests into flight at once. If you used one browser window and clicked, waited, then clicked again, the server would finish the first transfer completely before the second arrived, and the second would correctly see a reduced balance. Two sessions remove that natural pause.
Step 3: Fire both transfers at once
Both requests ask to move the full five dollars from card A to card B, fired as close to simultaneously as possible by hand, so that both land inside the same narrow window before the first one's deduction has been written and committed.
"Committed" means the change has been permanently saved. Until the deduction is saved, the server's record of card A still shows five dollars, and any request that reads the balance in that moment sees five dollars too.
Step 4: Repeat until the timing lines up
It did not work on the first try. By his own account it took five failed attempts before the timing lined up, and the sixth request was the one that landed both transfers inside the same window.
This is the part beginners most often skip past. The window between the check and the deduction is tiny, and pressing two buttons by hand is imprecise. Most attempts will miss. The method is not a single clever click; it is the same action repeated until the timing happens to fall right. Expecting failure is part of the technique, not a sign you are doing it wrong.
Step 5: Result
On that sixth attempt, card A, sitting at a five dollar balance, transferred its full five dollars to card B twice, concurrently. Card B ended up holding fifteen dollars instead of ten. Nine dollars spent on three physical cards had turned into real, spendable credit that was never actually paid for.
The arithmetic is worth spelling out. Card B started with five dollars of its own. Two transfers of five dollars arrived, so it should have ended at fifteen only if both were genuinely paid for. But card A only ever had five dollars to give, and it was only debited once. The extra five dollars on card B came from nowhere: it was created by the bug.
Root cause
The check-then-deduct sequence is not atomic. The balance check and the deduction are separate steps, so two concurrent requests can both pass the check against the same undiminished balance before either deduction is committed.
"Atomic" means all-or-nothing, indivisible. An atomic sequence cannot be interrupted halfway; either the whole thing happens or none of it does. "Serialise" means forcing requests to take turns, one finishing before the next begins. The Starbucks code did neither: it checked, then deducted, with a gap in between, and it allowed two requests to be in that gap together.
Impact
Nothing about the technique is limited to small amounts or a handful of cards. The same timing attack applied to larger transfers, repeated automatically rather than by hand across many accounts, could generate credit fast enough to be sold on for real money at a discount, entirely outside Starbucks' own books. A five-dollar card trick and a scripted, large-scale fraud operation are the same underlying bug; the only difference is whether anyone automated it before a defender noticed. The severity was never about the nine dollars spent to prove it.
"Automated" here means writing a small program to send the two requests at the right moment, over and over, instead of pressing buttons by hand. A program can hit the narrow window far more reliably than a person, and can do it across many accounts. That is why a fifteen-dollar demonstration matters: it is a sample of a much larger possible loss.
Fix
The fix, once Starbucks engaged with it properly, took about ten days. The standard defences against this bug class:
- Lock the specific row being modified during the entire check-then-deduct sequence, so a second request has to wait its turn rather than reading stale data.
- Wrap the whole sequence in a single atomic database transaction, so the check and the deduction cannot be pulled apart by timing at all.
A database row is one record in the site's storage, in this case the record holding a card's balance. "Locking" it means marking it as in use so that a second request must queue behind the first. "Stale data" means information that was true a moment ago but is no longer. The second defence is the all-or-nothing approach: the check and the deduction become one indivisible step, so there is no gap for a second request to slip into.
Neither is exotic engineering. The fix is usually simple once someone is forced to think about concurrent requests specifically, and the bug exists almost every time purely because nobody was forced to think about it until a researcher with two browser windows did it for them.
Variants to test
Any endpoint that checks a balance, a stock count, a usage limit, a redemption count, anything with a number that is allowed to go down, is worth testing with the exact same request fired twice at once rather than once in sequence. Sequential testing tells you the logic works; it never tells you whether the logic survives two people asking at the same time.
Concretely:
- Balance transfers. Send the same transfer request twice concurrently from two sessions. A positive result is the destination credited twice while the source is debited once.
- Redemption and coupon codes. Fire the same redeem request concurrently. A positive result is the value credited more than once for a single code.
- Stock or inventory decrement. Fire the same purchase or reservation request concurrently. A positive result is more units sold or reserved than exist.
- Usage limits and quotas. Fire the same quota-consuming request concurrently. A positive result is more usage recorded than the limit allows.
In each case, expect failures before success: the window is narrow, and repeated attempts are part of the method.
Glossary
- Account: a login on a website that holds your information and, in this case, your linked gift cards.
- Atomic: all-or-nothing; a step that cannot be interrupted or split in half.
- Automated: carried out by a program rather than by a person clicking.
- Balance: the amount of money or credit currently held on a card or account.
- Bug bounty: a scheme where companies pay researchers for reporting security flaws.
- Committed: permanently saved; a change that has been written to storage and will not be undone by a later step.
- Concurrent: happening at the same time rather than one after another.
- Cookie (session cookie): a small piece of text a site gives your browser after login, sent back with each request so the site knows who you are.
- Database row: one record in a site's storage, such as the record holding a single card's balance.
- Debit: to subtract money from a balance.
- Credit (verb): to add money to a balance.
- Endpoint: the specific address on a server that a particular action is sent to.
- Gift card: a physical or digital card holding a prepaid balance.
- Lock (a row): to mark a record as in use so other requests must wait their turn.
- Race condition: a bug where two actions happening at almost the same moment interfere, so the system produces a result that neither action alone would cause.
- Request: the message a browser sends to a server asking it to do something.
- Response: the message a server sends back after handling a request.
- Root cause: the underlying reason a bug exists, as opposed to its visible symptom.
- Serialise: to force actions to take turns, one finishing before the next starts.
- Session: a logged-in visit to a site, identified by a cookie.
- Stale data: information that was accurate earlier but is out of date now.
- Transaction (database): a group of changes treated as one unit, so either all of them are saved or none are.
- Transfer: moving an amount from one balance to another.
- Vulnerability: a weakness in a system that lets someone make it behave in a way its owners did not intend.