Description
The product does not initialize a critical resource.
Many resources require initialization before they can be properly used. If a resource is not initialized, it could contain unpredictable or expired data, or it could be initialized to defaults that are invalid. This can have security implications when the resource is expected to have certain properties or values.
Potential Impact
Confidentiality
Read Memory, Read Application Data
Availability
DoS: Crash, Exit, or Restart
Demonstrative Examples
private boolean initialized = true;public void someMethod() {
if (!initialized) {
// perform initialization tasks
...
initialized = true;
}$username = GetCurrentUser();$state = GetStateData($username);if (defined($state)) {$uid = ExtractUserID($state);}
# do stuff
if ($uid == 0) {DoAdminThings();}char str[20];strcat(str, "hello world");printf("%s", str);char *test_string;
if (i != err_val)
{
test_string = "Hello World!";
}
printf("%s", test_string);char *test_string = "Done at the beginning";
if (i != err_val)
{
test_string = "Hello World!";
}
printf("%s", test_string);char *test_string;
if (i != err_val)
{
test_string = "Hello World!";
}
else {
test_string = "Done on the other side!";
}
printf("%s", test_string);Mitigations & Prevention
Explicitly initialize the resource before use. If this is performed through an API function or standard procedure, follow all specified steps.
Pay close attention to complex conditionals that affect initialization, since some branches might not perform the initialization.
Avoid race conditions (CWE-362) during initialization routines.
Run or compile your product with settings that generate warnings about uninitialized variables or data.
Detection Methods
- Automated Static Analysis High — 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 sea
Real-World CVE Examples
| CVE ID | Description |
|---|---|
| CVE-2020-20739 | A variable that has its value set in a conditional statement is sometimes used when the conditional fails, sometimes causing data leakage |
| CVE-2005-1036 | Chain: Bypass of access restrictions due to improper authorization (CWE-862) of a user results from an improperly initialized (CWE-909) I/O permission bitmap |
Related Weaknesses
Frequently Asked Questions
What is CWE-909?
CWE-909 (Missing Initialization of Resource) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Class-level weakness. The product does not initialize a critical resource.
How can CWE-909 be exploited?
Attackers can exploit CWE-909 (Missing Initialization of Resource) to read memory, read application data. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-909?
Key mitigations include: Explicitly initialize the resource before use. If this is performed through an API function or standard procedure, follow all specified steps.
What is the severity of CWE-909?
CWE-909 is classified as a Class-level weakness (High abstraction). It has been observed in 2 real-world CVEs.