Exploiting a Mass Assignment API Vulnerability
The checkout API accepted a hidden discount field that the frontend never sent, letting a user set their own discount to 100%. An attacker could then place an order for a product without paying.
medium.com
Published on medium.com
PortSwigger | Practitioner | API Testing Series ๐งจ Status: Lab PWNED ๐ Lab Link: Exploiting Mass Assignment Vulnerability
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the backend blindly accepted all fields from the JSON request body and applied them to the order object, without checking which fields the client was allowed to set.
Impact
An attacker could obtain products for free by setting their own discount to 100%.
What the attacker needed
A free account; ability to intercept HTTP requests
How it was found
- Log in with the provided credentials.
- Add the leather jacket to the cart and attempt to place an order.
- In Burp, find the POST /api/checkout request and send it to Repeater.
- Notice that a GET /api/checkout response includes a chosen_discount field not present in the POST body.
- Add a chosen_discount object with percentage set to 100 to the POST JSON body and send it.
- The order is confirmed and the lab is solved.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When a website sends data to its server, the server should only accept the fields it expects. Here, the server also accepted an extra field for a discount percentage, so a user could simply add that field and give themselves a free item.
What is IDOR?
One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.