CWE WEAKNESSES / CWE-642
CWE-642
External Control of Critical State Data
What it is
The product stores security-critical state information about its users, or the product itself, in a location that is accessible to unauthorized actors.
If an attacker can modify the state information without detection, then it could be used to perform unauthorized actions or access unexpected resources, since the application programmer does not expect that the state can be changed.State information can be stored in various locations such as a cookie, in a hidden web form field, input parameter or argument, an environment variable, a database record, within a settings file, etc. All of these locations have the potential to be modified by an attacker. When this state information is used to control security or determine resource usage, then it may create a vulnerability. For example, an application may perform authentication, then save the state in an "authenticated=true" cookie. An attacker may simply create this cookie in order to bypass the authentication.
Impact
| Access Control | Bypass Protection Mechanism, Gain Privileges or Assume Identity |
| Confidentiality | Read Application Data |
| Availability | DoS: Crash, Exit, or Restart |
Mitigations
- [Architecture and Design] Understand all the potential locations that are accessible to attackers. For example, some programmers assume that cookies and hidden form fields cannot be modified by an attacker, or they may not consider that environment variables can be modified before a privileged program is invoked.
- [Architecture and Design]Store state information and sensitive data on the server side only.Ensure that the system definitively and unambiguously keeps track of its own state and user state and has rules defined for legitimate state transitions. Do not allow any application user to affect state directly in any way other than through legitimate actions leading to state transitions.If information must be stored on t
- [Architecture and Design] Store state information on the server side only. Ensure that the system definitively and unambiguously keeps track of its own state and user state and has rules defined for legitimate state transitions. Do not allow any application user to affect state directly in any way other than through legitimate actions leading to state transitions.
- [Architecture and Design]Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482].With a stateless protocol such as HTTP, use some frameworks can maintain the state for you.Examples include ASP.NET View State and the OWASP ESAPI Session Management feature.Be careful of language features that provide state support, sinc
- [Architecture and Design] For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
- [Operation, Implementation] When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.
Real-world CVE examples
- CVE-2005-2428 — Mail client stores password hashes for unrelated accounts in a hidden form field.
- CVE-2008-0306 — Privileged program trusts user-specified environment variable to modify critical configuration settings.
- CVE-1999-0073 — Telnet daemon allows remote clients to specify critical environment variables for the server, leading to code execution.
- CVE-2007-4432 — Untrusted search path vulnerability through modified LD_LIBRARY_PATH environment variable.
- CVE-2006-7191 — Untrusted search path vulnerability through modified LD_LIBRARY_PATH environment variable.
- CVE-2008-5738 — Calendar application allows bypass of authentication by setting a certain cookie value to 1.
- CVE-2008-5642 — Setting of a language preference in a cookie enables path traversal attack.
- CVE-2008-5125 — Application allows admin privileges by setting a cookie value to "admin."
- CVE-2008-5065 — Application allows admin privileges by setting a cookie value to "admin."
- CVE-2008-4752 — Application allows admin privileges by setting a cookie value to "admin."
- CVE-2000-0102 — Shopping cart allows price modification via hidden form field.
- CVE-2000-0253 — Shopping cart allows price modification via hidden form field.
Related weaknesses
Browse all common weaknesses, check related exploited CVEs, or map to ATT&CK techniques.
Source: MITRE CWE. View on cwe.mitre.org →