Skip to content
Business logic Write-up Beginner

One more Parameter manipulation bug (πŸ€‘)

A shopping site accepted a negative quantity for a cart item, so the item's line total became negative and reduced the overall order total. By adding a cheap product with a negative quantity alongside a normal product, an attacker could pay only the difference between the two prices.

Kanchan Singh Yadav Follow

Published on medium.com

#### Kanchan Singh Yadav

Kanchan Singh Yadav, on medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

This is a write-up about parameter tampering, specifically price and quantity manipulation, on an online shop selling shoes and other wearables. The researcher had found a parameter manipulation issue on one website and then checked a similar website for the same class of bug.

The feature under test is the normal purchase flow: choose a product, select the right size, add it to the cart, and check out. The parameters exchanged between client and server during that flow (price, product id, quantity, cart id) are what the researcher manipulated.

The definition quoted in the report is OWASP's:

The Web Parameter Tampering attack is based on the manipulation of parameters exchanged between client and server in order to modify application data, such as user credentials and permissions, price and quantity of products, etc. Usually, this information is stored in cookies, hidden form fields, or URL Query Strings, and is used to increase application functionality and control.

In plain terms, you alter the parameters and watch how the application reacts. The goal here was to reduce the price of a product, to order more than one product for the price of a single one, or to get a product at the price of a cheaper one.

Image for post
money!! From the original on medium.com

Setup

The only tool named in the report is Burp Suite, used to intercept and modify the requests the shop sends when items are added to the cart. No account details, roles or versions are given. The precondition is simply a working storefront with a cart and a checkout, and the ability to intercept traffic between the browser and the server.

Before touching anything, the researcher walked the normal workflow. Everything behaved as expected, with no errors.

Image for post
Website Developer! From the original on medium.com

Finding it

Price manipulation is often described as a thing of the past, since most organisations dealt with it long ago, and the researcher expected the same. This site turned out to be different. After selecting a product and the correct size, clicking add to cart produced a request that Burp Suite could capture, and that request carried the price and quantity as client-supplied parameters.

Image for post
burp From the original on medium.com

Exploitation

Step 1: change the price in the add-to-cart request

The request sent when clicking add to cart is shown in the report as an image. The researcher's conclusion on seeing it was that the price could be changed directly.

Changing the price had no effect: the value was not reflected in the cart. That indicates the site fetches the price from the product id server-side, so there is no point in changing the product id either, because that would simply change the price to that of the other product.

Image for post
yes!! From the original on medium.com

Step 2: send a negative quantity

The remaining parameter is quantity. The researcher set it to negative (-1), and the price in the cart became negative.

Image for post
good! From the original on medium.com

In principle that means the company pays the researcher that amount and ships the product as well. In practice, clicking checkout produced an error page instead.

Image for post
No!! From the original on medium.com

Step 3: abuse the cart id to get a fresh cart

While trying other things, the researcher learned that the cart id can be changed: there is no check on it, so new carts can be created freely. Until then, every add, delete or change required manually reversing the steps, clearing cookies or opening a private window to obtain a new cart. Adding a random value to the cart id now returned an empty cart.

Image for post
idea!!! From the original on medium.com

Step 4: combine a normal product with a negative-quantity cheaper product

The idea was to add one product normally and a second product, cheaper than the first, with quantity set to negative (-1). It worked: the total price became the difference between the two prices.

Image for post
Image for post From the original on medium.com
Image for post
Image for post

The arithmetic behind it, as stated in the report:

total=pof-pos _______________(equation 1)*condition

where pof=price of first product, pos=price of the second product

*condition:- equation 1 will only hold true when the total is greater than 0 (total>0) because if your total price is negative(total<0) the process will fail.

So the total must stay positive for checkout to proceed; a negative total fails, which is why the single negative-quantity item was rejected and the mixed cart was not.

Root cause

The report states the problem plainly: the website handled user-inputted data by taking it directly and multiplying it by the product price.

total_price=price*quantity

The site does check whether the total is negative or positive before the payment section, but that check can be abused to reduce the price of the product. The price itself is taken from the product id server-side, so the price parameter is not the weak point; quantity is, because a negative quantity subtracts from the total. The cart id can be changed because there is no check on it, which allowed fresh carts to be created.

Impact

An attacker can lower the amount paid for an order by pairing a normal product with a cheaper product at a negative quantity, as long as the resulting total stays above zero. The report does not describe any further consequences, and the negative-total route to being paid by the company was blocked at checkout.

Fix

The report does not say what the site changed.

