Excessive trust in client-side controls

1 min read Easy Portswigger
Business Logic
Contents

On this page

The lab

here is how portswigger describes it

This lab doesn't adequately validate user input. You can exploit a logic flaw in its purchasing workflow to buy items for an unintended price. To solve the lab, buy a "Lightweight l33t leather jacket". You can log in to your own account using the following credentials: wiener:peter

the shop sends the item's price from the client when you add it to the cart, and the server trusts that value instead of looking the price up itself. so the price is just another parameter we control. we intercept the add-to-cart request, rewrite the price to whatever we like, and the server charges that, letting us buy the jacket for far less than our store credit.

why trusting the client breaks this#

anything the browser sends can be changed before it arrives, so a price that travels in the request is attacker-controlled, not a fact. the server should treat the client's price as untrusted and re-derive it from the product id against its own catalogue. here it does not, it takes the submitted price at face value and bills it, so the client is effectively setting its own prices. this is the whole family of "excessive trust in client-side controls", the security decision is being made on data the client owns.

Step 1 - confirm the normal block#

we log in and try to buy the leather jacket. the order is rejected because we do not have enough store credit, so the price matters and there is something to bypass.

1

Step 2 - Find the price parameter#

in Proxy > HTTP history we study the order process and notice that adding an item to the cart sends a request containing a price parameter. we send the POST /cart request to Repeater.

2

Step 3 - Tamper with the price#

we change price to an arbitrary small integer and send the request.

3

Step 4 - Confirm the cart updated#

we refresh the cart and confirm the price has changed based on our input, so the server accepted our value.

4

Step 5 - Complete the order#

with the jacket now within our store credit we complete the order.

5

with this, the lab is solved!