CWE-565: Reliance on Cookies without Validation and Integrity Checking

Description

The product relies on the existence or values of cookies when performing security-critical operations, but it does not properly ensure that the setting is valid for the associated user.

Submission Date :

July 19, 2006, midnight

Modification Date :

2023-10-26 00:00:00+00:00

Organization :

MITRE
Extended Description

Attackers can easily modify cookies, within the browser or by implementing the client-side code outside of the browser. Reliance on cookies without detailed validation and integrity checking can allow attackers to bypass authentication, conduct injection attacks such as SQL injection and cross-site scripting, or otherwise modify inputs in unexpected ways.

Example Vulnerable Codes

Example - 1

The following code excerpt reads a value from a browser cookie to determine the role of the user.



userRole = c.getValue();Cookie c = cookies[i];if (c.getName().equals("role")) {}Cookie[] cookies = request.getCookies();for (int i =0; i< cookies.length; i++) {}

It is easy for an attacker to modify the "role" value found in the locally stored cookie, allowing privilege escalation.

Related Weaknesses

This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined to give an overview of the different insight to similar items that may exist at higher and lower levels of abstraction.

Visit http://cwe.mitre.org/ for more details.