Code typically requires "opening" handles or references to resources such as memory, files, devices, socket connections, services, etc. When the code is finished with using the resource, it is typically expected to "close" or "release" the resource, which indicates to the environment (such as the OS) that the resource can be re-assigned or reused by unrelated processes or actors - or in some cases, within the same process. API functions or other abstractions are often used to perform this release, such as free() or delete() within C/C++, or file-handle close() operations that are used in many languages.
Unfortunately, the implementation or design of such APIs might expect the developer to be responsible for ensuring that such APIs are only called once per release of the resource. If the developer attempts to release the same resource/handle more than once, then the API's expectations are not met, resulting in undefined and/or insecure behavior. This could lead to consequences such as memory corruption, data corruption, execution path corruption, or other consequences.
Note that while the implementation for most (if not all) resource reservation allocations involve a unique identifier/pointer/symbolic reference, then if this identifier is reused, checking the identifier for resource closure may result in a false state of openness and closing of the wrong resource. For this reason, reuse of identifiers is discouraged.
Scope | Impact | Likelihood |
---|---|---|
Availability Integrity | DoS: Crash, Exit, or Restart | Medium |
References | Description |
---|---|
CVE-2019-13351 | file descriptor double close can cause the wrong file to be associated with a file descriptor. |
CVE-2006-5051 | Chain: Signal handler contains too much functionality (CWE-828), introducing a race condition that leads to a double free (CWE-415). |
CVE-2004-0772 | Double free resultant from certain error conditions. |
Name | Organization | Date | Date release | Version |
---|---|---|---|---|
CWE Content Team | MITRE | 4.6 |
Name | Organization | Date | Comment |
---|---|---|---|
CWE Content Team | MITRE | updated Demonstrative_Examples, Description, Potential_Mitigations | |
CWE Content Team | MITRE | updated References | |
CWE Content Team | MITRE | updated Relationships | |
CWE Content Team | MITRE | updated Mapping_Notes |