CWE一覧に戻る
CWE-768

誤った短絡評価

Incorrect Short Circuit Evaluation
脆弱性 作成中
JA

この製品には、複数の論理式を持つ条件文が含まれており、先頭でない論理式の 1 つが副作用を発生させる可能性があります。ロジックを短絡させると副作用が発生しなくなるため、条件実行後のプログラムで予期しない状態が発生する可能性があります。

短絡評価の使用は、C標準では十分に定義されているが、検出が困難なロジックエラーを導入する方法で制御フローを変更する可能性があり、製品の実行中に後でエラーを引き起こす可能性がある。攻撃者がこのような矛盾を発見できれば、それを悪用してシステムを任意に制御できる可能性がある。

or "文の最初の条件が通常の状況で真であると仮定される場合、または "and "文の最初の条件が偽であると仮定される場合、後続の条件にはコードレビューやテスト中に検出されない独自のロジックエラーが含まれる可能性があります。

最後に、短絡評価の使用は、コードの保守性を低下させる可能性がある。

EN

The product contains a conditional statement with multiple logical expressions in which one of the non-leading expressions may produce side effects. This may lead to an unexpected state in the program after the execution of the conditional, because short-circuiting logic may prevent the side effects from occurring.

Usage of short circuit evaluation, though well-defined in the C standard, may alter control flow in a way that introduces logic errors that are difficult to detect, possibly causing errors later during the product's execution. If an attacker can discover such an inconsistency, it may be exploitable to gain arbitrary control over a system.

If the first condition of an "or" statement is assumed to be true under normal circumstances, or if the first condition of an "and" statement is assumed to be false, then any subsequent conditional may contain its own logic errors that are not detected during code review or testing.

Finally, the usage of short circuit evaluation may decrease the maintainability of the code.

Scope: Confidentiality, Integrity, Availability / Impact: Varies by Context
Minimizing the number of statements in a conditional that produce side effects will help to prevent the likelihood of short circuit evaluation to alter control flow in an unexpected way.
MITRE公式ページ — CWE-768