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
TurboPentest's agentic pentest is powerful and covers a broad range of issues automatically. This particular class is best confirmed in a manual IntegSec engagement, where human pentesters apply deeper methodology and a larger context window than any automated pass.
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?
TurboPentest's agentic pentest is powerful and covers a broad range of issues automatically. This particular class is best confirmed in a manual IntegSec engagement, where human pentesters apply deeper methodology and a larger context window than any automated pass.
Related CWEs
About this reference
These security references are maintained by IntegSec, an offensive-security firm whose team holds CISSP, OSCP, and OSCE certifications and has run thousands of penetration tests. Content is kept current as tools, standards, and attack techniques evolve.
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