Description
The product does not maintain or incorrectly maintains control over a resource throughout its lifetime of creation, use, and release.
Resources often have explicit instructions on how to be created, used and destroyed. When code does not follow these instructions, it can lead to unexpected behaviors and potentially exploitable states. Even without explicit instructions, various principles are expected to be adhered to, such as "Do not use an object until after its creation is complete," or "do not use an object after it has been slated for destruction."
Potential Impact
Other
Other
Demonstrative Examples
sock=socket(AF_INET, SOCK_STREAM, 0);while (1) {newsock=accept(sock, ...);printf("A connection has been accepted\n");pid = fork();}Detection Methods
- Automated Static Analysis — Use Static analysis tools to check for unreleased resources.
Real-World CVE Examples
| CVE ID | Description |
|---|---|
| CVE-2018-1000613 | Cryptography API uses unsafe reflection when deserializing a private key |
| CVE-2019-19911 | Chain: Python library does not limit the resources used to process images that specify a very large number of bands (CWE-1284), leading to excessive memory consumption (CWE-789) or an integer overflow |
Taxonomy Mappings
- CERT C Secure Coding: FIO39-C — Do not alternately input and output from a stream without an intervening flush or positioning call
Frequently Asked Questions
What is CWE-664?
CWE-664 (Improper Control of a Resource Through its Lifetime) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Pillar-level weakness. The product does not maintain or incorrectly maintains control over a resource throughout its lifetime of creation, use, and release.
How can CWE-664 be exploited?
Attackers can exploit CWE-664 (Improper Control of a Resource Through its Lifetime) to other. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-664?
Follow secure coding practices, conduct code reviews, and use automated security testing tools (SAST/DAST) to detect this weakness early in the development lifecycle.
What is the severity of CWE-664?
CWE-664 is classified as a Pillar-level weakness (Foundational abstraction). It has been observed in 2 real-world CVEs.