CWEweakness

CWE-588 Attempt to Access Child of a Non-structure Pointer

Official page ↗
Abstraction
Variant
Structure
Simple
Status
Incomplete
Languages
C, C++
CWE version
5.0

Description

The product casts a non-structure type to a structure type, then accesses a field within the structure.

Common consequences

• Integrity: Modify Memory — Adjacent variables in memory may be corrupted by assignments performed on fields after the cast, leading to data corruption. • Availability: DoS: Crash, Exit, or Restart — Execution may end due to a memory access error.

Potential mitigations

• [Requirements] The choice could be made to use a language that is not susceptible to these issues. • [Implementation] Review of type casting operations can identify locations where incompatible types are cast.

Detection methods

• Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Observed examples

• CVE-2021-3510: JSON decoder accesses a C union using an invalid offset to an object

Related

Observed example · CVE (1)

  • CVE-2021-3510 Zephyr JSON decoder incorrectly decodes array of array. vulnerability

Child of · CWE (2)

  • CWE-704 Incorrect Type Conversion or Cast weakness
  • CWE-758 Reliance on Undefined, Unspecified, or Implementation-Defined Behavior weakness

Referenced by CVE · weakness (3)

  • CVE-2026-21692 iccDEV provides a set of libraries and tools that allow for the interaction, manipulation, and application of International Color… vulnerability
  • CVE-2021-3319 DOS: Incorrect 802154 Frame Validation for Omitted Source / Dest Addresses. vulnerability
  • CVE-2021-3510 Zephyr JSON decoder incorrectly decodes array of array. vulnerability