CWEweakness

CWE-761 Free of Pointer not at Start of Buffer

Official page ↗
Abstraction
Variant
Structure
Simple
Status
Incomplete
Languages
C, Memory-Unsafe
CWE version
5.0

Description

The product calls free() on a pointer to a memory resource that was allocated on the heap, but the pointer is not at the start of the buffer.

Common consequences

• Integrity, Availability, Confidentiality: Modify Memory, DoS: Crash, Exit, or Restart, Execute Unauthorized Code or Commands — This can cause the product to crash, or in some cases, modify critical program variables or execute code.

Potential mitigations

• [Implementation] When utilizing pointer arithmetic to traverse a buffer, use a separate variable to track progress through memory and preserve the originally allocated address for later freeing. • [Implementation] When programming in C++, consider using smart pointers provided by the boost library to help correctly and consistently manage memory. • [Architecture and Design] Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, glibc in Linux provides protection against free of invalid pointers. • [Architecture and Design] Use a language that provides abstractions for memory allocation and deallocation.

Detection methods

• 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] or valgrind [REF-480].

Observed examples

• CVE-2019-11930: function "internally calls 'calloc' and returns a pointer at an index... inside the allocated buffer. This led to freeing invalid memory."

Related

Observed example · CVE (1)

  • CVE-2019-11930 An invalid free in mb_detect_order can cause the application to crash or potentially result in remote code execution. vulnerability

Child of · CWE (2)

  • CWE-404 Improper Resource Shutdown or Release weakness
  • CWE-763 Release of Invalid Pointer or Reference weakness

Referenced by CVE · weakness (2)

  • CVE-2025-47749 V-SFT v6.2.5.0 and earlier contains an issue with free of pointer not at start of buffer in VS6EditData.dll!CWinFontInf::WinFontMsgCheck… vulnerability
  • CVE-2024-31413 Free of pointer not at start of buffer vulnerability exists in CX-One CX-One CXONE-AL[][]D-V4 (The version which was installed with a DVD… vulnerability