CWE-404 · Słabość
Improper Resource Shutdown or Release
- Abstrakcja
- Klasa
- Status
- Szkic
- Ryzyko wykorzystania
- średnie
- Dodano
- 19 lipca 2006
- Ostatnia zmiana
- 26 października 2023
Opis
The product does not release or incorrectly releases a resource before it is made available for re-use.
When a resource is created or allocated, the developer is responsible for properly releasing the resource as well as accounting for all potential paths of expiration or invalidation, such as a set period of time or revocation.
Skutki
Availability, Other
DoS: Resource Consumption (Other); Varies by Context
Most unreleased resource issues result in general software reliability problems, but if an attacker can intentionally trigger a resource leak, the attacker might be able to launch a denial of service attack by depleting the resource pool.
Confidentiality
Read Application Data
When a resource containing sensitive information is not correctly shutdown, it may expose the sensitive data in a subsequent allocation.
Zapobieganie
Requirements · Language Selection
Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.
For example, languages such as Java, Ruby, and Lisp perform automatic garbage collection that releases memory for objects that have been deallocated.
Implementation
It is good practice to be responsible for freeing all resources you allocate and to be consistent with how and where you free memory in a function. If you allocate memory that you intend to free upon completion of the function, you must be sure to free the memory at all exit points for that function including error conditions.
Implementation
Memory should be allocated/freed using matching functions such as malloc/free, new/delete, and new[]/delete[].
Implementation
When releasing a complex object or structure, ensure that you properly dispose of all of its member components, not just the object itself.
Przykłady podatności
- CVE-1999-1127 Does not shut down named pipe connections if malformed data is sent.
- CVE-2001-0830 Sockets not properly closed when attacker repeatedly connects and disconnects from server.
- CVE-2002-1372 Chain: Return values of file/socket operations are not checked (CWE-252), allowing resultant consumption of file descriptors (CWE-772).
Słabość nadrzędna
Pokrewna
Może prowadzić do
Słabości podrzędne
- CWE-299 Improper Check for Certificate Revocation
- CWE-401 Missing Release of Memory after Effective Lifetime
- CWE-459 Incomplete Cleanup
- CWE-761 Free of Pointer not at Start of Buffer
- CWE-762 Mismatched Memory Management Routines
- CWE-763 Release of Invalid Pointer or Reference
- CWE-772 Missing Release of Resource after Effective Lifetime
- CWE-775 Missing Release of File Descriptor or Handle after Effective Lifetime
- CWE-1266 Improper Scrubbing of Sensitive Data from Decommissioned Device
Kiedy powstaje
- Implementation
Dotyczy
Not Language-Specific
Uwagi
Overlaps memory leaks, asymmetric resource consumption, malformed input errors.
Źródła
- 24 Deadly Sins of Software Security — Michael Howard, David LeBlanc, John Viega, "Sin 8: C++ Catastrophes." Page 143, McGraw-Hill, 2010
Wpis z katalogu CWE 4.20.