---
title: "CWE-665: Improper Initialization"
url: https://radicalnotion.ai/cwe/cwe-665
type: cwe
description: "The product does not initialize or incorrectly initializes a resource."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-665: Improper Initialization

- **Abstraction:** Class
- **Structure:** Simple
- **Status:** Draft
- **Likelihood of exploit:** Medium
- **CVEs with this as primary weakness:** 378
- **Of those, in CISA KEV:** 3
- **New in 2026:** 35
- **CWE catalog version:** 4.21

## Description

The product does not initialize or incorrectly initializes a resource.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | This weakness can occur in code paths that are not well-tested, such as rare error conditions. This is because the use of uninitialized data would be noticed as a bug during frequently-used functionality. |
| Operation | - |

## Applicable platforms

**Languages:** Python (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other | Varies by Context | The resource might be left in an unexpected state when it is accessed or used. |
| Confidentiality | Read Memory, Read Application Data | 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. |
| Access Control | Bypass Protection Mechanism | 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. |
| Availability | DoS: Crash, Exit, or Restart | 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. |

## Potential mitigations

### Requirements (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.

### Architecture and Design

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.

### Implementation

Explicitly initialize all your variables and other data stores, either during declaration or just before the first usage.

### Implementation

Pay close attention to complex conditionals that affect initialization, since some conditions might not perform the initialization.

### Implementation

Avoid race conditions (CWE-362) during initialization routines.

### Build and Compilation

Run or compile your product with settings that generate warnings about uninitialized variables or data.

## Detection methods

### 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.

Effectiveness: 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.)

Effectiveness: High

## Demonstrative examples

### Example 1

Here, a boolean initialized 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.

Bad code:

```java
private boolean initialized = true;
public void someMethod() {
    if (!initialized) {

        // perform initialization tasks
        ...

        initialized = true;
    }
```

### Example 2

The following code intends to limit certain operations to the administrator only.

Bad code:

```perl
$username = GetCurrentUser();
$state = GetStateData($username);
if (defined($state)) {
    $uid = ExtractUserID($state);
}

# do stuff
if ($uid == 0) {
    DoAdminThings();
}
```

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.

Bad code:

