---
title: "CWE-413: Improper Resource Locking"
url: https://radicalnotion.ai/cwe/cwe-413
type: cwe
description: "The product must have exclusive access to a resource, but it does not lock or does not correctly lock that resource."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-413: Improper Resource Locking

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

## Description

The product must have exclusive access to a resource, but it does not lock or does not correctly lock that resource.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Architecture and Design | - |
| Implementation | - |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity, Availability | Modify Application Data, DoS: Instability, DoS: Crash, Exit, or Restart | When a resource is not properly locked, an attacker could modify the resource while it is being operated on by the product. This might violate the product's assumption that the resource will not change, potentially leading to unexpected behaviors. |

## Potential mitigations

### Architecture and Design

Use a non-conflicting privilege scheme.

### Architecture and Design, Implementation

Use synchronization when locking a resource.

## 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 function attempts to acquire a lock in order to perform operations on a shared resource.

Bad code:

```c
void f(pthread_mutex_t *mutex) {
    pthread_mutex_lock(mutex);

    /* access shared resource */

    pthread_mutex_unlock(mutex);
}
```

Good code:

```c
int f(pthread_mutex_t *mutex) {
    int result;

    result = pthread_mutex_lock(mutex);
    if (0 != result)
        return result;

    /* access shared resource */

    return pthread_mutex_unlock(mutex);
}
```

### Example 2

This Java example shows a simple BankAccount class with deposit and withdraw methods.

Bad code:

```java
public class BankAccount {

    // variable for bank account balance
    private double accountBalance;

    // constructor for BankAccount
    public BankAccount() {
        accountBalance = 0;
    }

    // method to deposit amount into BankAccount
    public void deposit(double depositAmount) {

        double newBalance = accountBalance + depositAmount;
        accountBalance = newBalance;
    }

    // method to withdraw amount from BankAccount
    public void withdraw(double withdrawAmount) {

        double newBalance = accountBalance - withdrawAmount;
        accountBalance = newBalance;
    }

    // other methods for accessing the BankAccount object
    ...
}
```

Good code:

```java
public class BankAccount {
    ...
    // synchronized method to deposit amount into BankAccount
    public synchronized void deposit(double depositAmount) {
        ...
    }

    // synchronized method to withdraw amount from BankAccount
    public synchronized void withdraw(double withdrawAmount) {
        ...
    }

    ...
}
```

Good code:

```java
public class BankAccount {
    ...
    // lock object for thread access to methods
    private ReentrantLock balanceChangeLock;

    // condition object to temporarily release lock to other threads
    private Condition sufficientFundsCondition;

    // method to deposit amount into BankAccount
    public void deposit(double amount) {

        // set lock to block access to BankAccount from other threads
        balanceChangeLock.lock();
        try {
            double newBalance = balance + amount;
            balance = newBalance;

            // inform other threads that funds are available
            sufficientFundsCondition.signalAll();
        } catch (Exception e) {...}
        finally {
            // unlock lock object
            balanceChangeLock.unlock();
        }
    }

    // method to withdraw amount from bank account
    public void withdraw(double amount) {

        // set lock to block access to BankAccount from other threads
        balanceChangeLock.lock();
        try {
            while (balance < amount) {

                // temporarily unblock access

                // until sufficient funds are available
                sufficientFundsCondition.await();
            }
            double newBalance = balance - amount;
            balance = newBalance;
        } catch (Exception e) {...}
        finally {
            // unlock lock object
            balanceChangeLock.unlock();
        }
    }
    ...
}
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2022-20141 | Chain: an operating system kernel has insufficient resource locking (CWE-413) leading to a use after free (CWE-416). |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-72491 | net/9p: fix race condition on rdma-\>state in trans\_rdma.c | critical | 9.8 | - | No | 2026-08-15 |
| CVE-2023-54237 | net/smc: fix potential panic dues to unprotected smc\_llc\_srv\_add\_link() | critical | 9.8 | - | No | 2025-12-30 |
| CVE-2024-26877 | crypto: xilinx - call finalize with bh disabled | critical | 9.8 | - | No | 2024-04-17 |
| CVE-2025-3450 | Automation Runtime SDM requests may impact system | critical | 9.3 | - | No | 2025-10-07 |
| CVE-2026-48178 | Out of bound access in PPC due to race condition in global variable access | high | 8.8 | - | No | 2026-11-05 |
| CVE-2026-80547 | s390/vfio\_ccw: Implement a crw lock | high | 8.8 | - | No | 2026-08-26 |
| CVE-2025-21876 | iommu/vt-d: Fix suspicious RCU usage | high | 8.8 | - | No | 2025-03-27 |
| CVE-2024-41062 | bluetooth/l2cap: sync sock recv cb and release | high | 8.8 | - | No | 2024-07-29 |
| CVE-2024-36922 | wifi: iwlwifi: read txq-\>read\_ptr under lock | high | 8.8 | - | No | 2024-05-30 |
| CVE-2026-32748 | Squid has Denial of Service in ICP Response handling | high | 8.7 | - | No | 2026-03-26 |
| CVE-2023-28649 | Improper Resource Locking in Snap One OvrC Cloud | high | 8.6 | - | No | 2023-05-22 |
| CVE-2022-20678 | Cisco IOS XE Software AppNav-XE Denial of Service Vulnerability | high | 8.6 | - | No | 2022-04-15 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-667](https://radicalnotion.ai/cwe/cwe-667) | Improper Locking |
| Child | [CWE-591](https://radicalnotion.ai/cwe/cwe-591) | Sensitive Data Storage in Improperly Locked Memory |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Insufficient Resource Locking | - | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Ensure visibility when accessing shared primitive variables | VNA00-J | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Ensure that compound operations on shared variables are atomic | VNA02-J | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Use private final lock objects to synchronize classes that may interact with untrusted code | LCK00-J | - |
| Software Fault Patterns | Missing Lock | SFP19 | - |

## Frequently asked questions

### What is CWE-413?

The product must have exclusive access to a resource, but it does not lock or does not correctly lock that resource.

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

118 recorded CVEs are attributed to CWE-413, including CVE-2026-72491, CVE-2023-54237 and CVE-2024-26877.

### How do you prevent CWE-413?

Use a non-conflicting privilege scheme.

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

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

### Is CWE-413 actively exploited?

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

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

---

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