Business-Logic-Vulnerability(Negative-Quantity-Manipulation-To-Checkout-Price-Manipulation)-In-Yii2-Ecommerce-Website-TheCodeholic

Yii2 E-commerce Website – Negative Quantity Manipulation Leading to Checkout Price Manipulation

Researcher: Maloy Roy Orko
Platform: Web Security Insights (WSI)
Discovery Date: 03 December 2026
CVE Number: Not assigned yet

Introduction

Hi All,

I am Maloy Roy Orko.

Recently, during one of my penetration testing research projects, I came across an open-source e-commerce application developed by TheCodeholic using the Yii2 PHP framework.

Curious to explore its functionalities and security implementation, I downloaded the source code and configured the application in my local Docker-based testing environment.

While performing Static Application Security Testing (SAST) and reviewing the application's cart management and checkout functionalities, I discovered a business logic vulnerability caused by insufficient server-side quantity validation.

The application accepts invalid negative product quantities and uses them during price calculations. Consequently, negative product subtotals can affect the overall checkout price and compromise the financial integrity of an order.

To validate my findings, I conducted dynamic security testing using PortSwigger Burp Suite Professional and independently examined the MySQL database records.

The results confirmed that the manipulated checkout price was also persisted in the database as a draft order.

In this article, I will discuss the vulnerability, its root cause, technical observations, supporting evidence, potential business impact and recommended remediation.

Vulnerability Information

AttributeDetails
Vulnerability TitleNegative Quantity Manipulation Leading to Checkout Price Manipulation
Vulnerability ClassBusiness Logic Vulnerability
Product NameYii2 E-commerce Website
VendorTheCodeholic
Programming LanguagePHP
FrameworkYii2
DatabaseMySQL
CWECWE-1284, CWE-20
Suggested SeverityMedium (Provisional)
AuthenticationAuthenticated test account used
Verification StatusConfirmed in local testing
CVE StatusNot assigned

Vendor:

https://github.com/thecodeholic

Vulnerable Product:

https://github.com/thecodeholic/yii2-ecommerce-website

Inspected Commit Reference:

11e6f2c1b010a67c28f9c46e5df951d9c5aea07d

The commit reference was identified from the inspected source archive. The complete affected version range has not yet been independently established.

Technical Details and Description

The application does not adequately validate product quantities on the server before updating cart records and calculating product prices.

The quantity validation rules do not enforce an appropriate positive minimum value. Consequently, invalid quantities can be accepted, stored and included in subsequent financial calculations.

The vulnerability affects multiple stages of the application:

Shopping cart management.
Product quantity validation.
Cart subtotal calculation.
Checkout price calculation.
Draft order creation.
Database integrity.

The underlying issue is not a weakness in the Yii2 framework itself. Rather, it originates from the application's implementation of input validation and business logic.

Testing Environment

The following tools and technologies were used during the security assessment:

Kali Linux.
VMware Workstation.
PortSwigger Burp Suite Professional.
Docker and Docker Compose.
MySQL.
PHP and Yii2.
Firefox.

All testing was conducted within a researcher-controlled environment using synthetic accounts and products.

Observation and Technical Analysis

1. Source Code Analysis

During the initial SAST assessment, I identified several source files associated with cart management, quantity validation and order creation.

Affected source-code locations:

FileLinesObservation
frontend/controllers/CartController.php137–166Insufficient quantity range validation
common/models/CartItem.php124–132Missing positive quantity constraint
common/models/CartItem.php47–65Quantity-dependent price calculation
common/models/OrderItem.php33–43Insufficient quantity validation
frontend/controllers/CartController.php168–195Draft order creation workflow

The reviewed application logic calculates product subtotals using the product quantity and unit price.

The calculation itself is mathematically correct, but the application fails to ensure that the quantity represents a valid purchase.

This allows invalid cart data to propagate into the checkout workflow.

2. HTTP Request and Response Analysis

Using PortSwigger Burp Suite Professional, I examined the application's cart quantity update functionality.

The captured HTTP response confirmed that the server successfully processed an invalid quantity and returned a negative product subtotal.

Observed HTTP response status: HTTP/2 200 OK

Response content type: application/json

The response contained an invalid quantity and a corresponding negative price, demonstrating that the server had not rejected the invalid input.


Figure: Burp Suite request and response evidence, with session credentials and sensitive request details redacted

This observation confirmed that the issue was not limited to client-side presentation.

3. Negative Product Subtotal

Following the HTTP analysis, I examined the application's shopping cart interface.

The cart displayed a negative product quantity and a negative total price for a laboratory product.


Figure 02 – Shopping cart displaying an invalid negative quantity and subtotal.

This confirmed that invalid quantity information was reflected in the application's normal user interface.

4. Database Persistence Verification

To determine whether the vulnerability affected the backend database, I inspected the cart records using MySQL.

The database evidence confirmed that an invalid negative quantity had been persisted in the cart_items table.

The calculated database subtotal was consistent with the price displayed in the shopping cart.



Figure Screenshot 03 – MySQL database verification showing persisted invalid cart data.

This is an important observation because it demonstrates that the vulnerability affects stored application state rather than simply modifying the browser's displayed content.

5. Cross-Product Price Integrity Failure

Further controlled testing demonstrated that the incorrect subtotal of one product could affect the combined price of other products within the same shopping cart.

The application failed to independently validate each line item before calculating the combined amount.


Figure Screenshot 04 – Shopping cart containing valid and invalid product subtotals.

The resulting financial integrity failure was also confirmed through database inspection.

Figure Screenshot 05 – Database verification of multiple cart items and calculated subtotals.

6. Checkout Price Manipulation

