Platform

Platform overview How it works Authorization testing Evidence & reports Private scanning Integrations

Solutions

Security agencies Product teams Regulated industries Partner programme

Learn

Blog Knowledge hub Compare

Resources

Pricing Documentation Help centre FAQ Security & data What we haven’t proved

Company

About Contact Careers Sign in to the platform Start a $199 pilot →

Home / Knowledge hub / Double spend

Knowledge hub

Double spend

Using the same balance, credit or voucher twice by acting faster than your checks.

Illustration explaining Double spend

What it means

A double spend means using the same balance, credit, voucher or token more than once. The application checks the balance, finds enough, and then deducts it. If two requests arrive at nearly the same moment, both may pass the check before either deduction is recorded.

The term began in digital currencies, but the flaw is ordinary in web apps. It is a race condition in a business rule: the gap between checking a value and changing it is long enough for a second request to slip through.

Why it matters

The cost is direct. A wallet balance spent twice, a gift voucher redeemed in two baskets, a withdrawal paid out twice, a free trial claimed in parallel. The business pays out more than it ever received, and no single transaction looks wrong on its own.

It is also hard to catch. Each request is valid alone, tests run one request at a time and never trigger it, and the shortfall appears later in the books. See time-of-check to time-of-use for the general class of flaw.

How it shows up

It appears wherever a limited thing is consumed: balances, credits, stock, coupon uses, invitations, one-time links, withdrawal limits. A request reads the value, decides, then writes. Under load, or on purpose, two requests interleave. The rule is correct in the code that checks it and wrong in the time it takes to apply it.

Make check and change a single atomic step: a conditional update in the database such as "deduct 50 only if the balance is at least 50", a lock on the row, or a transaction with the right isolation level. Add a unique key so a repeated payment cannot be recorded twice. Test by firing identical requests at once and examining the final balance.

Questions people ask

Double spend, answered

Is a double spend the same as a race condition?

It is a race condition with money, or a money-like value, at stake. Race conditions are the wider category and include non-financial cases.

The double spend is the version the finance team notices.

Does it only affect payments?

No. Anything limited can be spent twice: coupon redemptions, seats, stock, invitations, API credits, daily limits.

If a value should only be used once, it can be the target, so list those values and check each.

Why do normal tests miss it?

Because they send one request at a time. The bug needs two requests within a narrow window, which only appears with concurrency.

Tests must send simultaneous requests on purpose, which is why manual testing finds these more often than unit tests.

How do we prevent it?

Do the check and the update in one atomic database operation, or lock the record while you work. Use unique constraints and idempotency keys for payments.

Do not read, calculate in code and write back.

How do we know if it has happened?

Reconcile balances against the sum of transactions, and look for the same voucher or token used twice close together in time. Alert when totals do not match.

Logs with precise timestamps help reconstruct it.

Cyberlop mark

What if two requests arrive together?

We send simultaneous requests at balances, vouchers and limits to see whether a check can be beaten, and report only what we proved, with the requests and the resulting balance. Book a pilot on one app.

Or start with a $199 pilot on one application: thirty days, success criteria agreed before day one, credited against the annual if you convert.