CWE-412: Unrestricted Externally Accessible Lock (Base)

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.

Extended Description: 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.



Applicable Platforms: ::LANGUAGE CLASS:Not Language-Specific:LANGUAGE PREVALENCE:Undetermined::

Modes of Introduction: ::PHASE:Architecture and Design::PHASE:Implementation::



Common Consequences: ::SCOPE:Availability:IMPACT:DoS: Resource Consumption (Other):NOTE: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: ::METHOD:White Box:DESCRIPTION: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: ::PHASE:Architecture and Design Implementation:DESCRIPTION:Use any access control that is offered by the functionality that is offering the lock.::PHASE:Architecture and Design Implementation:DESCRIPTION:Use unpredictable names or identifiers for the locks. This might not always be possible or feasible.::PHASE:Architecture and Design:DESCRIPTION:Consider modifying your code to use non-blocking synchronization methods.::

Observed Examples: ::REFERENCE:CVE-2001-0682:DESCRIPTION:Program can not execute when attacker obtains a mutex.:LINK:https://www.cve.org/CVERecord?id=CVE-2001-0682::REFERENCE:CVE-2002-1914:DESCRIPTION:Program can not execute when attacker obtains a lock on a critical output file.:LINK:https://www.cve.org/CVERecord?id=CVE-2002-1914::REFERENCE:CVE-2002-1915:DESCRIPTION:Program can not execute when attacker obtains a lock on a critical output file.:LINK:https://www.cve.org/CVERecord?id=CVE-2002-1915::REFERENCE:CVE-2002-0051:DESCRIPTION: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.:LINK:https://www.cve.org/CVERecord?id=CVE-2002-0051::REFERENCE:CVE-2000-0338:DESCRIPTION:Chain: predictable file names used for locking, allowing attacker to create the lock beforehand. Resultant from permissions and randomness.:LINK:https://www.cve.org/CVERecord?id=CVE-2000-0338::REFERENCE:CVE-2000-1198:DESCRIPTION:Chain: Lock files with predictable names. Resultant from randomness.:LINK:https://www.cve.org/CVERecord?id=CVE-2000-1198::REFERENCE:CVE-2002-1869:DESCRIPTION: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.:LINK:https://www.cve.org/CVERecord?id=CVE-2002-1869::



Notes: ::TYPE:Relationship:NOTE:This 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.::