Skip to content
Business logic Write-up Beginner

Break the Logic: Playing with product ratings on a shopping site(600$)

The product rating endpoint accepted arbitrary numeric values for the star rating and the yes/no question, allowing a user to submit ratings far outside the intended range. An attacker could manipulate product ratings, potentially affecting the site's rating system.

Fırat Follow

Published on infosecwriteups.com

Bounty$600 View original

As it’s a private program, i’ll refer to it as “redacted”. Let me give you some information about the program before we start.

Fırat, on infosecwriteups.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. 4 min read.

Context

The target was a private bug bounty program, referred to throughout as "redacted". The main application was a beverage shopping site. It had memberships, packages and profiles for every user, and product pages that carried two kinds of rating.

The first rating was a single question: "Would you buy this again?" A yes answer was submitted as yesOrNo:5, a no answer as YesOrNo:1. The second was a star rating, where the user picks how many hearts to give out of five, submitted in the sliderRating field. Both values travel in the JSON body of the rating request.

midjourney ai bot / discord From the original on infosecwriteups.com

Setup

The report describes no special tooling. The work was manual: reading the site, learning every feature, then testing individual pages and requests. The rating request carries a session cookie and a CSRF token.

Finding it

While going through the product page, the researcher noticed that a beverage could be rated without actually buying it.

The first idea was to abuse the yes/no question with a race condition, sending a value of 1 to the yesOrNo field. That did not work.

The second idea was to push the star rating outside its intended range. Changing sliderRating to 150 was accepted by the server, and the value was reflected both on the front end and in the API.

Exploitation

Step 1: capture the rating request

The rating action is a JSON POST to the product rating endpoint:

