Missing Reference to Active File Descriptor or Handle

Incomplete Variant
Structure: Simple
Description

This vulnerability occurs when a program fails to keep track of open files or resources, preventing the system from properly closing and reclaiming them.

Extended Description

When a file, network socket, or other system resource is opened, the operating system assigns it a unique identifier called a file descriptor or handle. If the software loses its reference to this identifier—for example, by overwriting a variable or exiting a scope without closing it—the resource remains allocated but unusable. This is often called a resource leak. Over time, these unreleased resources accumulate. Since operating systems impose strict limits on the total number of file descriptors available per process, the application can eventually exhaust this pool. When all descriptors are consumed, the program will fail to open new files, establish network connections, or even crash, potentially causing a denial-of-service condition for itself and other processes on the system.

Common Consequences 1
Scope: Availability

Impact: DoS: Resource Consumption (Other)

An attacker that can influence the allocation of resources that are not properly maintained could deplete the available resource pool and prevent all other processes from accessing the same type of resource.

Potential Mitigations 1
Phase: OperationArchitecture and Design

Strategy: Resource Limitation

Use resource-limiting settings provided by the operating system or environment. For example, when managing system resources in POSIX, setrlimit() can be used to set limits for certain types of resources, and getrlimit() can determine how many resources are available. However, these functions are not available on all operating systems. When the current levels get close to the maximum that is defined for the application (see Allocation of Resources Without Limits or Throttling), then limit the allocation of further resources to privileged users; alternately, begin releasing resources for less-privileged users. While this mitigation may protect the system from attack, it will not necessarily stop attackers from adversely impacting other users. Ensure that the application performs the appropriate error checks and error handling in case resources become unavailable (Improper Check or Handling of Exceptional Conditions).
Modes of Introduction
Implementation
Taxonomy Mapping
  • CERT C Secure Coding
  • Software Fault Patterns