CWE-457: Use of Uninitialized Variable

What is CWE-457?

CWE-457 is Use of Uninitialized Variable. The flaw arises when the code uses a variable that has not been initialized, leading to unpredictable or unintended results. The database currently holds 43 vulnerabilities mapped to CWE-457 and none of them are in the CISA Known Exploited Vulnerabilities catalog.

Analyzing data...

OWASP Top 10 Rank-
Related CVES (365 days)43
AbstractionVariant
Likelihood of exploitHigh

Vulnerabilities mapped to CWE-457

43 vulnerabilities105% increase year over year

No data

No vulnerability data in CISA KEV for CWE-457

Official definition

ByMitre CWE

The code uses a variable that has not been initialized, leading to unpredictable or unintended results.

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.

Characteristics

Modes of introduction

  • Implementation: In C, using an uninitialized char * in some string libraries will return incorrect results, as the libraries expect the null terminator to always be at the end of a string, even if the string is empty.

Common consequences

ImpactScopeExplanation
OtherAvailability, Integrity, OtherInitial 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.
OtherAuthorization, OtherStrings that are not initialized are especially dangerous, since many functions expect a null at the end -- and only at the end -- of a string.

Risk mitigations

  1. Attack Surface Reduction · ImplementationEnsure that critical variables are initialized before first use [REF-1485].
  2. Compilation or Build Hardening · Build and CompilationMost compilers will complain about the use of uninitialized variables if warnings are turned on.
  3. Implementation, OperationWhen 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.
  4. Language Selection · RequirementsChoose a language that is not susceptible to these issues.
  5. Architecture and DesignMitigating technologies such as safe string libraries and container abstractions could be introduced.

Detection methods

MethodApproachEffectiveness
FuzzingFuzz 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.High
Automated Static AnalysisAutomated 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.)High

Representative vulnerabilities

Sources (2)

CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.

Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.