CWE一覧に戻る
CWE-1333

非効率的な正規表現の複雑さ

Inefficient Regular Expression Complexity
脆弱性 レビュー中
JA

この製品は、非効率的で、おそらく指数関数的な最悪の計算複雑度を持つ正規表現を使用しており、過剰なCPUサイクルを消費している。

正規表現エンジンの中には「バックトラック」と呼ばれる機能を持つものがある。トークンがマッチしない場合、エンジンはマッチする可能性のある別のトークンの位置まで "バックトラック "する:

EN

The product uses a regular expression with an inefficient, possibly exponential worst-case computational complexity that consumes excessive CPU cycles.

Some regular expression engines have a feature called "backtracking". If the token cannot match, the engine "backtracks" to a position that may result in a different token that can match.Backtracking becomes a weakness if all of these conditions are met:

Scope: Availability / Impact: DoS: Resource Consumption (CPU)
Use regular expressions that do not support backtracking, e.g. by removing nested quantifiers.
Set backtracking limits in the configuration of the regular expression implementation, such as PHP's pcre.backtrack_limit. Also consider limits on execution time for the process.
Do not use regular expressions with untrusted input. If regular expressions must be used, avoid using backtracking in the expression.
Limit the length of the input that the regular expression will process.
MITRE公式ページ — CWE-1333