Assignment of a Fixed Address to a Pointer

Draft Variant
Structure: Simple
Description

This vulnerability occurs when code explicitly assigns a hardcoded memory address to a pointer, instead of using a dynamic or null value.

Extended Description

Assigning a fixed memory address, like 0xDEADBEEF, creates code that is inherently non-portable. The address is only meaningful within a specific execution environment, memory layout, or platform. When the software runs on a different operating system, hardware, or even after a system update, that exact memory location will likely be invalid or contain unrelated data, leading to crashes or undefined behavior. This practice bypasses the operating system's memory management and can severely hinder code reuse and security. Developers should always rely on safe memory allocation functions or system APIs to obtain valid pointers, ensuring the application functions correctly across different environments and remains maintainable.

Common Consequences 3
Scope: IntegrityConfidentialityAvailability

Impact: Execute Unauthorized Code or Commands

If one executes code at a known location, an attacker might be able to inject code there beforehand.

Scope: Availability

Impact: DoS: Crash, Exit, or RestartReduce MaintainabilityReduce Reliability

If the code is ported to another platform or environment, the pointer is likely to be invalid and cause a crash.

Scope: ConfidentialityIntegrity

Impact: Read MemoryModify Memory

The data at a known pointer location can be easily read or influenced by an attacker.

Potential Mitigations 1
Phase: Implementation
Never set a pointer to a fixed address.
Demonstrative Examples 1

ID : DX-192

This code assumes a particular function will always be found at a particular address. It assigns a pointer to that address and calls the function.

Code Example:

Bad
C
c

// Here we can inject code to execute.*

The same function may not always be found at the same memory address. This could lead to a crash, or an attacker may alter the memory at the expected address, leading to arbitrary code execution.
Applicable Platforms
Languages:
C : UndeterminedC++ : UndeterminedC# : UndeterminedAssembly : Undetermined
Modes of Introduction
Implementation
Functional Areas
  1. Memory Management
Affected Resources
  1. Memory
Taxonomy Mapping
  • CERT C Secure Coding
  • Software Fault Patterns