After examining the shopping cart calculations, I investigated whether the incorrect amount would propagate into the checkout workflow.

The checkout page displayed the manipulated combined price instead of rejecting the invalid cart state.

Observed financial impact in the laboratory:

DescriptionAmount
Positive merchandise subtotal$75.00
Invalid subtotal adjustment−$45.00
Resulting checkout total$30.00
Difference$45.00
Reduction against positive merchandise subtotal60%

Figure Screenshot 06 – Checkout order summary showing the incorrect $30.00 total.

This confirmed that the vulnerability affected the checkout calculation as well as the shopping cart.

7. Draft Order Creation and Database Verification

The next objective was to determine whether the incorrect checkout amount was persisted as an order in the database.

I inspected the database records before and after draft order creation.

The resulting database evidence showed a newly created order with the same incorrect total that appeared in the checkout summary.

Observed order information:

Database FieldRecorded Value
Order ID3
Total Price$30.00
Status0 — Draft
Created By2



   

Figure Screenshot 07 – Database records showing the newly created draft order.

Figure Screenshot 08 – Final database verification of cart and order price integrity.

This observation confirmed that the manipulated financial amount was persisted in the backend order database.

However, a completed payment or successful fulfillment was not demonstrated.

Vulnerability Verification Summary

VerificationStatus
Static source-code analysisConfirmed in prior assessment
Root cause identificationConfirmed in prior assessment
Invalid quantity acceptanceConfirmed
Negative price calculationConfirmed
Cart database persistenceConfirmed
Cross-product price integrity failureConfirmed
Checkout price manipulationConfirmed
Draft order creationConfirmed
Manipulated order price persistenceConfirmed
Successful payment bypassNot demonstrated
Actual financial lossNot demonstrated

Root Cause Analysis

The vulnerability originates from insufficient enforcement of business rules throughout the cart and order processing lifecycle.

The primary root causes include:

Missing server-side positive quantity validation.
Insufficient quantity constraints in cart and order models.
Failure to independently validate cart items before checkout.
Financial calculations performed using invalid persisted quantities.
Insufficient integrity checks before draft order creation.

Client-side input restrictions alone are not sufficient to protect the application.

The server must independently verify that every submitted quantity complies with the application's business rules.

Potential Security and Business Impact

If an organization deploys this application without addressing the vulnerability, it may introduce significant business risks.

Potential consequences include:

Unauthorized manipulation of order prices.
Incorrect product subtotals.
Corrupted shopping cart records.
Incorrect financial information in the order database.
Potential revenue loss.
Accounting and reconciliation inconsistencies.
Potential inventory inconsistencies.
Damage to customer trust and business reputation.

The extent of actual financial damage would depend on the payment gateway implementation, order fulfillment process and downstream validation mechanisms.

Recommended Remediation

1. Implement Strict Server-Side Quantity Validation

Every product quantity should be validated as a positive integer and restricted to an appropriate inventory-aware maximum.

Invalid values must be rejected without modifying the existing cart.

2. Strengthen Yii2 Model Validation

The application should enforce quantity constraints within both the CartItem and OrderItem models.

For example, a defensive Yii2 validation rule could be implemented as follows:

[['quantity'], 'required'],
[['quantity'], 'integer', 'min' => 1],

An appropriate maximum quantity should also be enforced according to inventory availability and business requirements.

3. Revalidate Cart Items During Checkout

Before creating an order, the application should independently validate every cart item.

The checkout workflow must reject invalid cart records instead of incorporating them into the final price.

4. Perform Trusted Server-Side Price Calculations

Product prices must be obtained from trusted server-side records.

The final order amount should be recalculated only after all cart items have passed validation.

5. Validate Payment Integrity

The application should independently verify the following information against trusted order records:

Order identifier.
Expected payment amount.
Currency.
Payment transaction status.
Payment transaction authenticity.

Order fulfillment should occur only after successful payment verification.

6. Implement Database-Level Constraints

Where supported, enforce database constraints that prevent invalid product quantities from being persisted.

Application-level validation and database-level integrity controls should work together as defense-in-depth mechanisms.

7. Introduce Security Regression Testing

Developers should introduce automated tests covering invalid quantity types, out-of-range quantities, checkout validation failures and order integrity.

These tests should also confirm that rejected requests do not modify cart or order state.

Proof of Concept Evidence

The complete technical evidence is documented in the accompanying Web Security Insights vulnerability report.

The report contains:

Static source-code assessment.
Sanitized Burp Suite HTTP evidence.
JSON response observations.
Docker and MySQL database verification evidence.
Shopping cart screenshots.
Checkout screenshots.
Draft order database records.
Root cause analysis.
Remediation recommendations.

Technical Report: After CVE Publishing

Conclusion

The main objective of this research is to demonstrate how insufficient business logic validation can introduce serious security weaknesses in e-commerce applications, even when conventional security mechanisms are present.

Not every vulnerability requires SQL Injection, Cross-Site Scripting or Remote Code Execution to compromise an application's security.

Sometimes, a missing validation rule in a financial workflow is enough to undermine the integrity of an entire order.

Organizations, particularly those deploying open-source e-commerce templates without conducting security assessments, may unknowingly expose themselves to these risks.

Through this research, I hope to encourage developers and security researchers to pay greater attention to business logic vulnerabilities, server-side validation and financial integrity throughout the application lifecycle.

All testing was performed in a controlled environment for security research and responsible disclosure purposes.

References


Discovered and Researched By: Maloy Roy Orko

Maloy Roy Orko

I am Maloy Roy Orko. An aspiring security researcher. Learning New Fields and Strategies Since 2019. 💻

Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post