Unrestricted Externally Accessible Lock

Incomplete Base
Structure: Simple
Description

This vulnerability occurs when a system correctly checks for a lock's existence, but an unauthorized external actor can control or influence that lock.

Extended Description

When an attacker can manipulate a lock—such as a mutex, file lock, or a shared resource used as a lock—they can prevent the application from accessing critical resources or performing essential operations. This effectively creates a denial-of-service condition, as the system remains blocked waiting for a lock it cannot acquire. The severity of this issue escalates if the attacker can hold the lock indefinitely, leading to a permanent disruption of service. Developers must ensure that lock mechanisms are secured within the application's trusted boundary and cannot be created, modified, or sustained by untrusted external sources.

Common Consequences 1
Scope: Availability

Impact: 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.

Detection Methods 1
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.
Potential Mitigations 3
Phase: Architecture and DesignImplementation
Use any access control that is offered by the functionality that is offering the lock.
Phase: Architecture and DesignImplementation
Use unpredictable names or identifiers for the locks. This might not always be possible or feasible.
Phase: Architecture and Design
Consider modifying your code to use non-blocking synchronization methods.
Demonstrative Examples 1

ID : DX-69

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

Code Example:

Bad
PHP
php

//attempt to get logfile lock* if (flock($logfile, LOCK_EX)) { ``` fwrite($logfile,$message);

php
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 7
CVE-2001-0682Program can not execute when attacker obtains a mutex.
CVE-2002-1914Program can not execute when attacker obtains a lock on a critical output file.
CVE-2002-1915Program can not execute when attacker obtains a lock on a critical output file.
CVE-2002-0051Critical 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-0338Chain: predictable file names used for locking, allowing attacker to create the lock beforehand. Resultant from permissions and randomness.
CVE-2000-1198Chain: Lock files with predictable names. Resultant from randomness.
CVE-2002-1869Product 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 Unrestricted Externally Accessible Lock, but close.
Applicable Platforms
Languages:
Not Language-Specific : Undetermined
Modes of Introduction
Architecture and Design
Implementation
Related Attack Patterns
Related Weaknesses
Taxonomy Mapping
  • PLOVER
  • 7 Pernicious Kingdoms
  • OWASP Top Ten 2004
  • The CERT Oracle Secure Coding Standard for Java (2011)
  • The CERT Oracle Secure Coding Standard for Java (2011)
  • Software Fault Patterns
Notes
RelationshipThis overlaps Insufficient Resource Pool when the "pool" is of size 1. It can also be resultant from race conditions, although the timing window could be quite large in some cases.