This vulnerability occurs when a program accesses a variable before it has been assigned a value, leading to unpredictable behavior and potential security risks.
In languages like C and C++, local variables declared on the stack are not automatically set to a known value. They contain whatever data was previously in that memory location ('junk data'), which an attacker might be able to influence or read. This can lead to information leaks, crashes, or logic flaws depending on how the program uses this unpredictable value. Using an uninitialized variable often points to a coding mistake, such as a typo or missing initialization logic. Even in languages that provide default values (like zero or null), relying on implicit initialization can introduce security weaknesses if the program's logic isn't explicitly handling the variable's starting state, making outcomes hard to predict and secure.
Impact: 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.
Impact: 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.
Strategy: Attack Surface Reduction
Strategy: Compilation or Build Hardening
Strategy: Language Selection
phpcchar *test_string; if (i != err_val) {
cchar *test_string = "Done at the beginning"; if (i != err_val) {
cchar *test_string; if (i != err_val) {
cHigh