---
title: "CWE-460: Improper Cleanup on Thrown Exception"
url: https://radicalnotion.ai/cwe/cwe-460
type: cwe
description: "The product does not clean up its state or incorrectly cleans up its state when an exception is thrown."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-460: Improper Cleanup on Thrown Exception

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **Likelihood of exploit:** Medium
- **CVEs with this as primary weakness:** 45
- **Of those, in CISA KEV:** 0
- **New in 2026:** 17
- **CWE catalog version:** 4.21

## Description

The product does not clean up its state or incorrectly cleans up its state when an exception is thrown.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | Often, when functions or loops become complicated, some level of resource cleanup is needed throughout execution. |
| Implementation | REALIZATION: This weakness is caused during implementation of an architectural security tactic. |

## Applicable platforms

**Languages:** C (Undetermined), C++ (Undetermined), Java (Undetermined), C# (Undetermined), Python (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other | Unexpected State, Varies by Context | Exceptions can disturb the flow of the code and prevent the necessary cleanup from happening. This could lead to unexpected state or control flow. |

## Potential mitigations

### Implementation

If one breaks from a loop or function by throwing an exception, make sure that cleanup happens or that you should exit the program. Use throwing exceptions sparsely.

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

Effectiveness: High

## Demonstrative examples

### Example 1

The following example demonstrates the weakness.

Bad code:

```java
public class foo {
    public static final void main( String args[] ) {

        boolean returnValue;
        returnValue=doStuff();
    }
    public static final boolean doStuff( ) {

        boolean threadLock;
        boolean truthvalue=true;
        try {

            while(
            //check some condition
            ) {

                threadLock=true; //do some stuff to truthvalue
                threadLock=false;
            }
        }
        catch (Exception e){

            System.err.println("You did something bad");
            if (something) return truthvalue;
        }
        return truthvalue;
    }
}
```

In this case, a thread might be left locked accidentally.

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2024-56718 | net/smc: protect link down work from execute after lgr freed | critical | 9.8 | - | No | 2024-12-29 |
| CVE-2024-53169 | nvme-fabrics: fix kernel crash while shutting down controller | critical | 9.8 | - | No | 2024-12-27 |
| CVE-2026-116561 | Apache Tomcat: Jakarta Authentication secureResponse AuthException sends unprotected HTTP 200 response | critical | 9.1 | - | No | 2026-11-19 |
| CVE-2026-40583 | UltraDAG: SmartOp Vote Path Triggers Fatal Supply Invariant Halt | high | 8.8 | - | No | 2026-04-21 |
| CVE-2022-22150 | Foxit Reader getPageNthWordQuads mishandled exception vulnerability | high | 8.8 | - | No | 2022-02-04 |
| CVE-2026-57890 | - | high | 8.7 | - | No | 2026-11-10 |
| CVE-2026-123558 | Zebra before 7.0.0 Checkpoint Sync Denial of Service via Cancelled Verifier Rewind | high | 8.7 | - | No | 2026-11-08 |
| CVE-2026-111103 | HTTP/2 StreamError recovery rolls back connection state and bypasses per-connection limits in Bandit | high | 8.2 | - | No | 2026-10-26 |
| CVE-2024-53059 | wifi: iwlwifi: mvm: Fix response handling in iwl\_mvm\_send\_recovery\_cmd() | high | 7.8 | - | No | 2024-11-19 |
| CVE-2022-4744 | kernel: tun: avoid double free in tun\_free\_netdev | high | 7.8 | - | No | 2023-03-30 |
| CVE-2018-17183 | ghostscript: User-writable error exception table | high | 7.8 | - | No | 2018-09-19 |
| CVE-2026-93710 | Dancer2 versions from 2.0.0 before 2.2.0 for Perl dispatch a route that a dying hook refused when the exception handler halts the response in compile\_hooks | high | 7.5 | - | No | 2026-09-22 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-459](https://radicalnotion.ai/cwe/cwe-459) | Incomplete Cleanup |
| Parent | [CWE-755](https://radicalnotion.ai/cwe/cwe-755) | Improper Handling of Exceptional Conditions |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CLASP | Improper cleanup on thrown exception | - | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Restore prior object state on method failure | ERR03-J | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Do not let checked exceptions escape from a finally block | ERR05-J | - |
| SEI CERT Perl Coding Standard | Do not suppress or ignore exceptions | EXP31-PL | Imprecise |
| OpenSSF Secure Coding Guide for Python | Ensure Cleanup on Exceptions | pyscg-0052 | - |

## Frequently asked questions

### What is CWE-460?

The product does not clean up its state or incorrectly cleans up its state when an exception is thrown.

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

45 recorded CVEs are attributed to CWE-460, including CVE-2024-56718, CVE-2024-53169 and CVE-2026-116561.

### How do you prevent CWE-460?

If one breaks from a loop or function by throwing an exception, make sure that cleanup happens or that you should exit the program. Use throwing exceptions sparsely.

### How is CWE-460 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-460?

Exploiting CWE-460 can lead to: Unexpected State, Varies by Context.

### Is CWE-460 actively exploited?

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

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

---

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