Variants to test

  1. Negative or zero quantity on any add-to-cart or cart-update endpoint. A positive result is a cart line or total that decreases, or a checkout that accepts a total below the sum of the items.
  2. Mixed carts: one item at normal quantity and a cheaper item at a negative quantity. A positive result is a total equal to the difference of the two prices, with checkout still proceeding.
  3. Price parameter in the add-to-cart body. A positive result is a cart line whose price differs from the catalogue price.
  4. Product id substitution. A positive result is a cart line priced as a cheaper product than the one selected.
  5. Cart id random values. A positive result is a new, empty cart.
  6. Boundary totals: keep the total just above zero. A positive result is a checkout that completes for a token amount.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 9 min read.

What happened, in plain words

This is a story about an online shop that sells shoes and other wearables. The shop had a flaw in the way it handled the numbers a browser sends when you put something in your basket. By changing one of those numbers, the researcher could make the shop charge less than it should, and in one arrangement could even make the total come out as the difference between two products.

The class of bug is called parameter tampering. A parameter is just a named value that a browser sends to a website, for example price=100 or quantity=1. Normally the website is supposed to decide these values itself, or at least check them. If it trusts whatever the browser sends, a person can edit the value before it reaches the server and change what the shop does.

The report quotes OWASP's definition:

The Web Parameter Tampering attack is based on the manipulation of parameters exchanged between client and server in order to modify application data, such as user credentials and permissions, price and quantity of products, etc. Usually, this information is stored in cookies, hidden form fields, or URL Query Strings, and is used to increase application functionality and control.

In everyday terms: you change the numbers the browser sends and watch what the shop does with them. The goal in this report was to pay less for a product, to get more than one product for the price of one, or to get an expensive product at the price of a cheaper one.

Image for post
money!! From the original on medium.com

The picture is captioned "money!!" and sets the theme: this is about the price and quantity fields.

Price or quantity manipulation sounds technical, but the report puts it in simple English: a hacker tries to change a parameter value so as to reduce the price of a product, order more than one product for the price of a single one, or get a product at the price of another, cheaper product.

Price manipulation is often called a thing of the past. Most organisations dealt with it long ago, and most authors and hackers say it is rarely possible to find one any more. The researcher believed the same, but this particular website had something else in store.

Image for post
Website Developer! From the original on medium.com

The image is captioned "Website Developer!" and sits right after the remark that this site was different.

The setup

One day, after finding a parameter manipulation issue on one website, the researcher checked a similar website for the same kind of bug. This second site sold shoes and other wearables.

First, the researcher walked through the normal workflow: pick a product, choose the right size, add it to the cart, go to checkout. Everything worked as expected, with no errors. This step matters because you cannot tell what is unusual until you know what normal looks like. It is like walking through a shop once before you start looking for the loose floorboard.

Then the researcher brought in the tool: Burp Suite.

Image for post
burp From the original on medium.com

The image is captioned "burp". Burp Suite is a program that sits between your browser and a website. Instead of your browser talking straight to the shop, it talks to Burp, and Burp passes the message on. That lets you read every request and change it before it is sent. Think of it as a postal worker who lets you open each letter, rewrite a line, and seal it again before delivery.

The researcher was only looking for parameter manipulation, so other kinds of issues were ignored on purpose.

Finding it

On this shop, after selecting a product you have to select the right size, and then click add to cart. When that button was clicked, Burp Suite captured the request the browser sent to the server.

The image is captioned "request to server". It shows the captured add-to-cart request, but the report presents it only as a picture, so the exact field names and values are not written out in the text. What matters is the researcher's reaction on seeing it: the price could be changed as simply as that, and the job would be done.

Image for post
yes!! From the original on medium.com

The image is captioned "yes!!".

But it was not that simple. After changing the price, the change was not reflected in the cart. That tells us something important about how the shop works: it does not use the price the browser sends. It takes the product id (the number that identifies which product you picked) and looks up the price on its own side. So changing the price parameter does nothing, and there is no point changing the product id either, because that would just switch the cart to a different product with that product's own price.

So the researcher moved to the other parameter available: quantity, the number of items. It was changed to negative one (-1), and the price in the cart became negative.

Image for post
good! From the original on medium.com

The image is captioned "good!".

A negative price in the cart means, in principle, that the company would pay the researcher that amount and give the product as well. The report calls this killing two birds with one stone. But when the researcher clicked checkout, the shop responded with an error page instead.

Image for post
No!! From the original on medium.com

The second image is captioned "No!!". So the researcher was stuck again: the negative total was refused at checkout.

Working around the checkout block

While trying other things and getting nowhere, the researcher learned something useful along the way: the cart id can be changed. A cart id is the label the shop uses to know which shopping cart belongs to which visitor. There was no check on it, so new carts could be created freely.

