Frontend Calculation Manipulation
Client-side price manipulation vulnerabilities and the critical importance of server-side validation.
Overview
Frontend calculation manipulation occurs when applications perform sensitive calculations like pricing, discounts, or totals in the browser. Attackers can modify these calculations by manipulating JavaScript code, intercepting requests, or using browser developer tools.
Affected: E-commerce, Financial Applications
Impact: Price manipulation, unauthorized discounts
CVSS: 6.5 (Medium)
The Vulnerability
Many web applications calculate final prices, discounts, and totals in the browser using JavaScript. While this provides a smooth user experience, it creates a critical security flaw. Attackers can easily modify these calculations using browser developer tools, browser extensions, or by intercepting and modifying requests.
Technical Details
The vulnerable application calculated discounts client-side and sent the final discounted price to the server. The server accepted this price without recalculating or validating that the discount was legitimate.
Attack Scenario
- User adds items to cart (total: $100)
- Attacker opens browser developer tools
- Modifies JavaScript to apply 90% discount instead of 10%
- Or intercepts request and changes finalPrice from $90 to $10
- Server accepts manipulated price without validation
Real-World Examples
- Discount Abuse: Attackers apply multiple discounts or modify discount percentages
- Price Override: Changing the price parameter in API requests
- Currency Manipulation: Switching currency values to pay less
- Quantity Manipulation: Negative quantities or fractional quantities
- Fee Bypass: Removing shipping fees or taxes
Root Cause
- Trusting client-side calculations for financial transactions
- Lack of server-side validation and recalculation
- Accepting price parameters from the client without verification
- Not using server-side session to track cart state
Remediation
- NEVER trust client-side calculations for pricing, discounts, or totals
- Always recalculate all financial values on the server
- Store cart state server-side, not just in the browser
- Validate discount codes and amounts server-side
- Use signed or encrypted parameters for sensitive data
- Implement rate limiting and fraud detection
Timeline
- August 2023: Vulnerability discovered in multiple platforms
- September 2023: Coordinated disclosure
- October 2023: Patches implemented
- November 2023: Public release of research