What is CWE-665?
The product fails to initialize a resource correctly, leaving it in an unexpected state when the resource is accessed or used.
The product fails to initialize a resource correctly, leaving it in an unexpected state when the resource is accessed or used.
The product does not initialize or incorrectly initializes a resource, which might leave the resource in an unexpected state when it is accessed or used.
This can have security implications when the associated resource is expected to have certain properties or values, such as a variable that determines whether a user has been authenticated or not.
An uninitialized resource may contain leftover or indeterminate data while the program assumes that it has safe, valid properties. This is especially significant when the resource is an authentication state, access-control flag, reused memory, array index, pointer, or handler. The weakness can arise on rare error paths, when complex control flow skips initialization, or when another thread accesses the resource before initialization is complete.
This weakness occurs when a variable, resource, or data region is accessed before it has a valid state, or when initialization occurs only on some control-flow paths. Rarely exercised paths, especially error handling and exception paths, are common locations for the problem. The resulting behavior depends on the residual or unintended value, which may be interpreted as a security decision, an index, a pointer, a function handler, or data sent to an external party.
Potential impacts include disclosure of residual memory or application data when reused resources are exposed to an untrusted party. If a security-critical decision depends on a value being zero or equivalent, an unintended value can bypass a protection mechanism. Unexpected values can also alter program flow, causing crashes, exits, restarts, incorrect results, memory corruption, or code execution in representative cases.
| Impact | Scope | Explanation |
|---|---|---|
| Read Memory, Read Application Data | Confidentiality | When reusing a resource such as memory or a program variable, the original contents of that resource may not be cleared before it is sent to an untrusted party. |
| Bypass Protection Mechanism | Access Control | If security-critical decisions rely on a variable having a "0" or equivalent value, and the programming language performs this initialization on behalf of the programmer, then a bypass of security may occur. |
| DoS: Crash, Exit, or Restart | Availability | The uninitialized data may contain values that cause program flow to change in ways that the programmer did not intend. For example, if an uninitialized variable is used as an array index in C, then its previous contents may produce an index that is outside the range of the array, possibly causing a crash or an exit in other environments. |
Use a language that prevents uninitialized data or makes it easier to avoid, for example through compile-time checks or defined default values. At the architecture and design stage, identify variables and data stores receiving external information and validate inputs so they are initialized only to expected values. Explicitly initialize every variable and data store at declaration or immediately before first use, and review complex conditionals to ensure that every relevant path performs initialization. Avoid race conditions during initialization routines, and compile or build the product with settings that warn about uninitialized variables or data.
Automated static analysis, commonly implemented as Static Application Security Testing, can identify some instances by modeling data flow and control flow and looking for potentially vulnerable source-to-sink patterns. Automated dynamic analysis can use fuzzing, robustness testing, fault injection, and stress tests with many simultaneous threads or processes; unexpected instability, crashes, or incorrect results are indicators, with moderate effectiveness and possible blind spots in rarely executed paths. Manual dynamic analysis should trigger uncommon error conditions, such as low memory, insufficient privileges, interrupted transactions, or disabled basic network services, and monitor for unexpected behavior. An exception handled by the surrounding environment may still indicate that the application failed to handle the underlying condition itself.
| Method | Approach | Effectiveness |
|---|---|---|
| Automated Dynamic Analysis | This weakness can be detected using dynamic tools and techniques that interact with the software using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The software's operation may slow down, but it should not become unstable, crash, or generate incorrect results. Initialization problems may be detected with a stress-test by calling the software simultaneously from a large number of threads or processes, and look for evidence of any unexpected behavior. The software's operation may slow down, but it should not become unstable, crash, or generate incorrect results. | Moderate |
| Manual Dynamic Analysis | Identify error conditions that are not likely to occur during normal usage and trigger them. For example, run the program under low memory conditions, run with insufficient privileges or permissions, interrupt a transaction before it is completed, or disable connectivity to basic network services such as DNS. Monitor the software for any unexpected behavior. If you trigger an unhandled exception or similar error that was discovered and handled by the application's environment, it may still indicate unexpected conditions that were not handled by the application itself. | — |
| Automated Static Analysis | Automated 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 searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.) | High |
The following are representative examples, not an exhaustive list:
CVE-2001-1471: an invalid value prevents a library file from being included, skipping initialization of key variables and leading to eval injection.CVE-2008-3637: improper error checking in a protection mechanism produces an uninitialized variable, enabling a security bypass and code execution.CVE-2008-4197 and CVE-2008-0081: use of uninitialized memory or a variable can lead to code execution.CVE-2008-2934, CVE-2008-0062, CVE-2009-2692, CVE-2009-0949, and CVE-2009-3620: initialization failures involving pointers, handlers, or data structures lead to crashes, null pointer dereferences, or double-free behavior.CVE-2007-3749 and CVE-2005-1036: state or structures are not reset or initialized correctly, resulting in unauthorized access or privilege gain.CVE-2008-0063: memory contents are not cleared while generating an error message, causing information leakage.CVE-2008-3688, CVE-2008-3475, and CVE-2008-3597: improper initialization leads to an infinite loop, memory corruption, or access to structures before initialization has completed.CVE-2008-5021: a race condition permits an object to be modified while it is still being initialized, causing the software to access uninitialized memory.Below are representative vulnerabilities related to this CWE, prioritized by severity.
CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.
CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.
Explore CyStack VulnScanen