Until then, every time the researcher added, deleted or changed something, the only way to get a fresh cart was to manually reverse the steps, clear the browser's cookies, or open a private window. Clearing the browser's cookies was one way to get a fresh cart. That was slow. Now, simply adding a random value to the cart id produced an empty cart.

Image for post
idea!!! From the original on medium.com

The image is captioned "idea!!!".

After thinking for a while, an idea came: add one product normally, and add a second product that is cheaper than the first, but with its quantity set to negative one (-1). It worked. The total price became the difference between the two prices.

Image for post
Image for post From the original on medium.com
Image for post
Image for post

The two images show the resulting cart and total.

The report explains the arithmetic with a small equation:

total=pof-pos _______________(equation 1)*condition

where pof=price of first product, pos=price of the second product

*condition:- equation 1 will only hold true when the total is greater than 0 (total>0) because if your total price is negative(total<0) the process will fail.

In plain words: the total equals the price of the first product minus the price of the second. That only holds while the total stays above zero. If the total goes negative, the checkout fails, which is exactly why the single negative-quantity item was rejected and the mixed cart was not. The shop does check whether the total is negative or positive before the payment section, but that check can be abused to reduce the price of the product.

Why it worked

The report states the root cause plainly: the website handled user-inputted data by taking it directly and multiplying it by the product price.

total_price=price*quantity

Read that line as the shop's rule for working out a line total: take the price, multiply by the quantity. If quantity is a normal positive number, the line adds to the bill. If quantity is negative, the multiplication produces a negative line total, which subtracts from the bill. The shop multiplied the quantity directly by the price, and only checked whether the total was negative before payment.

The price itself is not the weak point, because it is looked up from the product id on the server side. Quantity is the weak point, because a negative quantity subtracts. The cart id is likewise accepted without validation, which is what allowed fresh carts to be created at will.

What an attacker could do

An attacker can lower the amount paid for an order by pairing a normal product with a cheaper product at a negative quantity, as long as the resulting total stays above zero. The report does not describe any further consequences, and the route where the company would owe the researcher money was blocked at checkout.

How it should be fixed

The report does not say what the site changed.

Things worth trying on other shops

  1. Negative or zero quantity on any add-to-cart or cart-update request. A positive result is a cart line or total that goes down, or a checkout that accepts a total below the sum of the items.
  2. Mixed carts: one item at normal quantity and a cheaper item at a negative quantity. A positive result is a total equal to the difference of the two prices, with checkout still going through.
  3. A price parameter in the add-to-cart request body. A positive result is a cart line whose price differs from the catalogue price.
  4. Swapping the product id. A positive result is a cart line priced as a cheaper product than the one selected.
  5. Randomising the cart id. A positive result is a new, empty cart.
  6. Boundary totals: keep the total just above zero. A positive result is a checkout that completes for a token amount.

Lesson learnt

Even if there is the rarest of the rarest possibility for something, do check it. It may have a 0.01% probability for everyone else, but if you find it, you have turned that 0.01% into 100%.

Glossary

  • Parameter: a named value sent from the browser to a website, such as price, quantity or cart id.
  • Parameter tampering: changing those values before they reach the server, to make the application behave differently from what it intended.
  • Price manipulation: a form of parameter tampering where the price of a product is altered to pay less.
  • Quantity manipulation: a form of parameter tampering where the number of items is altered, for example to a negative number, so the line total subtracts from the bill.
  • OWASP: an organisation that publishes guidance and definitions about web application security; the report quotes its definition of parameter tampering.
  • Client and server: the client is your browser; the server is the computer that runs the shop and holds the real data.
  • Request: the message your browser sends to the server, for example when you click add to cart.
  • Response: the message the server sends back, such as the updated cart page.
  • Burp Suite: a tool that sits between browser and server so you can read and edit requests before they are sent.
  • Intercept: to catch a request in Burp Suite and hold it so you can change it.
  • Cookie: a small piece of data a website stores in your browser to remember you between pages, often holding things like a cart id.
  • Cart: the basket of items you intend to buy.
  • Cart id: the label the shop uses to identify which cart belongs to which visitor.
  • Product id: the number that identifies which product you selected; the shop uses it to look up the real price.
  • Checkout: the final step where the shop totals the cart and takes payment.
  • Total price: the sum the shop asks you to pay for everything in the cart.
  • Negative quantity: a quantity below zero, such as -1, which in a multiplication makes the line total negative.
  • Root cause: the underlying reason the bug exists, here trusting a quantity sent by the browser and multiplying it by the price.
  • Server-side validation: checking values on the server rather than trusting what the browser sends.
  • Private window: a browser mode that starts without your usual cookies, giving you a fresh session.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.