CWE-415: Double Free

Export to Word

Description

The product calls free() twice on the same memory address.

Extended Description

N/A


ThreatScore

Threat Mapped score: 0.0

Industry: Finiancial

Threat priority: Unclassified


Observed Examples (CVEs)

Related Attack Patterns (CAPEC)

N/A


Attack TTPs

N/A

Modes of Introduction

Phase Note
Implementation N/A

Common Consequences

Potential Mitigations

Applicable Platforms


Demonstrative Examples

Intro: The following code shows a simple example of a double free vulnerability.

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

char* ptr = (char*)malloc (SIZE); ... if (abrt) { free(ptr); } ... free(ptr);

Intro: While contrived, this code should be exploitable on Linux distributions that do not ship with heap-chunk check summing turned on.

#include <stdio.h> #include <unistd.h> #define BUFSIZE1 512 #define BUFSIZE2 ((BUFSIZE1/2) - 8) int main(int argc, char **argv) { char *buf1R1; char *buf2R1; char *buf1R2; buf1R1 = (char *) malloc(BUFSIZE2); buf2R1 = (char *) malloc(BUFSIZE2); free(buf1R1); free(buf2R1); buf1R2 = (char *) malloc(BUFSIZE1); strncpy(buf1R2, argv[1], BUFSIZE1-1); free(buf2R1); free(buf1R2); }

Notes

← Back to CWE list