```c
char str[20];
strcat(str, "hello world");
printf("%s", str);
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2001-1471 | Chain: an invalid value prevents a library file from being included, skipping initialization of key variables, leading to resultant eval injection. |
| CVE-2008-3637 | Improper error checking in protection mechanism produces an uninitialized variable, allowing security bypass and code execution. |
| CVE-2008-4197 | Use of uninitialized memory may allow code execution. |
| CVE-2008-2934 | Free of an uninitialized pointer leads to crash and possible code execution. |
| CVE-2007-3749 | OS kernel does not reset a port when starting a setuid program, allowing local users to access the port and gain privileges. |
| CVE-2008-0063 | Product does not clear memory contents when generating an error message, leading to information leak. |
| CVE-2008-0062 | Lack of initialization triggers NULL pointer dereference or double-free. |
| CVE-2008-0081 | Uninitialized variable leads to code execution in popular desktop application. |
| CVE-2008-3688 | Chain: Uninitialized variable leads to infinite loop. |
| CVE-2008-3475 | Chain: Improper initialization leads to memory corruption. |
| CVE-2008-5021 | Composite: race condition (CWE-362) allows attacker to modify an object while it is still being initialized, causing software to access uninitialized memory (CWE-908). |
| CVE-2005-1036 | Chain: Bypass of access restrictions due to improper authorization (CWE-862) of a user results from an improperly initialized (CWE-909) I/O permission bitmap |
| CVE-2008-3597 | Chain: game server can access player data structures before initialization has happened leading to NULL dereference |
| CVE-2009-2692 | Chain: Use of an unimplemented network socket operation pointing to an uninitialized handler function (CWE-456) causes a crash because of a null pointer dereference (CWE-476). |
| CVE-2009-0949 | Chain: improper initialization of memory can lead to NULL dereference |
| CVE-2009-3620 | Chain: some unprivileged ioctls do not verify that a structure has been initialized before invocation, leading to NULL dereference |

## Real CVEs with this weakness (sample of 12 of 378)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2022-0847 | Elevation of privilege in Kernel components (pipes) | high | 8.5 | - | Yes | 2022-03-07 |
| CVE-2013-1675 | Mozilla Firefox Information Disclosure Vulnerability | high | 7.1 | - | Yes | 2013-05-16 |
| CVE-2020-27950 | watchOS: Kernel - A malicious application may be able to disclose kernel memory | medium | 6.7 | - | Yes | 2020-12-08 |
| CVE-2026-127277 | Linksys EA8100 SMB Service service\_smbd.sh initialization | critical | 10.0 | - | No | 2026-11-13 |
| CVE-2023-20591 | - | critical | 10.0 | - | No | 2024-08-13 |
| CVE-2024-38558 | net: openvswitch: fix overwriting ct original tuple for ICMPv6 | critical | 10.0 | - | No | 2024-06-19 |
| CVE-2015-4805 | Java SE, Java SE Embedded: Serialization - takeover | critical | 10.0 | - | No | 2015-10-21 |
| CVE-2026-64035 | igc: set tx buffer type for SMD frames | critical | 9.8 | - | No | 2026-07-19 |
| CVE-2026-53398 | NFSD: Fix SECINFO\_NO\_NAME decode error cleanup | critical | 9.8 | - | No | 2026-07-19 |
| CVE-2025-40244 | hfsplus: fix KMSAN uninit-value issue in \_\_hfsplus\_ext\_cache\_extent() | critical | 9.8 | - | No | 2025-12-04 |
| CVE-2024-46697 | nfsd: ensure that nfsd4\_fattr\_args.context is zeroed out | critical | 9.8 | - | No | 2024-09-13 |
| CVE-2024-39864 | Apache CloudStack: Integration API service uses dynamic port when disabled | critical | 9.8 | - | No | 2024-07-05 |

## Related attack patterns (CAPEC)

- [CAPEC-26](https://radicalnotion.ai/capec/capec-26): Leveraging Race Conditions
- [CAPEC-29](https://radicalnotion.ai/capec/capec-29): Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-664](https://radicalnotion.ai/cwe/cwe-664) | Improper Control of a Resource Through its Lifetime |
| Child | [CWE-455](https://radicalnotion.ai/cwe/cwe-455) | Non-exit on Failed Initialization |
| Child | [CWE-456](https://radicalnotion.ai/cwe/cwe-456) | Missing Initialization of a Variable |
| Child | [CWE-457](https://radicalnotion.ai/cwe/cwe-457) | Use of Uninitialized Variable |
| Child | [CWE-770](https://radicalnotion.ai/cwe/cwe-770) | Allocation of Resources Without Limits or Throttling |
| Child | [CWE-908](https://radicalnotion.ai/cwe/cwe-908) | Use of Uninitialized Resource |
| Child | [CWE-909](https://radicalnotion.ai/cwe/cwe-909) | Missing Initialization of Resource |
| Child | [CWE-1188](https://radicalnotion.ai/cwe/cwe-1188) | Initialization of a Resource with an Insecure Default |
| Child | [CWE-1279](https://radicalnotion.ai/cwe/cwe-1279) | Cryptographic Operations are Run Before Supporting Units are Ready |
| Child | [CWE-1419](https://radicalnotion.ai/cwe/cwe-1419) | Incorrect Initialization of Resource |
| Child | [CWE-1434](https://radicalnotion.ai/cwe/cwe-1434) | Insecure Setting of Generative AI/ML Model Inference Parameters |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Incorrect initialization | - | - |
| CERT C Secure Coding | Explicitly specify array bounds, even if implicitly defined by an initializer | ARR02-C | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Prevent class initialization cycles | DCL00-J | - |
| Software Fault Patterns | Unchecked Status Condition | SFP4 | - |
| OpenSSF Secure Coding Guide for Python | Reinitialize Reused Thread Objects | pyscg-0029 | - |

## Frequently asked questions

### What is CWE-665?

The product does not initialize or incorrectly initializes a resource.

### What CVEs are caused by CWE-665?

378 recorded CVEs are attributed to CWE-665, including CVE-2022-0847, CVE-2013-1675 and CVE-2020-27950. 3 are listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.

### How do you prevent CWE-665?

Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.

### How is CWE-665 detected?

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.

### What are the consequences of CWE-665?

Exploiting CWE-665 can lead to: Varies by Context, Read Memory, Read Application Data, Bypass Protection Mechanism, DoS: Crash, Exit, or Restart.

### Is CWE-665 actively exploited?

Yes. 3 CWE-665 vulnerabilities are in CISA's KEV catalog of actively exploited flaws, out of 378 recorded CVEs.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/665.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-665). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
