CWE-412: Unrestricted Externally Accessible Lock
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.
Last updated
Overview
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.
Real-world CVEs
5 recorded CVEs are caused by CWE-412 (Unrestricted Externally Accessible Lock). The highest-severity and most recent are shown first. 1 new CWE-412 CVE has been recorded so far in 2026.
- CVE-2019-18269Critical · CVSS 9.8 · EPSS 59th2019-12-16
- CVE-2023-38505High · CVSS 7.5 · EPSS 47th2023-07-27
- CVE-2023-22318High · CVSS 7.5 · EPSS 41th2023-05-15
- CVE-2026-25612
Internal ResourceId collision may affect unrelated collections
High · CVSS 7.1 · EPSS 10th2026-02-10 - CVE-2019-11485
apport created lock file in wrong directory
Low · CVSS 3.3 · EPSS 17th2020-02-08
Common consequences
What can happen when CWE-412 is exploited.
DoS: Resource Consumption (Other)
Affects: Availability
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.
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
How to prevent it
Practical mitigations for CWE-412, grouped by where in the lifecycle they apply.
Use any access control that is offered by the functionality that is offering the lock.
Use unpredictable names or identifiers for the locks. This might not always be possible or feasible.
Consider modifying your code to use non-blocking synchronization methods.
How to detect it
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.
Code examples
Illustrative examples from MITRE showing how the weakness appears in code.
This code tries to obtain a lock for a file, then writes to it.
Vulnerable example
function writeToLog($message){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().
Illustrative examples
Real CVEs that MITRE cites as examples of this weakness.
- 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.
Terminology & mappings
Mapped taxonomies
- PLOVER: Unrestricted Critical Resource Lock
- 7 Pernicious Kingdoms: Deadlock
- OWASP Top Ten 2004: Denial of Service (A9) — CWE More Specific fit
- 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)
Attack patterns
CAPEC attack patterns that exploit this weakness.
Frequently asked questions
Common questions about CWE-412.
- 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?
- 5 recorded CVEs are attributed to CWE-412, including CVE-2019-18269, CVE-2023-38505, CVE-2023-22318.
- 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?
- 5 recorded CVEs are caused by CWE-412; none are currently in CISA's KEV catalog of actively exploited flaws.
References
- MITRE CWE definition (CWE-412) (opens in a new tab)
- CWE-412 vulnerabilities on NVD (opens in a new tab)
- Learn: What is a CWE?
Weakness data is sourced from the MITRE CWE catalog (v4.20). CVE associations are aggregated and kept current by RadicalNotion.AI.
Stay ahead of CWE-412
Get alerted the moment a new CWE-412 vulnerability affects your stack, with AI-written analysis, severity context, and remediation guidance.