CWEweakness

CWE-1341 Multiple Releases of Same Resource or Handle

Official page ↗
Abstraction
Base
Structure
Simple
Status
Incomplete
Languages
C, C++, Java, Not Language-Specific, Rust
CWE version
5.0

Description

The product attempts to close or release a resource or handle more than once, without any successful open between the close operations.

Extended description

Note that while the implementation for most (if not all) resource reservation allocations involve a unique identifier/pointer/symbolic reference, then if this identifier is reused, checking the identifier for resource closure may result in a false state of openness and closing of the wrong resource. For this reason, reuse of identifiers is discouraged.

Common consequences

• Availability, Integrity: DoS: Crash, Exit, or Restart • Integrity: Modify Memory, Modify Application Data — Depending on the type of resource and the expected API behavior, this could lead to memory corruption, data corruption, or execution path corruption.

Potential mitigations

• [Implementation] Change the code's logic so that the resource is only closed once. This might require simplifying or refactoring. This fix can be simple to do in small code blocks, but more difficult when multiple closes are buried within complex conditionals. • [Implementation] It can be effective to implement a flag that is (1) set when the resource is opened, (2) cleared when it is closed, and (3) checked before closing. This approach can be useful when there are disparate cases in which closes must be performed. However, flag-tracking can increase code complexity and requires diligent compliance by the programmer. • [Implementation] When closing a resource, set the resource's associated variable to NULL or equivalent value for the given language. Some APIs will ignore this null value without causing errors. For other APIs, this can lead to application crashes or exceptions, which may still be preferable to corrupting an unintended resource such as memory or data.

Detection methods

• Automated Static Analysis: For commonly-used APIs and resource types, automated tools often have signatures that can spot this issue. • Automated Dynamic Analysis: Some compiler instrumentation tools such as AddressSanitizer (ASan) can indirectly detect some instances of this weakness.

Observed examples

• CVE-2019-13351: file descriptor double close can cause the wrong file to be associated with a file descriptor. • 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). • CVE-2004-0772: Double free resultant from certain error conditions.

Related

Observed example · CVE (3)

  • CVE-2019-13351 posix/JackSocket.cpp in libjack in JACK2 1.9.1 through 1.9.12 (as distributed with alsa-plugins 1.1.7 and later) has a "double file… vulnerability
  • CVE-2006-5051 Signal handler race condition in OpenSSH before 4.4 allows remote attackers to cause a denial of service (crash), and possibly execute… vulnerability
  • CVE-2004-0772 Double free vulnerabilities in error handling code in krb524d for MIT Kerberos 5 (krb5) 1.2.8 and earlier may allow remote attackers to… vulnerability

Can precede · CWE (1)

  • CWE-672 Operation on a Resource after Expiration or Release weakness

Child of · CWE (1)

  • CWE-675 Multiple Operations on Resource in Single-Operation Context weakness

Referenced by CVE · weakness (8)

  • CVE-2026-52987 In the Linux kernel, the following vulnerability has been resolved: drm/amdgpu: avoid double drm_exec_fini() in userq validate When… vulnerability
  • CVE-2026-45852 In the Linux kernel, the following vulnerability has been resolved: RDMA/rxe: Fix double free in rxe_srq_from_init In rxe_srq_from_init(),… vulnerability
  • CVE-2026-45898 In the Linux kernel, the following vulnerability has been resolved: RDMA/iwcm: Fix workqueue list corruption by removing work_list The… vulnerability
  • CVE-2026-43494 In the Linux kernel, the following vulnerability has been resolved: net/rds: reset op_nents when zerocopy page pin fails When… vulnerability
  • CVE-2026-33811 When using LookupCNAME with the cgo DNS resolver, a very long CNAME response can trigger a double-free of C memory and a crash. vulnerability
  • CVE-2026-43178 In the Linux kernel, the following vulnerability has been resolved: procfs: fix possible double mmput() in do_procmap_query() When user… vulnerability
  • CVE-2026-23918 Double Free and possible RCE vulnerability in Apache HTTP Server with the HTTP/2 protocol. vulnerability
  • CVE-2026-6654 Double-Free / Use-After-Free (UAF) in the `IntoIter::drop` and `ThinVec::clear` functions in the thin_vec crate. vulnerability

Referenced by CWE · child of (1)