| Impact | Details |
|---|---|
|
Read Memory; Read Application Data |
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.
|
|
DoS: Crash, Exit, or Restart |
Scope: Availability
The uninitialized resource may contain values that cause program flow to change in ways that the programmer did not intend.
|
| Phase(s) | Mitigation |
|---|---|
|
Implementation |
Explicitly initialize the resource before use. If this is performed through an API function or standard procedure, follow all required steps.
|
|
Implementation |
Pay close attention to complex conditionals that affect initialization, since some branches might not perform the initialization.
|
|
Implementation |
Avoid race conditions (CWE-362) during initialization routines.
|
|
Build and Compilation |
Run or compile the product with settings that generate warnings about uninitialized variables or data.
|
| Nature | Type | ID | Name |
|---|---|---|---|
| ChildOf | Class Class - a weakness that is described in a very abstract fashion, typically independent of any specific language or technology. More specific than a Pillar Weakness, but more general than a Base Weakness. Class level weaknesses typically describe issues in terms of 1 or 2 of the following dimensions: behavior, property, and resource. | 665 | Improper Initialization |
| ParentOf | Variant Variant - a weakness that is linked to a certain type of product, typically involving a specific language or technology. More specific than a Base weakness. Variant level weaknesses typically describe issues in terms of 3 to 5 of the following dimensions: behavior, property, technology, language, and resource. | 457 | Use of Uninitialized Variable |
| CanFollow | Class Class - a weakness that is described in a very abstract fashion, typically independent of any specific language or technology. More specific than a Pillar Weakness, but more general than a Base Weakness. Class level weaknesses typically describe issues in terms of 1 or 2 of the following dimensions: behavior, property, and resource. | 909 | Missing Initialization of Resource |
| Nature | Type | ID | Name |
|---|---|---|---|
| MemberOf | Category Category - a CWE entry that contains a set of other entries that share a common characteristic. | 399 | Resource Management Errors |
| Nature | Type | ID | Name |
|---|---|---|---|
| ChildOf | Class Class - a weakness that is described in a very abstract fashion, typically independent of any specific language or technology. More specific than a Pillar Weakness, but more general than a Base Weakness. Class level weaknesses typically describe issues in terms of 1 or 2 of the following dimensions: behavior, property, and resource. | 665 | Improper Initialization |
| Phase | Note |
|---|---|
| Implementation |
Class: Not Language-Specific (Undetermined Prevalence)
Example 1
Here, a boolean initiailized field is consulted to ensure that initialization tasks are only completed once. However, the field is mistakenly set to true during static initialization, so the initialization code is never reached.
Example 2
The following code intends to limit certain operations to the administrator only.
If the application is unable to extract the state information - say, due to a database timeout - then the $uid variable will not be explicitly set by the programmer. This will cause $uid to be regarded as equivalent to "0" in the conditional, allowing the original user to perform administrator actions. Even if the attacker cannot directly influence the state data, unexpected errors could cause incorrect privileges to be assigned to a user just by accident.
Example 3
The following code intends to concatenate a string to a variable and print the string.
This might seem innocent enough, but str was not initialized, so it contains random memory. As a result, str[0] might not contain the null terminator, so the copy might start at an offset other than 0. The consequences can vary, depending on the underlying memory.
If a null terminator is found before str[8], then some bytes of random garbage will be printed before the "hello world" string. The memory might contain sensitive information from previous uses, such as a password (which might occur as a result of CWE-14 or CWE-244). In this example, it might not be a big deal, but consider what could happen if large amounts of memory are printed out before the null terminator is found.
If a null terminator isn't found before str[8], then a buffer overflow could occur, since strcat will first look for the null terminator, then copy 12 bytes starting with that location. Alternately, a buffer over-read might occur (CWE-126) if a null terminator isn't found before the end of the memory segment is reached, leading to a segmentation fault and crash.
Example 4
This example will leave test_string in an unknown condition when i is the same value as err_val, because test_string is not initialized (CWE-456). Depending on where this code segment appears (e.g. within a function body), test_string might be random if it is stored on the heap or stack. If the variable is declared in static memory, it might be zero or NULL. Compiler optimization might contribute to the unpredictability of this address.
When the printf() is reached, test_string might be an unexpected address, so the printf might print junk strings (CWE-457).
To fix this code, there are a couple approaches to making sure that test_string has been properly set once it reaches the printf().
One solution would be to set test_string to an acceptable default before the conditional:
Another solution is to ensure that each branch of the conditional - including the default/else branch - could ensure that test_string is set:
Note: this is a curated list of examples for users to understand the variety of ways in which this weakness can be introduced. It is not a complete list of all CVEs that are related to this CWE entry.
| Reference | Description |
|---|---|
|
Use of uninitialized memory may allow code execution.
|
|
|
Free of an uninitialized pointer leads to crash and possible code execution.
|
|
|
Product does not clear memory contents when generating an error message, leading to information leak.
|
|
|
Lack of initialization triggers NULL pointer dereference or double-free.
|
|
|
Uninitialized variable leads to code execution in popular desktop application.
|
|
|
Chain: Uninitialized variable leads to infinite loop.
|
|
|
Chain: Improper initialization leads to memory corruption.
|
|
|
Chain: game server can access player data structures before initialization has happened leading to NULL dereference
|
|
|
Chain: uninitialized function pointers can be dereferenced allowing code execution
|
|
|
Chain: improper initialization of memory can lead to NULL dereference
|
|
|
Chain: some unprivileged ioctls do not verify that a structure has been initialized before invocation, leading to NULL dereference
|
| Ordinality | Description |
|---|---|
|
Primary
|
(where the weakness exists independent of other weaknesses)
|
Resultant
|
(where the weakness is typically related to the presence of some other weaknesses)
|
| Nature | Type | ID | Name |
|---|---|---|---|
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1157 | SEI CERT C Coding Standard - Guidelines 03. Expressions (EXP) |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1306 | CISQ Quality Measures - Reliability |
| MemberOf | ViewView - a subset of CWE entries that provides a way of examining CWE content. The two main view structures are Slices (flat lists) and Graphs (containing relationships between entries). | 1340 | CISQ Data Protection Measures |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1416 | Comprehensive Categorization: Resource Lifecycle Management |
Rationale
This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.Comments
Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.| Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
|---|---|---|---|
| CERT C Secure Coding | EXP33-C | CWE More Abstract | Do not read uninitialized memory |
| Submissions | ||
|---|---|---|
| Submission Date | Submitter | Organization |
|
2012年12月21日
(CWE 2.4, 2013年02月21日) |
CWE Content Team | MITRE |
| New weakness based on discussion on the CWE research list in December 2012. | ||
| Modifications | ||
| Modification Date | Modifier | Organization |
|
2025年09月09日
(CWE 4.18, 2025年09月09日) |
CWE Content Team | MITRE |
| updated References | ||
| 2023年06月29日 | CWE Content Team | MITRE |
| updated Mapping_Notes | ||
| 2023年04月27日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2023年01月31日 | CWE Content Team | MITRE |
| updated Description, Potential_Mitigations | ||
| 2021年03月15日 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, Observed_Examples | ||
| 2020年12月10日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2020年08月20日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2020年02月24日 | CWE Content Team | MITRE |
| updated Description, Relationships | ||
| 2019年01月03日 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2017年11月08日 | CWE Content Team | MITRE |
| updated Taxonomy_Mappings | ||
Use of the Common Weakness Enumeration (CWE™) and the associated references from this website are subject to the Terms of Use. CWE is sponsored by the U.S. Department of Homeland Security (DHS) Cybersecurity and Infrastructure Security Agency (CISA) and managed by the Homeland Security Systems Engineering and Development Institute (HSSEDI) which is operated by The MITRE Corporation (MITRE). Copyright © 2006–2025, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation.