CWE一覧に戻る
CWE-457

初期化されていない変数の使用

Use of Uninitialized Variable
脆弱性 レビュー中
JA

コードが初期化されていない変数を使用しているため、予測できない、あるいは意図しない結果になっている。

CやC++などいくつかの言語では、スタック変数はデフォルトでは初期化されない。一般的に、スタック変数には、関数が呼び出される前のスタック・メモリの内容を含むジャンク・データが格納される。攻撃者はこれらの内容を制御したり読み取ったりすることができる。他の言語や条件下では、明示的に初期化されない変数に、プログラムのロジックによっては、セキュリ ティ上の意味を持つデフォルト値が与えられることがある。初期化されていない変数が存在するということは、コードのタイプミスを示すこともあります。

EN

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.

Scope: Availability, Integrity, Other / Impact: Other
Scope: Authorization, Other / Impact: Other
Ensure that critical variables are initialized before first use [REF-1485].
Most compilers will complain about the use of uninitialized variables if warnings are turned on.
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.
Choose a language that is not susceptible to these issues.
Mitigating technologies such as safe string libraries and container abstractions could be introduced.
MITRE公式ページ — CWE-457