CWE一覧に戻る
CWE-828

非同期安全でない機能を持つシグナルハンドラ

Signal Handler with Functionality that is not Asynchronous-Safe
脆弱性 作成中
JA

この製品は、非同期安全でない、つまり機能が再入可能でない、または中断される可能性のあるコード・シーケンスを含むシグナル・ハンドラを定義しています。

これは、サービス拒否やコード実行を含む、コンテキストに応じて様々な潜在的な結果を伴う予期せぬシステム状態につながる可能性がある。

シグナルハンドラは通常、イベントの発生をプロセスに通知するために、プログラムの通常の機能、あるいは他のシグナルに割り込むことを意図しています。シグナルハンドラがグローバル変数や静的変数を使用したり、そのような状態や関連するメタデータに最終的に依存する関数を呼び出したりすると、通常の機能で使用されているシステム状態を破損する可能性があります。これは、攻撃者がプログラムの状態を破壊することを可能にする、競合状態や他の弱点の対象となり得ます。サービス拒否が頻繁に発生する一方で、この弱点がコード実行に利用されるケースもある。

この問題を引き起こすシナリオはいくつかあります:

環境やコンテキストによっては、シグナルハンドラ自身が中断される可能性があることに注意してください。

シグナル・ハンドラと製品の通常の動作の両方が、同じステート変数のセットを操作する必要があり、通常の実行がこれらの変数を変更している最中にシグナルを受信した場合、シグナル・ハンドラの実行中に変数が不正または破損した状態になる可能性があります。

EN

The product defines a signal handler that contains code sequences that are not asynchronous-safe, i.e., the functionality is not reentrant, or it can be interrupted.

This can lead to an unexpected system state with a variety of potential consequences depending on context, including denial of service and code execution.

Signal handlers are typically intended to interrupt normal functionality of a program, or even other signals, in order to notify the process of an event. When a signal handler uses global or static variables, or invokes functions that ultimately depend on such state or its associated metadata, then it could corrupt system state that is being used by normal functionality. This could subject the program to race conditions or other weaknesses that allow an attacker to cause the program state to be corrupted. While denial of service is frequently the consequence, in some cases this weakness could be leveraged for code execution.

There are several different scenarios that introduce this issue:

Note that in some environments or contexts, it might be possible for the signal handler to be interrupted itself.

If both a signal handler and the normal behavior of the product have to operate on the same set of state variables, and a signal is received in the middle of the normal execution's modifications of those variables, the variables may be in an incorrect or corrupt state during signal handler execution, and possibly still incorrect or corrupt upon return.

Scope: Integrity, Confidentiality, Availability / Impact: DoS: Crash, Exit, or Restart; Execute Unauthorized Code or Commands
Eliminate the usage of non-reentrant functionality inside of signal handlers. This includes replacing all non-reentrant library calls with reentrant calls.

Note: This will not always be possible and may require large portions of the product to be rewritten or even redesigned. Sometimes reentrant-safe library alternatives will not be available. Sometimes non-reentrant interaction between the state of the system and the signal handler will be required by design.
Where non-reentrant functionality must be leveraged within a signal handler, be sure to block or mask signals appropriately. This includes blocking other signals within the signal handler itself that may also leverage the functionality. It also includes blocking all signals reliant upon the functionality when it is being accessed or modified by the normal behaviors of the product.
MITRE公式ページ — CWE-828