Description
A function returns the address of a stack variable, which will cause unintended program behavior, typically in the form of a crash.
Extended Description
Because local variables are allocated on the stack, when a program returns a pointer to a local variable, it is returning a stack address. A subsequent function call is likely to re-use this same stack address, thereby overwriting the value of the pointer, which no longer corresponds to the same variable since a function's stack frame is invalidated when it returns. At best this will cause the value of the pointer to change unexpectedly. In many cases it causes the program to crash the next time the pointer is dereferenced.
CVE vulnerabilities with CWE-562 (8)
9.8
CVSS
CRITICAL
CVE-2022-41837
pub. 2022-12-22
8.4
CVSS
HIGH
CVE-2024-33045
pub. 2024-09-02
7.8
CVSS
HIGH
CVE-2021-21798
pub. 2021-09-15
6.2
CVSS
MEDIUM
CVE-2024-4418
pub. 2024-05-08
5.5
CVSS
MEDIUM
CVE-2020-21686
pub. 2023-08-22
5.4
CVSS
MEDIUM
CVE-2026-3591
pub. 2026-03-25
5.3
CVSS
MEDIUM
CVE-2026-26399
pub. 2026-04-20
4.0
CVSS
MEDIUM
CVE-2026-34553
pub. 2026-03-31