CWE一覧に戻る
CWE-196

符号なしから符号ありへの変換エラー

Unsigned to Signed Conversion Error
脆弱性 レビュー中
JA

この製品は符号なしプリミティブを使用し、符号付きプリミティブへのキャストを実行します。符号なしプリミティブの値が符号付きプリミティブを使用して表現できない場合、予期しない値が生成される可能性があります。

符号付きから符号なしへの変換よりも頻繁に発生する問題ではないが、符号なしから符号ありへの変換は、危険なバッファー・アンダーライト状態の完璧な前兆となる可能性がある。バッファ・アンダーライトは、大きな符号なし値が符号付き値にキャストされ、バッファへのインデックスやポインタ演算に使用される場合に頻繁に発生します。

EN

The product uses an unsigned primitive and performs a cast to a signed primitive, which can produce an unexpected value if the value of the unsigned primitive can not be represented using a signed primitive.

Although less frequent an issue than signed-to-unsigned conversion, unsigned-to-signed conversion can be the perfect precursor to dangerous buffer underwrite conditions that allow attackers to move down the stack where they otherwise might not have access in a normal buffer overflow condition. Buffer underwrites occur frequently when large unsigned values are cast to signed values, and then used as indexes into a buffer or for pointer arithmetic.

Scope: Availability / Impact: DoS: Crash, Exit, or Restart
Scope: Integrity / Impact: Modify Memory
Scope: Integrity, Confidentiality, Availability, Access Control / Impact: Execute Unauthorized Code or Commands; Bypass Protection Mechanism
Choose a language which is not subject to these casting flaws.
Design object accessor functions to implicitly check values for valid sizes. Ensure that all functions which will be used as a size are checked previous to use as a size. If the language permits, throw exceptions rather than using in-band errors.
Error check the return values of all functions. Be aware of implicit casts made, and use unsigned variables for sizes if at all possible.
MITRE公式ページ — CWE-196