CWE-457: Use of Uninitialized Variable
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.
Consequences
- Availability, Integrity, Other: Other
- Authorization, Other: Other
How to prevent it
- Implementation: Ensure that critical variables are initialized before first use [REF-1485].
- Build and Compilation: Most compilers will complain about the use of uninitialized variables if warnings are turned on.
- Implementation, Operation: When 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.
- Requirements: Choose a language that is not susceptible to these issues.
- Architecture and Design: Mitigating technologies such as safe string libraries and container abstractions could be introduced.
Recent advisories
- GHSA-rfgq-q3w2-pmv2 — Pillow: Image.quantize() with empty palette leaks uninitialized stack memory
- GHSA-j4m9-6w36-pw47 — Pillow: Invalid free in FreeType glyph rendering when a stroker is active
- GHSA-r53h-jv2g-vpx6 — Helm's Missing YAML Content Leads To Panic
- GHSA-66p5-j55p-32r9 — Use of Uninitialized Resource in smallvec
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor