CWE-1284Spend & resource abuseSeverity · High

Negative quantities on an invoice

Quantity fields that accept negative numbers let a customer lower their own bill. One edited request can turn a charge into a credit or a free order.

At a glance

Controls
CWE-1284
Typical severityHigh
ReferenceCWE-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.

  1. 01Sign in with the test account and build a normal order or invoice.
  2. 02Resend the line-item request with a negative quantity and with zero.
  3. 03Compare the computed total with the expected total and record the response.
The rule, in plain English

Quantities must be validated on the server as positive and within plan limits.

Executable check

as 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

  1. 01

    Validate every quantity on the server as a positive integer.

  2. 02

    Apply an upper bound from the plan or product limits.

  3. 03

    Reject the whole request when any line fails validation.

  4. 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? →

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