CWE-412: Unrestricted Externally Accessible Lock
CWE版本: 4.18
更新日期: 2025-09-09
弱点描述
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.
常见后果
影响范围: 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.
潜在缓解措施
阶段: 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.
检测方法
方法: 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.
观察示例
参考: 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.
引入模式
| 阶段 | 说明 |
|---|---|
| Architecture and Design | - |
| Implementation | - |
适用平台
编程语言
分类映射
| 分类名称 | 条目ID | 条目名称 | 映射适配度 |
|---|---|---|---|
| PLOVER | - | Unrestricted Critical Resource Lock | - |
| 7 Pernicious Kingdoms | - | Deadlock | - |
| OWASP Top Ten 2004 | A9 | Denial of Service | CWE More Specific |
| The CERT Oracle Secure Coding Standard for Java (2011) | LCK00-J | Use private final lock objects to synchronize classes that may interact with untrusted code | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | LCK07-J | Avoid deadlock by requesting and releasing locks in the same order | - |
| Software Fault Patterns | SFP22 | Unrestricted lock | - |