Security weakness
CWE-642 External Control of Critical State Data
A class-level weakness that can lead to private data exposed, downtime and lost sales and accounts and admin areas exposed. Here is what it is, what it can cost you and how to close it.
- Senior security engineers
- 540+ projects delivered
- Reply within one business day
Quick answer
What is CWE-642?
External Control of Critical State Data: The product stores security-critical state information about its users, or the product itself, in a location that is accessible to unauthorized actors.
Business impact
What CWE-642 could cost your business
MITRE documents what this weakness can do. Here is what that means for a website, store or app.
Confidentiality
Private data exposed
Customer records, credentials, orders or internal files can be read by people who should never see them.
- Read Application Data
Availability
Downtime and lost sales
Crashes, slowdowns or exhausted resources can take your site, store or app offline.
- DoS: Crash, Exit, or Restart
Access Control
Accounts and admin areas exposed
Logins and permission checks can be bypassed, putting admin and customer accounts at risk.
- Bypass Protection Mechanism
- Gain Privileges or Assume Identity
Free security check
Is CWE-642 hiding in your site?
A senior engineer checks your site, store or app for this weakness and the rest of the CWE Top 25, then sends a prioritized fix plan within one business day. No obligation.
Official definition
How MITRE defines CWE-642
External Control of Critical State Data
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.
Prevention
How to fix CWE-642, phase by phase
Every mitigation from the CWE entry, in the order a project runs: plan, build, test, operate.
- 01
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.
- 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.
- 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.
Show 2 more recommendations
- 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.
- 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.
- 02
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.
Detection and evidence
How CWE-642 is found, and where it has hit
The testing methods MITRE recommends, and real vulnerabilities this weakness has caused.
How it is detected
- Automated Static AnalysisAutomated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then.
- FuzzingUse dynamic tools and techniques that interact with the product using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The product’s operation may slow down, but it should not become unstable, crash, or generate incorrect results.
- Manual Dynamic AnalysisUse tools and techniques that require manual (human) analysis, such as penetration testing, threat modeling, and interactive tools that allow the tester to record and modify an active session. These may be more effective than strictly automated techniques. This is especially the case with weaknesses.
Real vulnerabilities it caused
- CVE-2005-2428Mail client stores password hashes for unrelated accounts in a hidden form field.
- CVE-2008-0306Privileged program trusts user-specified environment variable to modify critical configuration settings.
- CVE-1999-0073Telnet daemon allows remote clients to specify critical environment variables for the server, leading to code execution.
- CVE-2007-4432Untrusted search path vulnerability through modified LD_LIBRARY_PATH environment variable.
- CVE-2006-7191Untrusted search path vulnerability through modified LD_LIBRARY_PATH environment variable.
- CVE-2008-5738Calendar application allows bypass of authentication by setting a certain cookie value to 1.
How we fix it
From finding to fixed: how Codefreex closes CWE-642
- 01
Scan and confirm
We test your site, store or app for this weakness and the rest of the CWE Top 25 with automated scanning and manual review, and confirm what is actually exploitable.
- 02
Fix at the source
We change the code, configuration or dependency that causes it, not just the symptom, and plan the changes to avoid downtime.
- 03
Verify the fix
We retest every finding, check that nothing else broke and hand you a short report you can share with your team, client or auditor.
- 04
Keep it fixed
Updates, monitoring and maintenance so the weakness does not return with the next plugin, theme, app or code change.
Website SecurityPenetration TestingMalware Removal & Hack RepairWordPress Maintenance
Related weaknesses
Weaknesses related to CWE-642
FAQ
CWE-642: FAQs
Short answers for owners and developers. Not sure whether your site is affected? Ask us to check.
What is CWE-642?
CWE-642, “External Control of Critical State Data”, is a software weakness catalogued by MITRE in the Common Weakness Enumeration. The product stores security-critical state information about its users, or the product itself, in a location that is accessible to unauthorized actors.
How serious is CWE-642?
MITRE rates the likelihood of exploit as High. It can affect access control, confidentiality, availability, with impacts such as bypass protection mechanism, gain privileges or assume identity, read application data. The real risk depends on where the weakness sits and what data or functions it exposes.
How do you prevent CWE-642?
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. 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.
Can Codefreex check my site for CWE-642?
Yes. A senior engineer reviews your site, store or app for CWE-642 and the rest of the CWE Top 25, confirms what is exploitable and sends a prioritized fix plan within one business day. Start with the free security check form on this page.
Which technologies does CWE-642 affect?
MITRE lists it as applicable to Web Server. In practice any software that matches the weakness description can be affected, including custom code, plugins, themes and third-party libraries.
Free security check
Find out if CWE-642 affects your site
Send your URL. A senior engineer checks for this weakness and the rest of the CWE Top 25, and replies within one business day with what to fix first.
- A senior strategist reviews your request, not a sales bot
- Clear scope, timeline and estimate within one business day
- Free 30-minute discovery call, no obligation
- NDA available on request
- Emailhello@codefreex.com
- CallUSA +1 (209) 375-3475 · India +91 790 3375 530
- Prefer to talk?Book a 30-minute call
Weakness data from the Common Weakness Enumeration (CWE®) version 5.0, Copyright © 2006–2026, The MITRE Corporation. CWE is free to use by any organization or individual for any research, development, and/or commercial purposes under the CWE Terms of Use. CWE is a registered trademark of The MITRE Corporation. The business impact, risk profile and plain-English guidance on this page are written by Codefreex and are general information, not a security assessment of your system.