CWE-457: Use of Uninitialized Variable
The code uses a variable that has not been initialized, leading to unpredictable or unintended results.
Last updated
Overview
In some languages such as C and C++, stack variables are not initialized by default. They generally contain junk data with the contents of stack memory before the function was invoked. An attacker can sometimes control or read these contents. In other languages or conditions, a variable that is not explicitly initialized can be given a default value that has security implications, depending on the logic of the program. The presence of an uninitialized variable can sometimes indicate a typographic error in the code.
Real-world CVEs
139 recorded CVEs are caused by CWE-457 (Use of Uninitialized Variable). The highest-severity and most recent are shown first. 34 new CWE-457 CVEs have been recorded so far in 2026 (36 in 2025).
- CVE-2026-6748
Uninitialized memory in the Audio/Video: Web Codecs component
Critical · CVSS 9.8 · EPSS 33th2026-04-21 - CVE-2024-32611Critical · CVSS 9.8 · EPSS 59th2024-05-09
- CVE-2022-40510Critical · CVSS 9.8 · EPSS 36th2023-08-08
- CVE-2022-21217Critical · CVSS 9.8 · EPSS 66th2022-01-28
- CVE-2021-40418Critical · CVSS 9.8 · EPSS 97th2021-12-22
- CVE-2026-2806
Uninitialized memory in the Graphics: Text component
Critical · CVSS 9.1 · EPSS 32th2026-02-24 - CVE-2025-5749
WOLFBOX Level 2 EV Charger BLE Encryption Keys Uninitialized Variable Authentication Bypass Vulnerability
High · CVSS 8.8 · EPSS 10th2025-06-06 - CVE-2024-7022High · CVSS 8.8 · EPSS 28th2024-09-23
- CVE-2024-6990High · CVSS 8.8 · EPSS 58th2024-08-01
- CVE-2023-6324High · CVSS 8.8 · EPSS 51th2024-05-15
- CVE-2023-31275High · CVSS 8.8 · EPSS 75th2023-11-27
- CVE-2009-0901High · CVSS 8.8 · EPSS 98th2009-07-29
Showing 12 of 139 recorded CWE-457 CVEs. Track new ones as they are published and get AI-written analysis and fixes.
Monitor CWE-457 vulnerabilitiesCommon consequences
What can happen when CWE-457 is exploited.
Other
Affects: Availability, Integrity, Other
Initial variables usually contain junk, which can not be trusted for consistency. This can lead to denial of service conditions, or modify control flow in unexpected ways. In some cases, an attacker can "pre-initialize" the variable using previous actions, which might enable code execution. This can cause a race condition if a lock variable check passes when it should not.
Other
Affects: Authorization, Other
Strings that are not initialized are especially dangerous, since many functions expect a null at the end -- and only at the end -- of a string.
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
Applies to
Languages
How to prevent it
Practical mitigations for CWE-457, grouped by where in the lifecycle they apply.
Ensure that critical variables are initialized before first use [REF-1485].
Most compilers will complain about the use of uninitialized variables if warnings are turned on.
When using a language that does not require explicit declaration of variables, run or compile the software in a mode that reports undeclared or unknown variables. This may indicate the presence of a typographic error in the variable's name.
Choose a language that is not susceptible to these issues.
Mitigating technologies such as safe string libraries and container abstractions could be introduced.
How to detect it
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.
Effectiveness: High
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.)
Effectiveness: High
Code examples
Illustrative examples from MITRE showing how the weakness appears in code.
This code prints a greeting using information stored in a POST request:
Vulnerable example
if (isset($_POST['names'])) {This code checks if the POST array 'names' is set before assigning it to the $nameArray variable. However, if the array is not in the POST request, $nameArray will remain uninitialized. This will cause an error when the array is accessed to print the greeting message, which could lead to further exploit.
The following switch statement is intended to set the values of the variables aN and bN before they are used:
Vulnerable example
int aN, Bn;In the default case of the switch statement, the programmer has accidentally set the value of aN twice. As a result, bN will have an undefined value. Most uninitialized variable issues result in general software reliability problems, but if attackers can intentionally trigger the use of an uninitialized variable, they might be able to launch a denial of service attack by crashing the program. Under the right circumstances, an attacker may be able to control the value of an uninitialized variable by affecting the values on the stack prior to the invocation of the function.
This example will leave test_string in an unknown condition when i is the same value as err_val, because test_string is not initialized (CWE-456). Depending on where this code segment appears (e.g. within a function body), test_string might be random if it is stored on the heap or stack. If the variable is declared in static memory, it might be zero or NULL. Compiler optimization might contribute to the unpredictability of this address.
Vulnerable example
test_string = "Hello World!";Safe example
test_string = "Hello World!";Illustrative examples
Real CVEs that MITRE cites as examples of this weakness.
- CVE-2019-15900 — Chain: sscanf() call is used to check if a username and group exists, but the return value of sscanf() call is not checked (CWE-252), causing an uninitialized variable to be checked (CWE-457), returning success to allow authorization bypass for executing a privileged (CWE-863).
- CVE-2008-3688 — Chain: A denial of service may be caused by an uninitialized variable (CWE-457) allowing an infinite loop (CWE-835) resulting from a connection to an unresponsive server.
- CVE-2008-0081 — Uninitialized variable leads to code execution in popular desktop application.
- CVE-2007-4682 — Crafted input triggers dereference of an uninitialized object pointer.
- CVE-2007-3468 — Crafted audio file triggers crash when an uninitialized variable is used.
- CVE-2007-2728 — Uninitialized random seed variable used.
Terminology & mappings
Mapped taxonomies
- CLASP: Uninitialized variable
- 7 Pernicious Kingdoms: Uninitialized Variable
- Software Fault Patterns: Glitch in computation (SFP1)
- SEI CERT Perl Coding Standard: Declare identifiers before using them (DCL33-PL) — Imprecise fit
Frequently asked questions
Common questions about CWE-457.
- What is CWE-457?
- The code uses a variable that has not been initialized, leading to unpredictable or unintended results.
- What CVEs are caused by CWE-457?
- 139 recorded CVEs are attributed to CWE-457, including CVE-2026-6748, CVE-2024-32611, CVE-2022-40510.
- How do you prevent CWE-457?
- Ensure that critical variables are initialized before first use [REF-1485].
- How is CWE-457 detected?
- 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.
- What are the consequences of CWE-457?
- Exploiting CWE-457 can lead to: Other.
- Is CWE-457 actively exploited?
- 139 recorded CVEs are caused by CWE-457; none are currently in CISA's KEV catalog of actively exploited flaws.
References
- MITRE CWE definition (CWE-457) (opens in a new tab)
- CWE-457 vulnerabilities on NVD (opens in a new tab)
- Learn: What is a CWE?
Weakness data is sourced from the MITRE CWE catalog (v4.20). CVE associations are aggregated and kept current by RadicalNotion.AI.
Stay ahead of CWE-457
Get alerted the moment a new CWE-457 vulnerability affects your stack, with AI-written analysis, severity context, and remediation guidance.