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
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
9 recorded CVEs are caused by CWE-412 (Unrestricted Externally Accessible Lock). The highest-severity and most recent are shown first. 6 new CWE-412 CVEs have been recorded so far in 2026.
Unrestricted Externally Accessible Lock in Omron PLC CJ and CS Series
Denial of service against webconf
Internal ResourceId collision may affect unrelated collections
io_uring/cancel: drop sqd->lock while SQPOLL waits
can: raw, isotp: copy socket options outside of lock_sock()
readdir: take no inode lock on an immutable directory
md/raid1: don't set array_frozen in raid1_takeover()
NFSD: validate transport name in listener_set before serv creation
apport created lock file in wrong directory
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.
Typically introduced during these phases of the software lifecycle.
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.
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.
MITRE examples of the weakness in code.
This code tries to obtain a lock for a file, then writes to it.
Vulnerable example
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().
Real CVEs that MITRE cites as examples of this weakness.
CAPEC attack patterns that exploit this weakness.
Common questions about CWE-412.
Weakness data is sourced from the MITRE CWE catalog (v4.21). CVE associations are aggregated and kept current by RadicalNotion.AI.
Get an alert when a new CWE-412 CVE affects your products, with AI-written analysis and remediation steps.