The product dereferences a pointer that contains a location for memory that was previously valid, but is no longer valid.
View on MITREWhen 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.
If the expired pointer is used in a read operation, an attacker might be able to control data read in by the application.
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.
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.
Choose a language that provides automatic memory management.
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.
No detection method information available for this CWE.
The following code shows a simple example of a use after free error:
When an error occurs, the pointer is immediately freed. However, this pointer is later incorrectly used in the logError function.
The following code shows a simple example of a double free error:
Double free vulnerabilities have two common (and sometimes overlapping) causes:
stale pointer issue leads to denial of service and possibly other consequences
View DetailsChain: 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.
View Detailsread of value at an offset into a structure after the offset is no longer valid
View DetailsCWE-825: Expired Pointer Dereference is a Common Weakness Enumeration (CWE) entry maintained by MITRE. The product dereferences a pointer that contains a location for memory that was previously valid, but is no longer valid. 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.
If exploited, CWE-825 (Expired Pointer Dereference) it can compromise Confidentiality, Availability and Integrity, leading to outcomes such as Read Memory, DoS: Crash, Exit, or Restart and Execute Unauthorized Code or Commands.
Recommended mitigations for CWE-825 include: Choose a language that provides automatic memory management. 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.
CWE-825 commonly affects C and C++. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.
MITRE documents real CVEs mapped to CWE-825, including CVE-2008-5013, CVE-2010-3257, CVE-2008-0062 and CVE-2007-1211. You can look up the full details of each CVE, including CVSS scores and remediation guidance, on our CVE Lookup tool.
A CWE (Common Weakness Enumeration) like CWE-825 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.