Logo
-

Byte Open Security

(ByteOS Network)

Log In

Sign Up

ByteOS

Security
Vulnerability Details
Registries
Custom Views
Weaknesses
Attack Patterns
Filters & Tools
CWE-672:Operation on a Resource after Expiration or Release
Weakness ID:672
Version:v4.17
Weakness Name:Operation on a Resource after Expiration or Release
Vulnerability Mapping:Allowed-with-Review
Abstraction:Class
Structure:Simple
Status:Draft
Likelihood of Exploit:
DetailsContent HistoryObserved CVE ExamplesReports
▼Description

The product uses, accesses, or otherwise operates on a resource after that resource has been expired, released, or revoked.

▼Extended Description

▼Alternate Terms
▼Relationships
Relevant to the view"Research Concepts - (1000)"
NatureMappingTypeIDName
ChildOfDiscouragedC666Operation on Resource in Wrong Phase of Lifetime
ParentOfAllowedB1341Multiple Releases of Same Resource or Handle
ParentOfAllowedV298Improper Validation of Certificate Expiration
ParentOfAllowedB324Use of a Key Past its Expiration Date
ParentOfAllowedB562Return of Stack Variable Address
ParentOfAllowedB613Insufficient Session Expiration
ParentOfAllowedB825Expired Pointer Dereference
ParentOfAllowedB826Premature Release of Resource During Expected Lifetime
ParentOfAllowedB910Use of Expired File Descriptor
ParentOfAllowedB911Improper Update of Reference Count
Nature: ChildOf
Mapping: Discouraged
Type: Class
ID: 666
Name: Operation on Resource in Wrong Phase of Lifetime
Nature: ParentOf
Mapping: Allowed
Type: Base
ID: 1341
Name: Multiple Releases of Same Resource or Handle
Nature: ParentOf
Mapping: Allowed
Type: Variant
ID: 298
Name: Improper Validation of Certificate Expiration
Nature: ParentOf
Mapping: Allowed
Type: Base
ID: 324
Name: Use of a Key Past its Expiration Date
Nature: ParentOf
Mapping: Allowed
Type: Base
ID: 562
Name: Return of Stack Variable Address
Nature: ParentOf
Mapping: Allowed
Type: Base
ID: 613
Name: Insufficient Session Expiration
Nature: ParentOf
Mapping: Allowed
Type: Base
ID: 825
Name: Expired Pointer Dereference
Nature: ParentOf
Mapping: Allowed
Type: Base
ID: 826
Name: Premature Release of Resource During Expected Lifetime
Nature: ParentOf
Mapping: Allowed
Type: Base
ID: 910
Name: Use of Expired File Descriptor
Nature: ParentOf
Mapping: Allowed
Type: Base
ID: 911
Name: Improper Update of Reference Count
▼Memberships
NatureMappingTypeIDName
MemberOfProhibitedC8082010 Top 25 - Weaknesses On the Cusp
MemberOfProhibitedV884CWE Cross-section
MemberOfProhibitedC983SFP Secondary Cluster: Faulty Resource Use
MemberOfProhibitedV1003Weaknesses for Simplified Mapping of Published Vulnerabilities
MemberOfProhibitedC1131CISQ Quality Measures (2016) - Security
MemberOfProhibitedC1162SEI CERT C Coding Standard - Guidelines 08. Memory Management (MEM)
MemberOfProhibitedC1163SEI CERT C Coding Standard - Guidelines 09. Input Output (FIO)
MemberOfProhibitedC1306CISQ Quality Measures - Reliability
MemberOfProhibitedC1308CISQ Quality Measures - Security
MemberOfProhibitedV1340CISQ Data Protection Measures
MemberOfProhibitedC1415Comprehensive Categorization: Resource Control
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 808
Name: 2010 Top 25 - Weaknesses On the Cusp
Nature: MemberOf
Mapping: Prohibited
Type:View
ID: 884
Name: CWE Cross-section
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 983
Name: SFP Secondary Cluster: Faulty Resource Use
Nature: MemberOf
Mapping: Prohibited
Type:View
ID: 1003
Name: Weaknesses for Simplified Mapping of Published Vulnerabilities
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 1131
Name: CISQ Quality Measures (2016) - Security
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 1162
Name: SEI CERT C Coding Standard - Guidelines 08. Memory Management (MEM)
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 1163
Name: SEI CERT C Coding Standard - Guidelines 09. Input Output (FIO)
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 1306
Name: CISQ Quality Measures - Reliability
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 1308
Name: CISQ Quality Measures - Security
Nature: MemberOf
Mapping: Prohibited
Type:View
ID: 1340
Name: CISQ Data Protection Measures
Nature: MemberOf
Mapping: Prohibited
Type:Category
ID: 1415
Name: Comprehensive Categorization: Resource Control
▼Tags
NatureMappingTypeIDName
MemberOfProhibitedBSBOSS-294Not Language-Specific Weaknesses
MemberOfProhibitedBSBOSS-306Mobile (technology class) Weaknesses
MemberOfProhibitedBSBOSS-312Other (impact)
MemberOfProhibitedBSBOSS-318Modify Application Data (impact)
MemberOfProhibitedBSBOSS-324DoS: Crash, Exit, or Restart (impact)
MemberOfProhibitedBSBOSS-328Read Application Data (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-294
Name: Not Language-Specific Weaknesses
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-306
Name: Mobile (technology class) Weaknesses
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-312
Name: Other (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-318
Name: Modify Application Data (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-324
Name: DoS: Crash, Exit, or Restart (impact)
Nature: MemberOf
Mapping: Prohibited
Type:BOSSView
ID: BOSS-328
Name: Read Application Data (impact)
▼Relevant To View
Relevant to the view"Weaknesses Addressed by the SEI CERT C Coding Standard - (1154)"
NatureMappingTypeIDName
MemberOfProhibitedC1162SEI CERT C Coding Standard - Guidelines 08. Memory Management (MEM)
Nature: MemberOf
Mapping: Prohibited
Type: Category
ID: 1162
Name: SEI CERT C Coding Standard - Guidelines 08. Memory Management (MEM)
Relevant to the view"Weaknesses Addressed by the SEI CERT C Coding Standard - (1154)"
NatureMappingTypeIDName
MemberOfProhibitedC1163SEI CERT C Coding Standard - Guidelines 09. Input Output (FIO)
Nature: MemberOf
Mapping: Prohibited
Type: Category
ID: 1163
Name: SEI CERT C Coding Standard - Guidelines 09. Input Output (FIO)
Relevant to the view"CISQ Quality Measures (2020) - (1305)"
NatureMappingTypeIDName
MemberOfProhibitedC1306CISQ Quality Measures - Reliability
Nature: MemberOf
Mapping: Prohibited
Type: Category
ID: 1306
Name: CISQ Quality Measures - Reliability
Relevant to the view"CISQ Quality Measures (2020) - (1305)"
NatureMappingTypeIDName
MemberOfProhibitedC1308CISQ Quality Measures - Security
Nature: MemberOf
Mapping: Prohibited
Type: Category
ID: 1308
Name: CISQ Quality Measures - Security
Relevant to the view"Software Fault Pattern (SFP) Clusters - (888)"
NatureMappingTypeIDName
MemberOfProhibitedC983SFP Secondary Cluster: Faulty Resource Use
Nature: MemberOf
Mapping: Prohibited
Type: Category
ID: 983
Name: SFP Secondary Cluster: Faulty Resource Use
▼Background Detail

▼Common Consequences
ScopeLikelihoodImpactNote
IntegrityConfidentialityN/AModify Application DataRead Application Data

If a released resource is subsequently reused or reallocated, then an attempt to use the original resource might allow access to sensitive data that is associated with a different user or entity.

OtherAvailabilityN/AOtherDoS: Crash, Exit, or Restart

When a resource is released it might not be in an expected state, later attempts to access the resource may lead to resultant errors that may lead to a crash.

Scope: Integrity, Confidentiality
Likelihood: N/A
Impact: Modify Application Data, Read Application Data
Note:

If a released resource is subsequently reused or reallocated, then an attempt to use the original resource might allow access to sensitive data that is associated with a different user or entity.

Scope: Other, Availability
Likelihood: N/A
Impact: Other, DoS: Crash, Exit, or Restart
Note:

When a resource is released it might not be in an expected state, later attempts to access the resource may lead to resultant errors that may lead to a crash.

▼Potential Mitigations
▼Modes Of Introduction
Phase: Implementation
Note:

N/A

Phase: Operation
Note:

N/A

▼Applicable Platforms
Languages
Class: Not Language-Specific(Undetermined Prevalence)
Technology
Class: Mobile(Undetermined Prevalence)
▼Demonstrative Examples
Example 1

The following code shows a simple example of a use after free error:

Language: ( code)
N/A

Language: C(Bad code)
char* ptr = (char*)malloc (SIZE); if (err) { abrt = 1; free(ptr); } ... if (abrt) { logError("operation aborted before commit", ptr); }

Language: ( code)
N/A

When an error occurs, the pointer is immediately freed. However, this pointer is later incorrectly used in the logError function.

Example 2

The following code shows a simple example of a double free error:

Language: ( code)
N/A

Language: C(Bad code)
char* ptr = (char*)malloc (SIZE); ... if (abrt) { free(ptr); } ... free(ptr);

Language: ( code)
N/A

Double free vulnerabilities have two common (and sometimes overlapping) causes:

Language: ( code)
N/A
  • Error conditions and other exceptional circumstances
  • Confusion over which part of the program is responsible for freeing the memory

Language: ( code)
N/A

Although some double free vulnerabilities are not much more complicated than the previous example, most are spread out across hundreds of lines of code or even different files. Programmers seem particularly susceptible to freeing global variables more than once.

Example 3

In the following C/C++ example the method processMessage is used to process a message received in the input array of char arrays. The input message array contains two char arrays: the first is the length of the message and the second is the body of the message. The length of the message is retrieved and used to allocate enough memory for a local char array, messageBody, to be created for the message body. The messageBody is processed in the method processMessageBody that will return an error if an error occurs while processing. If an error occurs then the return result variable is set to indicate an error and the messageBody char array memory is released using the method free and an error message is sent to the logError method.

Language: ( code)
N/A

Language: C(Bad code)
#define FAIL 0 #define SUCCESS 1 #define ERROR -1 #define MAX_MESSAGE_SIZE 32 int processMessage(char **message) { int result = SUCCESS; int length = getMessageLength(message[0]); char *messageBody; if ((length > 0) && (length < MAX_MESSAGE_SIZE)) { messageBody = (char*)malloc(length*sizeof(char)); messageBody = &message[1][0]; int success = processMessageBody(messageBody); if (success == ERROR) { result = ERROR; free(messageBody); } } else { printf("Unable to process message; invalid message length"); result = FAIL; } if (result == ERROR) { logError("Error processing message", messageBody); } return result; }

Language: ( code)
N/A

However, the call to the method logError includes the messageBody after the memory for messageBody has been released using the free method. This can cause unexpected results and may lead to system crashes. A variable should never be used after its memory resources have been released.

Language: C(Good code)
... messageBody = (char*)malloc(length*sizeof(char)); messageBody = &message[1][0]; int success = processMessageBody(messageBody); if (success == ERROR) { result = ERROR; logError("Error processing message", messageBody); free(messageBody); } ...

▼Observed Examples
ReferenceDescription
CVE-2009-3547
Chain: race condition (CWE-362) might allow resource to be released before operating on it, leading to NULL dereference (CWE-476)
Reference: CVE-2009-3547
Description:
Chain: race condition (CWE-362) might allow resource to be released before operating on it, leading to NULL dereference (CWE-476)
▼Affected Resources
    ▼Functional Areas
      ▼Weakness Ordinalities
      OrdinalityDescription
      ▼Detection Methods
      ▼Vulnerability Mapping Notes
      Usage:Allowed-with-Review
      Reason:Abstraction
      Rationale:

      This CWE entry is a Class and might have Base-level children that would be more appropriate

      Comments:

      Examine children of this entry to see if there is a better fit

      Suggestions:
      ▼Notes
      ▼Taxonomy Mappings
      Taxonomy NameEntry IDFitEntry Name
      Software Fault PatternsSFP15N/AFaulty Resource Use
      CERT C Secure CodingFIO46-CCWE More AbstractDo not access a closed file
      CERT C Secure CodingMEM30-CCWE More AbstractDo not access freed memory
      OMG ASCSMASCSM-CWE-672N/AN/A
      Taxonomy Name: Software Fault Patterns
      Entry ID: SFP15
      Fit: N/A
      Entry Name: Faulty Resource Use
      Taxonomy Name: CERT C Secure Coding
      Entry ID: FIO46-C
      Fit: CWE More Abstract
      Entry Name: Do not access a closed file
      Taxonomy Name: CERT C Secure Coding
      Entry ID: MEM30-C
      Fit: CWE More Abstract
      Entry Name: Do not access freed memory
      Taxonomy Name: OMG ASCSM
      Entry ID: ASCSM-CWE-672
      Fit: N/A
      Entry Name: N/A
      ▼Related Attack Patterns
      IDName
      ▼References
      Reference ID: REF-962
      Title: Automated Source Code Security Measure (ASCSM)
      Author: Object Management Group (OMG)
      Section: ASCSM-CWE-672
      Publication:
      Publisher:
      Edition:
      URL:http://www.omg.org/spec/ASCSM/1.0/
      URL Date:
      Day:N/A
      Month:01
      Year:2016
      Details not found