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
| Attribute | Details |
|---|---|
| Vulnerability Title | Negative Quantity Manipulation Leading to Checkout Price Manipulation |
| Vulnerability Class | Business Logic Vulnerability |
| Product Name | Yii2 E-commerce Website |
| Vendor | TheCodeholic |
| Programming Language | PHP |
| Framework | Yii2 |
| Database | MySQL |
| CWE | CWE-1284, CWE-20 |
| Suggested Severity | Medium (Provisional) |
| Authentication | Authenticated test account used |
| Verification Status | Confirmed in local testing |
| CVE Status | Not 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:
| File | Lines | Observation |
|---|---|---|
frontend/controllers/CartController.php | 137–166 | Insufficient quantity range validation |
common/models/CartItem.php | 124–132 | Missing positive quantity constraint |
common/models/CartItem.php | 47–65 | Quantity-dependent price calculation |
common/models/OrderItem.php | 33–43 | Insufficient quantity validation |
frontend/controllers/CartController.php | 168–195 | Draft 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.
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:
| Description | Amount |
|---|---|
| Positive merchandise subtotal | $75.00 |
| Invalid subtotal adjustment | −$45.00 |
| Resulting checkout total | $30.00 |
| Difference | $45.00 |
| Reduction against positive merchandise subtotal | 60% |
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 Field | Recorded Value |
|---|---|
| Order ID | 3 |
| Total Price | $30.00 |
| Status | 0 — Draft |
| Created By | 2 |
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
| Verification | Status |
|---|---|
| Static source-code analysis | Confirmed in prior assessment |
| Root cause identification | Confirmed in prior assessment |
| Invalid quantity acceptance | Confirmed |
| Negative price calculation | Confirmed |
| Cart database persistence | Confirmed |
| Cross-product price integrity failure | Confirmed |
| Checkout price manipulation | Confirmed |
| Draft order creation | Confirmed |
| Manipulated order price persistence | Confirmed |
| Successful payment bypass | Not demonstrated |
| Actual financial loss | Not 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
Affected Product: https://github.com/thecodeholic/yii2-ecommerce-website
Vendor: https://github.com/thecodeholic
CWE-1284 — Improper Validation of Specified Quantity: https://cwe.mitre.org/data/definitions/1284.html
CWE-20 — Improper Input Validation: https://cwe.mitre.org/data/definitions/20.html
PortSwigger — Business Logic Vulnerabilities: https://portswigger.net/web-security/logic-flaws
OWASP — Input Validation Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Input_Validation_Cheat_Sheet.html
Discovered and Researched By: Maloy Roy Orko








