---
title: "CWE-1341: Multiple Releases of Same Resource or Handle"
url: https://radicalnotion.ai/cwe/cwe-1341
type: cwe
description: "The product attempts to close or release a resource or handle more than once, without any successful open between the close operations."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-1341: Multiple Releases of Same Resource or Handle

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 70
- **Of those, in CISA KEV:** 0
- **New in 2026:** 51
- **CWE catalog version:** 4.21

## Description

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

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.

## Background

Code typically requires "opening" handles or references to resources such as memory, files, devices, socket connections, services, etc. When the code is finished with using the resource, it is typically expected to "close" or "release" the resource, which indicates to the environment (such as the OS) that the resource can be re-assigned or reused by unrelated processes or actors - or in some cases, within the same process. API functions or other abstractions are often used to perform this release, such as free() or delete() within C/C++, or file-handle close() operations that are used in many languages.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | the implementation or design of resource-management APIs might expect the developer to be responsible for ensuring that such APIs are only called once per release of the resource. If the developer attempts to release the same resource/handle more than once, then the API's expectations are not met. |

## Applicable platforms

**Languages:** Java (Undetermined), Rust (Undetermined), C (Undetermined), C++ (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| 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 (Refactoring)

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 (Refactoring)

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.

Effectiveness: Defense in Depth

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

## Demonstrative examples

### Example 1

This example attempts to close a file twice. In some cases, the C library fclose() function will catch the error and return an error code. In other implementations, a double-free (CWE-415) occurs, causing the program to fault. Note that the examples presented here are simplistic, and double fclose() calls will frequently be spread around a program, making them more difficult to find during code reviews.

Bad code:

```c
char b[2000];
FILE *f = fopen("dbl_cls.c", "r");
if (f)
{
    b[0] = 0;
    fread(b, 1, sizeof(b) - 1, f);
    printf("%s\n'", b);
    int r1 = fclose(f);
    printf("\n-----------------\n1 close done '%d'\n", r1);

    int r2 = fclose(f);	// Double close
    printf("2 close done '%d'\n", r2);
}
```

Good code:

```c
char b[2000];
FILE *f = fopen("dbl_cls.c", "r");
if (f)
{
    b[0] = 0;
    fread(b, 1, sizeof(b) - 1, f);
    printf("%s\n'", b);
    int r = fclose(f);
    printf("\n-----------------\n1 close done '%d'\n", r);
}
```

Good code:

```c
char b[2000];
int f_flg = 0;
FILE *f = fopen("dbl_cls.c", "r");
if (f)
{
    f_flg = 1;
    b[0] = 0;
    fread(b, 1, sizeof(b) - 1, f);
    printf("%s\n'", b);
    if (f_flg)
    {
        int r1 = fclose(f);
        f_flg = 0;
        printf("\n-----------------\n1 close done '%d'\n", r1);

    }

    if (f_flg)
    {
        int r2 = fclose(f);	// Double close
        f_flg = 0;
        printf("2 close done '%d'\n", r2);

    }

}
```

### Example 2

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

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2024-44984 | bnxt\_en: Fix double DMA unmapping for XDP\_REDIRECT | critical | 10.0 | - | No | 2024-09-04 |
| CVE-2026-99079 | net/mlx5e: Prevent stale XSK buffer release on refill retry | critical | 9.8 | - | No | 2026-10-23 |
| CVE-2026-99078 | net/mlx5e: Prevent stale XSK buffer release on MPWQE refill retry | critical | 9.8 | - | No | 2026-10-23 |
| CVE-2026-74545 | rtase: fix double free of multi-frag skb on DMA map failure | critical | 9.8 | - | No | 2026-08-15 |
| CVE-2026-74434 | rxrpc: Don't move a peeked OOB message onto the pending queue | critical | 9.8 | - | No | 2026-08-15 |
| CVE-2026-72220 | sunrpc: harden rq\_procinfo lifecycle to prevent double-free | critical | 9.8 | - | No | 2026-08-15 |
| CVE-2026-72137 | xfrm: nat\_keepalive: avoid double free on send error | critical | 9.8 | - | No | 2026-08-15 |
| CVE-2026-45898 | RDMA/iwcm: Fix workqueue list corruption by removing work\_list | critical | 9.8 | - | No | 2026-05-27 |
| CVE-2023-54223 | net/mlx5e: xsk: Fix invalid buffer access for legacy rq | critical | 9.8 | - | No | 2025-12-30 |
| CVE-2026-72289 | KVM: arm64: vgic: Check the interrupt is still ours before migrating it | critical | 9.3 | - | No | 2026-08-15 |
| CVE-2025-40253 | s390/ctcm: Fix double-kfree | high | 8.8 | - | No | 2025-12-04 |
| CVE-2025-38238 | scsi: fnic: Fix crash in fnic\_wq\_cmpl\_handler when FDMI times out | high | 8.8 | - | No | 2025-07-09 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-675](https://radicalnotion.ai/cwe/cwe-675) | Multiple Operations on Resource in Single-Operation Context |
| Child | [CWE-415](https://radicalnotion.ai/cwe/cwe-415) | Double Free |
| Can precede | [CWE-672](https://radicalnotion.ai/cwe/cwe-672) | Operation on a Resource after Expiration or Release |

## Frequently asked questions

### What is CWE-1341?

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

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

70 recorded CVEs are attributed to CWE-1341, including CVE-2024-44984, CVE-2026-99079 and CVE-2026-99078.

### How do you prevent CWE-1341?

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.

### How is CWE-1341 detected?

Automated Static Analysis: For commonly-used APIs and resource types, automated tools often have signatures that can spot this issue.

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

Exploiting CWE-1341 can lead to: DoS: Crash, Exit, or Restart, Modify Memory, Modify Application Data.

### Is CWE-1341 actively exploited?

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

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

---

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