Extended Description
Strategy: Language Selection Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, in Java, if the programmer does not explicitly initialize a variable, then the code could produce a compile-time error (if the variable is local) or automatically initialize the variable to the default value for the variable's type. In Perl, if explicit initialization is not performed, then a default value of undef is assigned, which is interpreted as 0, false, or an equivalent value depending on the context in which the variable is accessed.
Identify all variables and data stores that receive information from external sources, and apply input validation to make sure that they are only initialized to expected values.
Explicitly initialize all your variables and other data stores, either during declaration or just before the first usage.
Pay close attention to complex conditionals that affect initialization, since some conditions might not perform the initialization.
Avoid race conditions ( CWE-362 ) during initialization routines.
Run or compile your product with settings that generate warnings about uninitialized variables or data.
Use automated static analysis tools that target this type of weakness. Many modern techniques use data flow analysis to minimize the number of false positives. This is not a perfect solution, since 100% accuracy and coverage are not feasible.
No detection method information available for this CWE.
No examples or observed CVEs available for this CWE.
CWE-665: CWE-665: Improper Initialization is a Common Weakness Enumeration (CWE) entry maintained by MITRE. Description Extended Description
If exploited, CWE-665 (CWE-665: Improper Initialization) it can compromise Read Memory, Read Application Data, Bypass Protection Mechanism, DoS: Crash, Exit and or Restart, leading to outcomes such as Scope: 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., Scope: Access Control If security-critical decisions rely on a variable having a ", 0", or equivalent value and and the programming language performs this initialization on behalf of the programmer.
Recommended mitigations for CWE-665 include: Strategy: Language Selection Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, in Java, if the programmer does not explicitly initialize a variable, then the code could produce a compile-time error (if the variable is local) or automatically initialize the variable to the default value for the variable's type. In Perl, if explicit initialization is not performed, then a default value of undef is assigned, which is interpreted as 0, false, or an equivalent value depending on the context in which the variable is accessed. Identify all variables and data stores that receive information from external sources, and apply input validation to make sure that they are only initialized to expected values. Explicitly initialize all your variables and other data stores, either during declaration or just before the first usage.
CWE-665 commonly affects Languages. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.
A CWE (Common Weakness Enumeration) like CWE-665 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.