CWEweakness

CWE-765 Multiple Unlocks of a Critical Resource

Official page ↗
Abstraction
Base
Structure
Simple
Status
Incomplete
Languages
Not Language-Specific
CWE version
5.0

Description

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

Common consequences

• Availability, Integrity: DoS: Crash, Exit, or Restart, Modify Memory, Unexpected State — 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 mitigations

• [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: 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 searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Observed examples

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

Related

Observed example · CVE (1)

  • CVE-2009-0935 The inotify_read function in the Linux kernel 2.6.27 to 2.6.27.13, 2.6.28 to 2.6.28.2, and 2.6.29-rc3 allows local users to cause a denial… vulnerability

Child of · CWE (2)

  • CWE-667 Improper Locking weakness
  • CWE-675 Multiple Operations on Resource in Single-Operation Context weakness

Referenced by CVE · weakness (1)

  • CVE-2024-49602 Dell PowerScale OneFS Versions 8.2.2.x through 9.8.0.x contain an improper resource unlocking vulnerability. vulnerability