At a glance
- Controls
- CWE-1284
What it is
A cart, order or usage record takes a quantity from the request. The server trusts the number and multiplies it by the price. A negative value then produces a negative line total, which cuts the amount owed.
An attacker edits one request and sets the quantity below zero, or pairs a negative line with a normal one so the total lands near zero. AI-assisted tools try boundary values on every numeric field by default, so this gap is found quickly.
Where it hides
What a reviewer can look for in the code and in the behaviour, before anyone proves it.
- Add-to-cart and update-cart endpoints
- Usage reporting APIs that feed metered billing
- Invoice line-item and quote builders
- Seat or licence count changes on a subscription
How MATT tests it
The proof runs against the deployed product, on every release, whoever wrote the code.
- 01Sign in with the test account and build a normal order or invoice.
- 02Resend the line-item request with a negative quantity and with zero.
- 03Compare the computed total with the expected total and record the response.
Quantities must be validated on the server as positive and within plan limits.
Executable checkas test user: POST /v1/cart/items {"sku": "X", "quantity": -5} expect: 400 or 422 expect: cart total unchanged as test user: POST /v1/cart/items {"sku": "X", "quantity": 100000} expect: 400 or 422 when above the plan limit
Every rule MATT holds →What the fix looks like
- 01
Validate every quantity on the server as a positive integer.
- 02
Apply an upper bound from the plan or product limits.
- 03
Reject the whole request when any line fails validation.
- 04
Recompute totals on the server and refuse any total below zero.
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? →