CWE-562: Return of Stack Variable Address

low-risk

A function returns the address of a stack variable, which will cause unintended program behavior, typically in the form of a crash.

Abstraction: Base

Common Consequences

Availability Read Memory

Detection Methods

Fuzzing

Fuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.

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.)

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].

Real-World Examples (7)

CVE CVSS EPSS KEV
CVE-2021-21798 7.8 63.4%
CVE-2024-4418 6.2 0.5%
CVE-2022-41837 9.8 0.2%
CVE-2020-21686 5.5 0.2%
CVE-2024-33045 8.4 0.1%
CVE-2026-3591 5.4 0.0%
CVE-2026-34553 4.0 0.0%
5
/ 100
low-risk
Active Threat 5/50 · Minimal
Exploit Availability 0/50 · Minimal