CWE-456: Missing Initialization of a Variable
The product does not initialize critical variables, which causes the execution environment to use unexpected values.
How it's found
Missing Initialization of a Variable is a specific, narrowly defined instance of a broader pattern. Testers confirm it with targeted code review and a proof-of-concept input that exercises the exact code path this weakness describes.
Vulnerable vs. safe
// user allowed to perform bank manager tasks
// constructor for BankManager class
// retrieve user from database of users
// set user variable using username
// authenticate user
// methods for performing bank manager tasks...
...
this.user = getUserFromUserDatabase(username);
isUserAuthentic = true;
if (username.equals(user.getUsername()) && password.equals(user.getPassword())) {}return isUserAuthentic;private User user = null;private boolean isUserAuthentic = false;public BankManager() {}public User getUserFromUserDatabase(String username){}public void setUser(String username) {}public boolean authenticateUser(String username, String password) {}...public class BankManager {}// user allowed to perform bank manager tasks
// constructor for BankManager class
// retrieve user from database of users
// authenticate useruser = getUserFromUserDatabase(username);
System.out.println("Cannot find user " + username);
isUserAuthentic = true;if (password.equals(user.getPassword())) {}
if (user == null) {}else {}return isUserAuthentic;
// methods for performing bank manager tasks...private User user = null;private boolean isUserAuthentic = false;public BankManager(String username) {}public User getUserFromUserDatabase(String username) {...}public boolean authenticateUser(String username, String password) {}public class BankManager {}Consequences
- Unexpected State, Quality Degradation, Varies by Context: The uninitialized data may be invalid, causing logic errors within the program. In some cases, this could result in a security problem.
Mitigations
- Implementation: Ensure that critical variables are initialized before first use [REF-1485].
- Requirements: Choose a language that is not susceptible to these issues.
Where this fits in a TurboPentest engagement
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Frequently asked questions
What is CWE-456?
The product does not initialize critical variables, which causes the execution environment to use unexpected values.
How do you find Missing Initialization of a Variable?
Missing Initialization of a Variable is a specific, narrowly defined instance of a broader pattern. Testers confirm it with targeted code review and a proof-of-concept input that exercises the exact code path this weakness describes.
What is the impact of CWE-456?
Unexpected State, Quality Degradation, Varies by Context: The uninitialized data may be invalid, causing logic errors within the program. In some cases, this could result in a security problem.
Does TurboPentest test for Missing Initialization of a Variable?
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Related CWEs
Written and reviewed by
Michel Chamberland - Founder & CEO, IntegSec
CISSP, OSCP, OSCE, CEH, GIAC, CCSK · 20+ years in offensive security
Michel has spent 20+ years on offensive security teams including IBM X-Force Red and Trustwave SpiderLabs, leading penetration tests, red team engagements, and breach response for Fortune 500 customers. He is the founder of IntegSec and the architect of TurboPentest.
Find these issues before an attacker does
TurboPentest runs an agentic AI pentest against your target and reports findings with proof, from $99 per target.
Start a pentest