CWE-664: Improper Control of a Resource Through its… | Glexia
CWE-664 (Improper Control of a Resource Through its Lifetime) weakness overview with consequences, detection methods, mitigations, related CVEs and MITRE ATT&CK…
Glexia's Take · Automated analysis
CWE-664: Improper Control of a Resource Through its Lifetime
Improper Control of a Resource Through its Lifetime represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.
Executive Impact
- Other: Other
Developer Pattern
CWE-664 is the kind of defect developers can usually prevent with explicit validation, safer framework defaults, and tests that exercise hostile input or unsafe state transitions.
Automation confidence
high confidence from CWE-664, 4.20.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Official CWE Definition
CWE-664: Improper Control of a Resource Through its Lifetime
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."
Developer And Remediation Guidance
How teams prevent and detect this weakness
Causes
- This code allocates a socket and forks each time it receives a new connection. The program does not track how many connections have been made, and it does not limit the number of connections. Because forking is a relatively expensive operation, an attacker would be able to cause the system to run out of CPU, processes, or memory by making a large number of connections. Alternatively, an attacker could consume all available connections, preventing others from accessing the system remotely.
Remediation
- Use safe APIs
- Centralize the control
- Add regression tests
- Review logs and telemetry for attempted abuse
Detection
- Automated Static Analysis: Use Static analysis tools to check for unreleased resources.
Mappings
Related CVEs, CWEs, and ATT&CK context
Related CWEs
- CWE-118: Incorrect Access of Indexable Resource ('Range Error')
- CWE-1229: Creation of Emergent Resource
- CWE-1250: Improper Preservation of Consistency Between Independent Representations of Shared State
- CWE-1329: Reliance on Component That is Not Updateable
- CWE-221: Information Loss or Omission
- CWE-372: Incomplete Internal State Distinction
- CWE-400: Uncontrolled Resource Consumption
- CWE-404: Improper Resource Shutdown or Release
- CWE-410: Insufficient Resource Pool
- CWE-471: Modification of Assumed-Immutable Data (MAID)
- CWE-487: Reliance on Package-level Scope
- CWE-495: Private Data Structure Returned From A Public Method
ATT&CK Relevance
ATT&CK relevance is shown only when reviewed or responsibly inferred.