HTTP
POST /customer/product/product-rating.json HTTP/2Host: www.xxxx.comCookie: xxxContent-Length: 81Sec-Ch-Ua: " Not A;Brand";v="99", "Chromium";v="102", "Google Chrome";v="102"Content-Type: application/jsonX-Csrf-Token: xxxxxSec-Ch-Ua-Mobile: ?0User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[redacted] Safari/537.36Sec-Ch-Ua-Platform: "Windows"Accept: */*Origin: xxxSec-Fetch-Site: same-originSec-Fetch-Mode: corsSec-Fetch-Dest: emptyReferer: https://www.xxx.com/products/xxxAccept-Encoding: gzip, deflateAccept-Language: en-US,en;q=0.9,tr;q=0.8{"comment":"","productId":27044,"yesOrNo":5,"sliderRating":5,"favourite":false}

The body carries the product identifier (productId), the yes/no answer (yesOrNo), the star value (sliderRating) and a favourite flag. The request is authenticated by the session cookie and protected by an X-Csrf-Token header, so the token has to be kept valid when replaying it.

Step 2: try the yes/no field

The first attempt was a race condition against the yesOrNo question, sending a value of 1. This did not work.

Step 3: push the star rating out of range

The second attempt changed sliderRating to 150. The server accepted it and returned it in the response:

HTTP
HTTP/2 200 OKDate: Sat, 25 Jun 2022 19:54:16 GMTContent-Type: application/json;charset=UTF-8Cache-Control: no-cache, no-store, max-age=0, must-revalidateContent-Security-Policy: Expires: 0Pragma: no-cacheStrict-Transport-Security: max-age=31536000X-Content-Type-Options: nosniffX-Content-Type-Options: nosniffX-Frame-Options: SAMEORIGINX-Xss-Protection: 1; mode=blockExpect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"{"rating":{"id":113062722,"rating":150.0,"sliderRating":600.0,........}

The response shows the manipulated value stored and returned: rating is 150.0 and sliderRating is 600.0. The value was displayed as 150 on the front end as well as in the API. The researcher also states that both the star rating and the yes/no question could be manipulated.

Root cause

The server accepted a sliderRating of 150, outside the intended 1 to 5 range, and stored it. The program accepted the finding as a business logic error. The report does not describe the server-side code.

Impact

A logged-in customer could submit a rating without buying the product, and could set the star value far above the intended maximum, with the manipulated value shown on the front end and returned by the API. The researcher expected the report to be closed as informative because it might not affect the reputation of the ratings, but the program's response was positive: it was affecting the ratings and was accepted as a business logic error. The researcher notes that it was not a security issue. The report does not quantify how many products or users could be affected.

Fix

The report does not state what was changed.

Variants to test

  1. Send a negative or zero sliderRating and check whether the API stores and returns it.
  2. Send a very large integer or a decimal value and check whether it is accepted and reflected on the front end.
  3. Send a string or null in place of the numeric field and check whether the server coerces or rejects it.
  4. Submit a rating for a product the account has not purchased and check whether the rating is stored.
  5. Replay the rating request with a different productId and check whether the rating is applied to that product.
  6. Try the same out-of-range values on the yes/no field and check whether the server accepts values other than the expected ones.

A positive result in each case is a 200 response that stores and returns the manipulated value, and a front end that displays 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. 12 min read.

What happened, in plain words

A security researcher spent time on a shopping website that sells drinks. The site was part of a private bug bounty programme, which means the company invited selected researchers to test it and paid for useful findings. In the write-up the site is called "redacted" because the programme is private.

The site had memberships, packages and profiles for every user, and every product page had a rating feature. You could answer a question, "Would you buy this again?", and you could give a star rating out of five hearts.

The researcher found that the website let a logged-in customer rate a drink without ever buying it, and that the star value could be pushed far beyond five. The server accepted a star rating of 150 and showed it both on the page and in the data the page fetches. The company accepted the report as a business logic error.

This article walks through the same steps for someone who has never done security testing: what the site did, what was sent, and why each attempt was made.

The target and the setup

The main application was a beverage shopping site. It had memberships, packages and profiles for every user, and product pages that carried two kinds of rating.

The first rating was a single question: "Would you buy this again?" A yes answer was submitted as yesOrNo:5, a no answer as YesOrNo:1. The second was a star rating, where the user picks how many hearts to give out of five, submitted in the sliderRating field. Both values travel in the JSON body of the rating request.

midjourney ai bot / discord From the original on infosecwriteups.com

A JSON body is the part of a web request that carries data, written in a format that looks like a shopping list of names and values: "name": value. When you click a star on a page, your browser packages your choice into such a body and sends it to the server.

The report describes no special tooling. The work was manual: reading the site, learning every feature, then testing individual pages and requests. The rating request carries a session cookie and a CSRF token.

A session cookie is a small piece of text your browser stores after you log in and sends back with every request, so the server knows who you are. A CSRF token is a second, secret value the page includes in forms and requests to prove the request really came from the site's own pages and not from some other website trying to act on your behalf. Both have to be valid for the rating request to be accepted.

Finding it

While going through the product page, the researcher noticed that a beverage could be rated without actually buying it.

Think of a restaurant review site that lets anyone leave a review for a meal they never ate. Nothing crashes, no password is stolen, but the reviews stop meaning what they are supposed to mean. This kind of problem is called a business logic flaw: the software works exactly as programmed, but the rules of the business are not enforced.

The first idea was to abuse the yes/no question with a race condition, sending a value of 1 to the yesOrNo field. That did not work.

A race condition means sending several requests at almost the same moment, hoping the server handles them in an order it did not expect, for example counting two answers before it has finished recording the first. The researcher tried this against the yes/no question, sending the value 1, and it did not work.

The second idea was to push the star rating outside its intended range. Changing sliderRating to 150 was accepted by the server, and the value was reflected both on the front end and in the API.

An API is the part of a website that answers requests with data rather than with a page. When the product page needs to show the current rating, it asks the API, and the API replies with the numbers. "Reflected" means the value the researcher sent came back unchanged, both in the data and in what the page displayed.

Exploitation

Step 1: capture the rating request

The rating action is a JSON POST to the product rating endpoint:

HTTP
POST /customer/product/product-rating.json HTTP/2Host: www.xxxx.comCookie: xxxContent-Length: 81Sec-Ch-Ua: " Not A;Brand";v="99", "Chromium";v="102", "Google Chrome";v="102"Content-Type: application/jsonX-Csrf-Token: xxxxxSec-Ch-Ua-Mobile: ?0User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[redacted] Safari/537.36Sec-Ch-Ua-Platform: "Windows"Accept: */*Origin: xxxSec-Fetch-Site: same-originSec-Fetch-Mode: corsSec-Fetch-Dest: emptyReferer: https://www.xxx.com/products/xxxAccept-Encoding: gzip, deflateAccept-Language: en-US,en;q=0.9,tr;q=0.8{"comment":"","productId":27044,"yesOrNo":5,"sliderRating":5,"favourite":false}

