Base · Medium

CWE-765: Multiple Unlocks of a Critical Resource

The product unlocks a critical resource more times than intended, leading to an unexpected state in the system.

CWE-765 · Base Level ·1 CVEs ·1 Mitigations

Description

The product unlocks a critical resource more times than intended, leading to an unexpected state in the system.

When the product is operating in a concurrent environment and repeatedly unlocks a critical resource, the consequences will vary based on the type of lock, the lock's implementation, and the resource being protected. In some situations such as with semaphores, the resources are pooled and extra calls to unlock will increase the count for the number of available resources, likely resulting in a crash or unpredictable behavior when the system nears capacity.

Potential Impact

Availability, Integrity

DoS: Crash, Exit, or Restart, Modify Memory, Unexpected State

Mitigations & Prevention

Implementation

When locking and unlocking a resource, try to be sure that all control paths through the code in which the resource is locked one or more times correspond to exactly as many unlocks. If the product acquires a lock and then determines it is not able to perform its intended behavior, be sure to release the lock(s) before waiting for conditions to improve. Reacquire the lock(s) before trying again.

Detection Methods

  • Automated Static Analysis High — Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then sea

Real-World CVE Examples

CVE IDDescription
CVE-2009-0935Attacker provides invalid address to a memory-reading function, causing a mutex to be unlocked twice

Taxonomy Mappings

  • Software Fault Patterns: SFP21 — Multiple locks/unlocks

Frequently Asked Questions

What is CWE-765?

CWE-765 (Multiple Unlocks of a Critical Resource) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product unlocks a critical resource more times than intended, leading to an unexpected state in the system.

How can CWE-765 be exploited?

Attackers can exploit CWE-765 (Multiple Unlocks of a Critical Resource) to dos: crash, exit, or restart, modify memory, unexpected state. This weakness is typically introduced during the Implementation phase of software development.

How do I prevent CWE-765?

Key mitigations include: When locking and unlocking a resource, try to be sure that all control paths through the code in which the resource is locked one or more times correspond to exactly as many unlocks. If the product ac

What is the severity of CWE-765?

CWE-765 is classified as a Base-level weakness (Medium abstraction). It has been observed in 1 real-world CVEs.