---
title: "CWE-666: Operation on Resource in Wrong Phase of Lifetime"
url: https://radicalnotion.ai/cwe/cwe-666
type: cwe
description: "The product performs an operation on a resource at the wrong phase of the resource's lifecycle, which can lead to unexpected behaviors."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-666: Operation on Resource in Wrong Phase of Lifetime

- **Abstraction:** Class
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 8
- **Of those, in CISA KEV:** 0
- **New in 2026:** 5
- **CWE catalog version:** 4.21

## Description

The product performs an operation on a resource at the wrong phase of the resource's lifecycle, which can lead to unexpected behaviors.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other | Varies by Context, Modify Application Data | Using a resource before it has been fully initialized could cause corruption or incorrect data to be used. |

## Potential mitigations

### Architecture and Design

Follow the resource's lifecycle from creation to release.

### Implementation

For each phase, it is important to follow the specifications outlined for how to operate on the resource and to ensure that the resource is in the expected phase. Otherwise, if a resource is in one phase but the operation is not valid for that phase (i.e., an incorrect phase of the resource's lifetime), then this can produce resultant weaknesses.

## Detection methods

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

## Demonstrative examples

### Example 1

The following code shows a simple example of a double free vulnerability.

Bad code:

```c
char* ptr = (char*)malloc (SIZE);
...
if (abrt) {
    free(ptr);
}
...
free(ptr);
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2006-5051 | Chain: Signal handler contains too much functionality (CWE-828), introducing a race condition (CWE-362) that leads to a double free (CWE-415). |

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-64162 | idpf: fix read\_dev\_clk\_lock spinlock init in idpf\_ptp\_init() | critical | 9.8 | - | No | 2026-07-19 |
| CVE-2024-46754 | bpf: Remove tst\_run from lwt\_seg6local\_prog\_ops. | high | 7.8 | - | No | 2024-09-18 |
| CVE-2024-40949 | mm: shmem: fix getting incorrect lruvec when replacing a shmem folio | high | 7.8 | - | No | 2024-07-12 |
| CVE-2026-68930 | Russh: Channel-scoped server callbacks can be reached without an open channel | medium | 6.5 | - | No | 2026-08-03 |
| CVE-2026-85036 | Bluetooth Classic AVDTP session reuse re-initializes a queued work item, corrupting the system work queue | medium | 5.7 | - | No | 2026-11-04 |
| CVE-2024-50111 | LoongArch: Enable IRQ if do\_ale() triggered in irq-enabled context | medium | 5.5 | - | No | 2024-11-05 |
| CVE-2026-15460 | Missing channel-state validation in Zephyr Bluetooth Classic L2CAP receive path | medium | 5.4 | - | No | 2026-09-09 |
| CVE-2026-16148 | Kernel panic in the it82xx2 USB device controller driver via re-initialization of a busy delayable work item | medium | 4.6 | - | No | 2026-09-14 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-664](https://radicalnotion.ai/cwe/cwe-664) | Improper Control of a Resource Through its Lifetime |
| Child | [CWE-415](https://radicalnotion.ai/cwe/cwe-415) | Double Free |
| Child | [CWE-593](https://radicalnotion.ai/cwe/cwe-593) | Authentication Bypass: OpenSSL CTX Object Modified after SSL Objects are Created |
| Child | [CWE-605](https://radicalnotion.ai/cwe/cwe-605) | Multiple Binds to the Same Port |
| Child | [CWE-672](https://radicalnotion.ai/cwe/cwe-672) | Operation on a Resource after Expiration or Release |
| Child | [CWE-826](https://radicalnotion.ai/cwe/cwe-826) | Premature Release of Resource During Expected Lifetime |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CERT C Secure Coding | Do not access a closed file | FIO46-C | CWE More Abstract |
| CERT C Secure Coding | Do not access freed memory | MEM30-C | CWE More Abstract |

## Frequently asked questions

### What is CWE-666?

The product performs an operation on a resource at the wrong phase of the resource's lifecycle, which can lead to unexpected behaviors.

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

8 recorded CVEs are attributed to CWE-666, including CVE-2026-64162, CVE-2024-46754 and CVE-2024-40949.

### How do you prevent CWE-666?

Follow the resource's lifecycle from creation to release.

### How is CWE-666 detected?

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

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

Exploiting CWE-666 can lead to: Varies by Context, Modify Application Data.

### Is CWE-666 actively exploited?

8 recorded CVEs are caused by CWE-666; none are currently in CISA's KEV catalog of actively exploited flaws.

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

---

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