---
title: "CWE-412: Unrestricted Externally Accessible Lock"
url: https://radicalnotion.ai/cwe/cwe-412
type: cwe
description: "The product properly checks for the existence of a lock, but the lock can be externally controlled or influenced by an actor that is outside of the intended sphere of control."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-412: Unrestricted Externally Accessible Lock

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

## Description

The product properly checks for the existence of a lock, but the lock can be externally controlled or influenced by an actor that is outside of the intended sphere of control.

This prevents the product from acting on associated resources or performing other behaviors that are controlled by the presence of the lock. Relevant locks might include an exclusive lock or mutex, or modifying a shared resource that is treated as a lock. If the lock can be held for an indefinite period of time, then the denial of service could be permanent.

## Modes of introduction

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Availability | DoS: Resource Consumption (Other) | When an attacker can control a lock, the program may wait indefinitely until the attacker releases the lock, causing a denial of service to other users of the program. This is especially problematic if there is a blocking operation on the lock. |

## Potential mitigations

### Architecture and Design, Implementation

Use any access control that is offered by the functionality that is offering the lock.

### Architecture and Design, Implementation

Use unpredictable names or identifiers for the locks. This might not always be possible or feasible.

### Architecture and Design

Consider modifying your code to use non-blocking synchronization methods.

## Detection methods

### White Box

Automated code analysis techniques might not be able to reliably detect this weakness, since the application's behavior and general security model dictate which resource locks are critical. Interpretation of the weakness might require knowledge of the environment, e.g. if the existence of a file is used as a lock, but the file is created in a world-writable directory.

## Demonstrative examples

### Example 1

This code tries to obtain a lock for a file, then writes to it.

Bad code:

```php
function writeToLog($message){
    $logfile = fopen("logFile.log", "a");
    //attempt to get logfile lock
    if (flock($logfile, LOCK_EX)) {
        fwrite($logfile,$message);
        // unlock logfile
        flock($logfile, LOCK_UN);
    }
    else {
        print "Could not obtain lock on logFile.log, message not recorded\n";
    }
}
fclose($logFile);
```

PHP by default will wait indefinitely until a file lock is released. If an attacker is able to obtain the file lock, this code will pause execution, possibly leading to denial of service for other users. Note that in this case, if an attacker can perform an flock() on the file, they may already have privileges to destroy the log file. However, this still impacts the execution of other programs that depend on flock().

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2001-0682 | Program can not execute when attacker obtains a mutex. |
| CVE-2002-1914 | Program can not execute when attacker obtains a lock on a critical output file. |
| CVE-2002-1915 | Program can not execute when attacker obtains a lock on a critical output file. |
| CVE-2002-0051 | Critical file can be opened with exclusive read access by user, preventing application of security policy. Possibly related to improper permissions, large-window race condition. |
| CVE-2000-0338 | Chain: predictable file names used for locking, allowing attacker to create the lock beforehand. Resultant from permissions and randomness. |
| CVE-2000-1198 | Chain: Lock files with predictable names. Resultant from randomness. |
| CVE-2002-1869 | Product does not check if it can write to a log file, allowing attackers to avoid logging by accessing the file using an exclusive lock. Overlaps unchecked error condition. This is not quite CWE-412, but close. |

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2019-18269 | Unrestricted Externally Accessible Lock in Omron PLC CJ and CS Series | critical | 9.8 | - | No | 2019-12-16 |
| CVE-2023-22318 | Denial of service against webconf | high | 7.5 | - | No | 2023-05-15 |
| CVE-2026-25612 | Internal ResourceId collision may affect unrelated collections | high | 7.1 | - | No | 2026-02-10 |
| CVE-2026-99797 | io\_uring/cancel: drop sqd-\>lock while SQPOLL waits | medium | 5.5 | - | No | 2026-11-20 |
| CVE-2026-99671 | can: raw, isotp: copy socket options outside of lock\_sock() | medium | 5.5 | - | No | 2026-11-20 |
| CVE-2026-99084 | readdir: take no inode lock on an immutable directory | medium | 5.5 | - | No | 2026-10-23 |
| CVE-2026-93241 | memcg: bypass the reclaim and oom killer for dying tasks once oom\_reaper is done | medium | 5.5 | - | No | 2026-09-24 |
| CVE-2026-90275 | md/raid1: don't set array\_frozen in raid1\_takeover() | medium | 5.5 | - | No | 2026-09-17 |
| CVE-2026-99359 | NFSD: validate transport name in listener\_set before serv creation | low | 3.3 | - | No | 2026-11-19 |
| CVE-2019-11485 | apport created lock file in wrong directory | low | 3.3 | - | No | 2020-02-08 |

## Related attack patterns (CAPEC)

- [CAPEC-25](https://radicalnotion.ai/capec/capec-25): Forced Deadlock

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-667](https://radicalnotion.ai/cwe/cwe-667) | Improper Locking |
| Can also be | [CWE-410](https://radicalnotion.ai/cwe/cwe-410) | Insufficient Resource Pool |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Unrestricted Critical Resource Lock | - | - |
| 7 Pernicious Kingdoms | Deadlock | - | - |
| OWASP Top Ten 2004 | Denial of Service | A9 | CWE More Specific |
| 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 | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Avoid deadlock by requesting and releasing locks in the same order | LCK07-J | - |
| Software Fault Patterns | Unrestricted lock | SFP22 | - |

## Frequently asked questions

### What is CWE-412?

The product properly checks for the existence of a lock, but the lock can be externally controlled or influenced by an actor that is outside of the intended sphere of control.

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

10 recorded CVEs are attributed to CWE-412, including CVE-2019-18269, CVE-2023-22318 and CVE-2026-25612.

### Is CWE-412 part of the OWASP Top 10?

CWE-412 maps to OWASP Top Ten 2004: Denial of Service (A9) in the OWASP security taxonomy.

### How do you prevent CWE-412?

Use any access control that is offered by the functionality that is offering the lock.

### How is CWE-412 detected?

White Box: Automated code analysis techniques might not be able to reliably detect this weakness, since the application's behavior and general security model dictate which resource locks are critical. Interpretation of the weakness might require knowledge of the environment, e.g. if the existence of a file is used as a lock, but the file is created in a world-writable directory.

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

Exploiting CWE-412 can lead to: DoS: Resource Consumption (Other).

### Is CWE-412 actively exploited?

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

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

---

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