Line by line, in plain words:

  • POST /customer/product/product-rating.json HTTP/2 is the request line. POST means "I am sending data to the server". The path /customer/product/product-rating.json is the address of the rating feature, and .json tells you the answer will come back as data rather than as a web page. HTTP/2 is the version of the language the browser and server use to talk.
  • Host: www.xxxx.com names the website being contacted. The real name is hidden in the write-up.
  • Cookie: xxx is where the session cookie would appear. It is the value that proves the request comes from a logged-in customer. It is hidden here.
  • Content-Length: 81 says how many bytes of data follow the blank line, so the server knows where the body ends.
  • Sec-Ch-Ua, Sec-Ch-Ua-Mobile, Sec-Ch-Ua-Platform and User-Agent describe the browser and operating system. Browsers send them automatically; they are not part of the attack.
  • Content-Type: application/json announces that the body is JSON, the name/value format described earlier.
  • X-Csrf-Token: xxxxx is the CSRF token, the secret value that proves the request came from the site's own page. It is hidden here.
  • Accept: */* says the browser will accept any kind of answer.
  • Origin: xxx and Referer: https://www.xxx.com/products/xxx tell the server which page the request came from. Both are hidden or shortened here.
  • Sec-Fetch-Site, Sec-Fetch-Mode and Sec-Fetch-Dest are extra browser hints about the context of the request.
  • Accept-Encoding and Accept-Language say which compression and which languages the browser understands.
  • The last line is the body: {"comment":"","productId":27044,"yesOrNo":5,"sliderRating":5,"favourite":false}. comment is empty, productId identifies which drink is being rated, yesOrNo is the answer to "Would you buy this again?" (5 for yes), sliderRating is the star value (5 out of 5), and favourite is a true/false flag.

The body carries the product identifier (productId), the yes/no answer (yesOrNo), the star value (sliderRating) and a favourite flag. The request is authenticated by the session cookie and protected by an X-Csrf-Token header, so the token has to be kept valid when replaying it.

Why this step matters: to test a feature you first need to see exactly what your browser sends when you use it normally. Once you have that, you can change one value at a time and watch what the server does.

Step 2: try the yes/no field

The first attempt was a race condition against the yesOrNo question, sending a value of 1. This did not work.

The researcher tried a race condition against the yes/no question, sending a value of 1, and it did not work. It did not, and the researcher moved on.

Step 3: push the star rating out of range

The second attempt changed sliderRating to 150. The server accepted it and returned it in the response:

HTTP
HTTP/2 200 OKDate: Sat, 25 Jun 2022 19:54:16 GMTContent-Type: application/json;charset=UTF-8Cache-Control: no-cache, no-store, max-age=0, must-revalidateContent-Security-Policy: Expires: 0Pragma: no-cacheStrict-Transport-Security: max-age=31536000X-Content-Type-Options: nosniffX-Content-Type-Options: nosniffX-Frame-Options: SAMEORIGINX-Xss-Protection: 1; mode=blockExpect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"{"rating":{"id":113062722,"rating":150.0,"sliderRating":600.0,........}

Line by line, in plain words:

  • HTTP/2 200 OK is the status line. 200 OK means the server accepted the request and processed it without complaint.
  • Date: Sat, 25 Jun 2022 19:54:16 GMT is when the server answered.
  • Content-Type: application/json;charset=UTF-8 says the answer is JSON data.
  • Cache-Control, Expires and Pragma are instructions about caching, meaning whether browsers or proxies may keep a copy of the answer.
  • Content-Security-Policy, Strict-Transport-Security, X-Content-Type-Options, X-Frame-Options and X-Xss-Protection are security headers. They tell the browser how to behave when displaying the site. They are normal on many sites and are not what was bypassed here.
  • Expect-Ct is another security header, related to certificates.
  • The last line is the body: {"rating":{"id":113062722,"rating":150.0,"sliderRating":600.0,........}. The server stored the rating under an id, and returned rating as 150.0 and sliderRating as 600.0. The dots at the end stand for further fields the write-up does not show.

The response shows the manipulated value stored and returned: rating is 150.0 and sliderRating is 600.0. The value was displayed as 150 on the front end as well as in the API. The researcher also states that both the star rating and the yes/no question could be manipulated.

Why this step matters: the page only offers five hearts, but the page is just a picture. The real decision is made by the server, and the server was never told to check that the number it receives is between 1 and 5. Sending 150 is like writing "150 out of 5" on a paper form that has no box for it: if nobody checks the form, the number goes straight into the records.

Root cause

The server accepted a sliderRating of 150, outside the intended 1 to 5 range, and stored it. The program accepted the finding as a business logic error. The report does not describe the server-side code.

In everyday terms: the door lock worked fine, the person walking through it was a real customer, but nobody at the desk checked whether the number on the form made sense.

Impact

A logged-in customer could submit a rating without buying the product, and could set the star value far above the intended maximum, with the manipulated value shown on the front end and returned by the API. The researcher expected the report to be closed as informative because it might not affect the reputation of the ratings, but the program's response was positive: it was affecting the ratings and was accepted as a business logic error. The researcher notes that it was not a security issue. The report does not quantify how many products or users could be affected.

"Closed as informative" is a common outcome in bug bounty programmes: the report is read, but the company decides it is not a problem worth fixing or paying for. Here the opposite happened, and the report was accepted.

Fix

"Server-side validation" simply means the server itself checks the value, instead of trusting the page to only offer sensible choices.

Variants to test

If you want to look for the same kind of problem on a site you are allowed to test, these are some follow-up checks:

  1. Send a negative or zero sliderRating and check whether the API stores and returns it.
  2. Send a very large integer or a decimal value and check whether it is accepted and reflected on the front end.
  3. Send a string or null in place of the numeric field and check whether the server coerces or rejects it.
  4. Submit a rating for a product the account has not purchased and check whether the rating is stored.
  5. Replay the rating request with a different productId and check whether the rating is applied to that product.
  6. Try the same out-of-range values on the yes/no field and check whether the server accepts values other than the expected ones.

A positive result in each case is a 200 response that stores and returns the manipulated value, and a front end that displays it.

Glossary

  • Bug bounty programme: an arrangement where a company invites researchers to test its systems and pays for useful findings.
  • Private programme: a bug bounty programme open only to selected researchers, not to the public.
  • Business logic flaw: a problem where the software works as programmed but does not enforce the rules of the business, such as allowing a rating without a purchase.
  • Parameter tampering: changing a value in a request, such as a number or an identifier, to something the page did not intend to offer.
  • API: the part of a website that answers requests with data rather than with a web page.
  • Endpoint: the address of a specific feature on a server, such as the rating path in the request above.
  • Request: the message your browser sends to a server asking it to do something.
  • Response: the message the server sends back.
  • POST: an HTTP method meaning "I am sending data to the server".
  • HTTP/2: a version of the language browsers and servers use to exchange requests and responses.
  • Header: a line in a request or response carrying information about it, such as the content type or a cookie.
  • Body: the part of a request or response that carries the actual data.
  • JSON: a text format for data made of names and values, such as "sliderRating":5.
  • Cookie: a small piece of text a browser stores and sends back with requests, often used to keep you logged in.
  • Session cookie: the cookie that identifies your logged-in session to the server.
  • CSRF token: a secret value included in requests to prove they came from the site's own pages, not from another website.
  • User-Agent: a header describing the browser and operating system making the request.
  • Origin / Referer: headers telling the server which page a request came from.
  • Status code: the number at the start of a response, such as 200, saying how the request went. 200 means success.
  • Front end: the part of the site you see and interact with in the browser.
  • Server-side validation: checking a value on the server, rather than trusting the page to send only sensible values.
  • Race condition: sending several requests at nearly the same moment, hoping the server handles them in an unexpected order.
  • Reflected: a value you sent coming back unchanged in the response or on the page.
  • Informative: a bug bounty outcome where the report is read but judged not worth fixing or paying for.
  • Bounty: the money a programme pays for an accepted report.
  • Impact: what an attacker could actually do with a finding, and how much it matters.

More by Fırat

View all

4 more disclosed reports, best first.

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.