Skip to content
Business logic Write-up Intermediate

Insecure comparison in PHP — Business Logic Bypass vulnerability

The application compared the creator and approver identifiers as loosely typed values, so a decimal approver identifier was judged different from the creator's integer identifier but then rounded to the same user. An attacker could therefore select themselves as approver and approve their own object, bypassing the business rule.

Marcin Szydlowski Follow

Published on infosecwriteups.com

I have recently spotted an interesting vulnerability in a PHP application, which was in scope of a private bug bounty program. This vulnerability has nothing to do with standard web app issues like SQLi, XSS or IDOR, hence despite relatively small impact I decided to write couple of paragraphs about it.

Marcin Szydlowski, 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.

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 PHP code used loose comparison (==) on user-supplied identifiers before casting or rounding them to integers, so a float value passed the inequality check but resolved to the same user.

Impact

The creator could set themselves as approver and approve their own object, completely bypassing the business logic; the report notes the bounty was small due to limited business impact.

What the attacker needed

Ability to create objects; ability to intercept and modify requests

How it was found

  1. Create an object and note the creator identifier sent in the POST request.
  2. Modify the approver identifier in the request to a decimal value close to the creator identifier.
  3. Observe that the application accepts it and rounds the approver identifier to a user.
  4. Send a request with the creator identifier equal to the rounded approver identifier.
  5. Observe that the object is saved with both values the same and no error is returned.

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.

The site tried to stop you approving your own item by checking that your user number and the approver's user number are different. But it compared the numbers in a loose way, so a decimal like 200.9 looked different from 201, even though the site then rounded it to 201. That let the same person be both creator and approver.

What is Business logic?

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

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.