This weakness occurs when a program's signal handler contains code that is not asynchronous-safe. This means the handler can be interrupted or can corrupt shared data, leading to unpredictable program behavior.
Signal handlers interrupt your program's normal flow to process events. If these handlers use global variables, call non-reentrant functions like malloc(), or modify shared state, they can corrupt memory or program logic when interrupted. This corruption often creates race conditions, making your application vulnerable to crashes (denial of service) or, in some cases, allowing an attacker to execute arbitrary code. A common pitfall is writing handlers that assume they run only once, but signals can fire repeatedly or share the same handler. If your main code and the signal handler both access the same data, an incoming signal can leave that data in a broken, inconsistent state. Since very few functions are truly reentrant, you must carefully design handlers to use only asynchronous-safe operations to maintain system stability.
Impact: DoS: Crash, Exit, or RestartExecute Unauthorized Code or Commands
The most common consequence will be a corruption of the state of the product, possibly leading to a crash or exit. However, if the signal handler is operating on state variables for security relevant libraries or protection mechanisms, the consequences can be far more severe, including protection mechanism bypass, privilege escalation, or information exposure.
Effectiveness: High
c
/* artificially increase the size of the timing window to make demonstration of this weakness easier. /
c
cc
/* Sleep statements added to expand timing window for race condition /
c
c