CWE - CWE-825: Expired Pointer Dereference (4.19.1)
Weakness ID: 825
Vulnerability Mapping: ALLOWED This CWE ID may be used to map to real-world vulnerabilitiesAbstraction: Base Base - a weakness that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource.
Description
The product dereferences a pointer that contains a location for memory that was previously valid, but is no longer valid.
Extended Description
When a product releases memory, but it maintains a pointer to that memory, then the memory might be re-allocated at a later time. If the original pointer is accessed to read or write data, then this could cause the product to read or modify data that is in use by a different function or process. Depending on how the newly-allocated memory is used, this could lead to a denial of service, information exposure, or code execution.
Alternate Terms
Common Consequences
This table specifies different individual consequences
associated with the weakness. The Scope identifies the application security area that is
violated, while the Impact describes the negative technical impact that arises if an
adversary succeeds in exploiting this weakness. The Likelihood provides information about
how likely the specific consequence is expected to be seen relative to the other
consequences in the list. For example, there may be high likelihood that a weakness will be
exploited to achieve a certain impact, but a low likelihood that it will be exploited to
achieve a different impact.
| Impact | Details |
|---|---|
|
Read Memory |
Scope: Confidentiality
If the expired pointer is used in a read operation, an attacker might be able to control data read in by the application. |
|
DoS: Crash, Exit, or Restart |
Scope: Availability
If the expired pointer references a memory location that is not accessible to the product, or points to a location that is "malformed" (such as NULL) or larger than expected by a read or write operation, then a crash may occur. |
|
Execute Unauthorized Code or Commands |
Scope: Integrity, Confidentiality, Availability
If the expired pointer is used in a function call, or points to unexpected data in a write operation, then code execution may be possible. |
Potential Mitigations
| Phase(s) | Mitigation |
|---|---|
|
Architecture and Design |
Choose a language that provides automatic memory management. |
|
Implementation |
When freeing pointers, be sure to set them to NULL once they are freed. However, the utilization of multiple or complex data structures may lower the usefulness of this strategy. |
Relationships
This table shows the weaknesses and high level categories that are related to this
weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to
similar items that may exist at higher and lower levels of abstraction. In addition,
relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user
may want to explore.
Relevant to the view "Research Concepts" (View-1000)
| Nature | Type | ID | Name |
|---|---|---|---|
| ChildOf |
|
119 | Improper Restriction of Operations within the Bounds of a Memory Buffer |
| ChildOf |
|
672 | Operation on a Resource after Expiration or Release |
| ParentOf |
|
415 | Double Free |
| ParentOf |
|
416 | Use After Free |
| CanFollow |
|
562 | Return of Stack Variable Address |
| CanPrecede |
|
125 | Out-of-bounds Read |
| CanPrecede |
|
787 | Out-of-bounds Write |
Relevant to the view "Software Development" (View-699)
| Nature | Type | ID | Name |
|---|---|---|---|
| MemberOf |
|
465 | Pointer Issues |
Relevant to the view "CISQ Quality Measures (2020)" (View-1305)
| Nature | Type | ID | Name |
|---|---|---|---|
| ChildOf |
|
119 | Improper Restriction of Operations within the Bounds of a Memory Buffer |
Relevant to the view "CISQ Data Protection Measures" (View-1340)
| Nature | Type | ID | Name |
|---|---|---|---|
| ChildOf |
|
119 | Improper Restriction of Operations within the Bounds of a Memory Buffer |
Modes
Of Introduction
The different Modes of Introduction provide information
about how and when this
weakness may be introduced. The Phase identifies a point in the life cycle at which
introduction
may occur, while the Note provides a typical scenario related to introduction during the
given
phase.
| Phase | Note |
|---|---|
| Implementation |
Applicable Platforms
This listing shows possible areas for which the given
weakness could appear. These
may be for specific named Languages, Operating Systems, Architectures, Paradigms,
Technologies,
or a class of such platforms. The platform is listed along with how frequently the given
weakness appears for that instance.
| Languages |
Class: Memory-Unsafe (Undetermined Prevalence) C (Undetermined Prevalence) C++ (Undetermined Prevalence) |
Demonstrative Examples
Example 1
The following code shows a simple example of a use after free error:
(bad code)
Example Language: C
char* ptr = (char*)malloc (SIZE);
if (err) {
abrt = 1;
free(ptr);
}
...
if (abrt) {
logError("operation aborted before commit", ptr);
}
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:
(bad code)
Example Language: C
char* ptr = (char*)malloc (SIZE);
...
if (abrt) {
free(ptr);
}
...
free(ptr);
Double free vulnerabilities have two common (and sometimes overlapping) causes:
-
Error conditions and other exceptional circumstances
-
Confusion over which part of the program is responsible for freeing the memory
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.
Selected Observed
Examples
Note: this is a curated list of examples for users to understand the variety of ways in which this weakness can be introduced. It is not a complete list of all CVEs that are related to this CWE entry.
| Reference | Description |
|---|---|
|
Chain: IPSec VPN product uses the same variable for multiple purposes in the same function (CWE-1109), leading to incorrect access control (CWE-284) and expired pointer dereference (CWE-825) |
|
|
access of expired memory address leads to arbitrary code execution |
|
|
stale pointer issue leads to denial of service and possibly other consequences |
|
|
Chain: a message having an unknown message type may cause a reference to uninitialized memory resulting in a null pointer dereference (CWE-476) or dangling pointer (CWE-825), possibly crashing the system or causing heap corruption. |
|
|
read of value at an offset into a structure after the offset is no longer valid |
Weakness Ordinalities
| Ordinality | Description |
|---|---|
|
Resultant |
(where the weakness is typically related to the presence of some other weaknesses) |
Detection
Methods
| Method | Details |
|---|---|
|
Automated Static Analysis |
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.) |
|
Automated Dynamic Analysis |
Use tools that are integrated during compilation to insert runtime error-checking mechanisms related to memory safety errors, such as AddressSanitizer (ASan) for C/C++ [REF-1518]. Effectiveness: Moderate Note:Crafted inputs are necessary to reach the code containing the error, such as generated by fuzzers. Also, these tools may reduce performance, and they only report the error condition - not the original mistake that led to the error. |
Functional Areas
- Memory Management
Affected Resources
- Memory
Memberships
This MemberOf Relationships table shows additional CWE Categories and Views that
reference this weakness as a member. This information is often useful in understanding where a
weakness fits within the context of external information sources.
Vulnerability Mapping Notes
| Usage |
ALLOWED
(this CWE ID may be used to map to real-world vulnerabilities) |
| Reason | Acceptable-Use |
|
Rationale |
This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities. |
|
Comments |
Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction. |
Notes
Terminology
Many weaknesses related to pointer dereferences fall under the general term of "memory corruption" or "memory safety." As of September 2010, there is no commonly-used terminology that covers the lower-level variants.
Maintenance
There are close relationships between incorrect pointer dereferences and other weaknesses related to buffer operations. There may not be sufficient community agreement regarding these relationships. Further study is needed to determine when these relationships are chains, composites, perspective/layering, or other types of relationships. As of September 2010, most of the relationships are being captured as chains.
References
Content
History
Submissions |
||
|---|---|---|
| Submission Date | Submitter | Organization |
|
2010-09-22
(CWE 1.10, 2010-09-27) |
CWE Content Team | MITRE |
Modifications |
||
| Modification Date | Modifier | Organization |
|
2025-12-11
(CWE 4.19, 2025-12-11) |
CWE Content Team | MITRE |
| updated Applicable_Platforms, Detection_Factors, Observed_Examples, References, Time_of_Introduction, Weakness_Ordinalities | ||
|
2025-09-09
(CWE 4.18, 2025-09-09) |
CWE Content Team | MITRE |
| updated Affected_Resources, Functional_Areas | ||
|
2025-04-03
(CWE 4.17, 2025-04-03) |
CWE Content Team | MITRE |
| updated Applicable_Platforms | ||
| 2023-06-29 | CWE Content Team | MITRE |
| updated Mapping_Notes | ||
| 2023-04-27 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2023-01-31 | CWE Content Team | MITRE |
| updated Common_Consequences, Description | ||
| 2022-04-28 | CWE Content Team | MITRE |
| updated Research_Gaps | ||
| 2021-03-15 | CWE Content Team | MITRE |
| updated Observed_Examples | ||
| 2020-12-10 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2020-08-20 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2020-02-24 | CWE Content Team | MITRE |
| updated Relationships | ||
| 2013-02-21 | CWE Content Team | MITRE |
| updated Alternate_Terms | ||
| 2012-05-11 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, Relationships | ||
| 2011-06-27 | CWE Content Team | MITRE |
| updated Demonstrative_Examples, Potential_Mitigations, Relationships | ||
