CWE一覧に戻る
CWE-1335

整数の不正なビットシフト

Incorrect Bitwise Shift of Integer
脆弱性 レビュー中
JA

整数値が、負の量または値に含まれるビット数以上の量だけシフトされるように指定され、予期せぬ結果または不確定な結果を引き起こす。

負の量だけシフトする値を指定することは、さまざまな言語で未定義である。さまざまなコンピュータ・アーキテクチャが、さまざまな方法でこの動作を実装している。シフトを行うコードを生成するコンパイラやインタープリタは、一般にこの問題のチェックを行わない。

オーバーシフト(シフトされる値に含まれるビット数以上のシフト)を指定すると、アーキテクチャーやコンパイラーによって異なる結果が得られる。一部の言語では、この動作は未定義の結果を生成すると明記されています。

EN

An integer value is specified to be shifted by a negative amount or an amount greater than or equal to the number of bits contained in the value causing an unexpected or indeterminate result.

Specifying a value to be shifted by a negative amount is undefined in various languages. Various computer architectures implement this action in different ways. The compilers and interpreters when generating code to accomplish a shift generally do not do a check for this issue.

Specifying an over-shift, a shift greater than or equal to the number of bits contained in a value to be shifted, produces a result which varies by architecture and compiler. In some languages, this action is specifically listed as producing an undefined result.

Scope: Integrity / Impact: DoS: Crash, Exit, or Restart
Implicitly or explicitly add checks and mitigation for negative or over-shift values.
MITRE公式ページ — CWE-1335