Overview
This vulnerability occurs when an application relies on client-side controls (e.g., JavaScript validation, hidden form fields, disabled buttons, client-side permission checks) to enforce security rules, rather than performing authoritative checks on the server-side. Attackers can easily bypass client-side controls by modifying the HTML/JavaScript in their browser, intercepting and modifying requests with a proxy (like Burp Suite), or crafting raw HTTP requests directly to the server. 💻➡️🧍♂️➡️🔥Business Impact
Relying on client-side security leads to critical vulnerabilities:- Authorization Bypass: Attackers can modify hidden fields or JavaScript checks to gain access to functions or data intended for administrators or other users.
- Data Tampering: Prices in shopping carts, target account numbers for transfers, or user roles can be modified before submission, leading to fraud or unauthorized changes.
- Input Validation Bypass: Constraints enforced only by JavaScript (e.g., length limits, character restrictions) can be bypassed, leading to injection attacks or data corruption if the server doesn’t re-validate.
Reference Details
CWE ID: CWE-602
OWASP Top 10 (2021): A04:2021 - Insecure Design
Severity: High to Critical
Framework-Specific Analysis and Remediation
This is a fundamental design flaw, independent of specific frameworks, although frameworks provide the tools for server-side validation which must be used. Client-side validation is useful for improving user experience (providing immediate feedback) but must never be the only line of defense. Key Remediation Principles:- Duplicate Validation: Perform all critical validation checks (type, format, range, business rules) on the server, even if they are already done on the client.
- Server Authority: Base security decisions (permissions, pricing, targets) only on trusted server-side data (e.g., user session, database records), not on hidden fields or parameters submitted by the client.
- Secure Session Management: Store sensitive user state (like role, ID) securely in server-side sessions or signed/encrypted tokens, not in client-modifiable locations.
- Python
- Java
- .NET(C#)
- PHP
- Node.js
- Ruby
Framework Context
Relying on JavaScript form validation or hidden fields in HTML forms without equivalent checks in Django views/forms or Flask routes.Vulnerable Scenario 1: Hidden Price Field
A shopping cart form uses a hidden field for the item price, validated only by JavaScript.Vulnerable Scenario 2: Client-Side Admin Check
JavaScript hides an admin button, but the server endpoint doesn’t re-verify admin privileges.Mitigation and Best Practices
- Prices/Critical Data: Always retrieve prices, product details, and permissions from the server-side (database) based on the item ID or user session after submission. Do not trust values in hidden fields.
- Permissions: Re-validate user roles and permissions on the server for every sensitive action. Use framework decorators (
@permission_required,@user_passes_test, DRFpermission_classes = [IsAdminUser]).
Secure Code Example
Testing Strategy
Use browser developer tools or an intercepting proxy (like Burp Suite) to modify client-side data before it’s submitted: change values in hidden fields (prices, user IDs, roles), re-enable disabled buttons, removereadonly attributes, modify JavaScript variables influencing submission. Check if the server accepts and processes the manipulated data or if it correctly rejects/ignores it based on server-side validation and state.
