Return of Pointer Value Outside of Expected Range

Draft Base
Structure: Simple
Description

This vulnerability occurs when a function returns a memory pointer that points outside the expected buffer range, potentially exposing unrelated memory or causing crashes.

Extended Description

When a function is designed to return a pointer within a specific buffer—like an array or allocated memory block—but instead returns an address outside that boundary, it breaks fundamental memory safety assumptions. This often happens due to incorrect offset calculations, boundary check failures, or mishandling of edge cases in pointer arithmetic. The returned pointer might point to unrelated data structures, freed memory, or even invalid addresses, leading to unpredictable behavior. From a security perspective, this flaw can be exploited to read sensitive data from other parts of memory (information disclosure) or to corrupt memory if the pointer is later used for writing. Developers should rigorously validate all pointer calculations, ensure functions explicitly document their return range contracts, and use modern memory-safe languages or sanitizers to catch these errors during testing.

Common Consequences 1
Scope: ConfidentialityIntegrity

Impact: Read MemoryModify Memory

References 2
Seven Pernicious Kingdoms: A Taxonomy of Software Security Errors
Katrina Tsipenyuk, Brian Chess, and Gary McGraw
NIST Workshop on Software Security Assurance Tools Techniques and MetricsNIST
07-11-2005
ID: REF-6
24 Deadly Sins of Software Security
Michael Howard, David LeBlanc, and John Viega
McGraw-Hill
2010
ID: REF-44
Applicable Platforms
Languages:
C : UndeterminedC++ : Undetermined
Modes of Introduction
Implementation
Functional Areas
  1. Memory Management
Affected Resources
  1. Memory
Taxonomy Mapping
  • 7 Pernicious Kingdoms
  • Software Fault Patterns
Notes
MaintenanceThis entry should have a chaining relationship with Improper Restriction of Operations within the Bounds of a Memory Buffer instead of a parent / child relationship, however the focus of this weakness does not map cleanly to any existing entries in CWE. A new parent is being considered which covers the more generic problem of incorrect return values. There is also an abstract relationship to weaknesses in which one component sends incorrect messages to another component; in this case, one routine is sending an incorrect value to another.