CWE-362Spend & resource abuseSeverity · High

The same refund twice

When two refund requests arrive at the same moment, both can pass the balance check. The account is then credited twice for one refund or payout.

At a glance

Controls
CWE-362
Typical severityHigh
ReferenceCWE-362

What it is

A refund flow reads the balance, checks it, then writes the credit. If two requests run between the read and the write, both see the same starting state. Each one passes and each one pays.

An attacker sends many identical requests in a single burst to hit that small window. AI-assisted tooling can script and time these bursts with little effort, so race windows are tested far more often than before.

Where it hides

What a reviewer can look for in the code and in the behaviour, before anyone proves it.

  • Refund and cancellation endpoints
  • Payout and withdrawal requests
  • Credit, voucher and gift card redemption
  • Background jobs that settle pending refunds

How MATT tests it

The proof runs against the deployed product, on every release, whoever wrote the code.

  1. 01Sign in with the test account and place a test-mode order that can be refunded.
  2. 02Send several identical refund requests for that order at the same moment.
  3. 03Check the order and account ledger to count how many credits were applied.
The rule, in plain English

A refund, payout or credit must be applied exactly once.

Executable check

as test user: send 10 parallel POST /v1/orders/{id}/refund expect: at most one 200 expect: the others return 409 or the same refund id expect: exactly one refund entry in the ledger for the order

Every rule MATT holds →

What the fix looks like

  1. 01

    Require an idempotency key on every refund, payout and credit request.

  2. 02

    Lock the order or balance row during the check and the write.

  3. 03

    Add a unique constraint so one order can hold only one refund of each kind.

  4. 04

    Reconcile the ledger daily and alert on duplicate credits.

A check that was never written is found by proving the deployed behaviour, fixed with the engineer who shipped it, and kept fixed by running the control on every change. What is ExploitOps? →

ExploitOps discovery call

Understand where your security loop breaks.

A call with a MATT co-founder to understand your product and whether an ExploitOps Review is worth doing. If there is a real need, we scope one with the research team.

Let’s understand your priority

What brings you to MATT?

What would you like help with?
01 / 02