1285
Effectiveness = High
Potential Mitigations
Phase: Architecture and Design
Avoid using cookie data for a security-related decision.
Phase: Implementation
Perform thorough input validation (i.e.: server side validation) on the cookie data if you're going to
use it for a security related decision.
Phase: Architecture and Design
Add integrity checks to detect tampering.
Phase: Architecture and Design
Protect critical cookies from replay attacks, since cross-site scripting or other attacks may
allow attackers to steal a strongly-encrypted cookie that also passes integrity checks. This
mitigation applies to cookies that should only be valid during a single transaction or session. By
enforcing timeouts, you may limit the scope of an attack. As part of your integrity check, use an
unpredictable, server-side value that is not exposed to the client.
Demonstrative Examples
Example 1:
The following code excerpt reads a value from a browser cookie to determine the role of the user.
Example Language: Java (Bad)
Cookie[] cookies = request.getCookies();
for (int i =0; i< cookies.length; i++) {
Cookie c = cookies[i];
if (c.getName().equals("role")) {
userRole = c.getValue();
}
}
It is easy for an attacker to modify the "role" value found in the locally stored cookie, allowing
privilege escalation.
Observed Examples
Reference Description
CVE-2008-5784 e-dating application allows admin privileges by setting the admin cookie to 1.
https://www.cve.org/CVERecord?id=CVE-2008-5784
MemberOf Relationships
This MemberOf relationships table shows additional CWE Catgeories and Views that reference this
weakness as a member. This information is often useful in understanding where a weakness fits
within the context of external information sources.
Nature Type ID Name Page
MemberOf 949 SFP Secondary Cluster: Faulty Endpoint Authentication 888 2395
MemberOf 1354 OWASP Top Ten 2021 Category A08:2021 - Software
and Data Integrity Failures
1344 2495
MemberOf 1403 Comprehensive Categorization: Exposed Resource 1400 2528
Notes
Relationship
This problem can be primary to many types of weaknesses in web applications. A developer may
perform proper validation against URL parameters while assuming that attackers cannot modify
CWE Version 4.14
CWE-566: Authorization Bypass Through User-Controlled SQL Primary Key
CWE-566: Authorization Bypass Through User-Controlled SQL Primary Key