Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CWE-828 (非异步安全功能中的信号处理例程) — Vulnerability Class 1

1 vulnerabilities classified as CWE-828 (非异步安全功能中的信号处理例程). AI Chinese analysis included.

CWE-828 represents a critical implementation flaw where signal handlers invoke functions that are not asynchronous-safe, meaning they lack reentrancy or cannot be safely interrupted during execution. This weakness typically arises when developers use non-thread-safe library calls, such as printf or malloc, within a handler context. Exploitation often occurs when a signal interrupts a vulnerable operation, causing race conditions, memory corruption, or undefined behavior that can lead to denial of service or arbitrary code execution. To mitigate this risk, developers must strictly adhere to asynchronous-signal-safe functions defined by POSIX standards within their handlers. By limiting handler logic to simple state flags or using sig_atomic_t variables, programmers ensure that signal processing does not interfere with ongoing critical operations, thereby maintaining system stability and preventing unexpected state transitions.

MITRE CWE Description
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: Invocation of non-reentrant functions from within the handler. One example is malloc(), which modifies internal global variables as it manages memory. Very few functions are actually reentrant. Code sequences (not necessarily function calls) contain non-atomic use of global variables, or associated metadata or structures, that can be accessed by other functionality of the program, including other signal handlers. Frequently, the same function is registered to handle multiple …
Common Consequences (1)
Integrity, Confidentiality, AvailabilityDoS: Crash, Exit, or Restart, Execute 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 me…
Mitigations (2)
Implementation, Architecture and DesignEliminate 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 …
Effectiveness: High
ImplementationWhere 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.
Examples (2)
This code registers the same signal handler function with two different signals (CWE-831). If those signals are sent to the process, the handler creates a log message (specified in the first argument to the program) and exits.
char *logMessage; void handler (int sigNum) { syslog(LOG_NOTICE, "%s\n", logMessage); free(logMessage); /* artificially increase the size of the timing window to make demonstration of this weakness easier. */ sleep(10); exit(0); } int main (int argc, char* argv[]) { logMessage = strdup(argv[1]); /* Register signal handlers. */ signal(SIGHUP, handler); signal(SIGTERM, handler); /* artificially increase the size of the timing window to make demonstration of this weakness easier. */ sleep(10); }
Bad · C
The following code registers a signal handler with multiple signals in order to log when a specific event occurs and to free associated memory before exiting.
#include <signal.h> #include <syslog.h> #include <string.h> #include <stdlib.h> void *global1, *global2; char *what; void sh (int dummy) { syslog(LOG_NOTICE,"%s\n",what); free(global2); free(global1); /* Sleep statements added to expand timing window for race condition */ sleep(10); exit(0); } int main (int argc,char* argv[]) { what=argv[1]; global1=strdup(argv[2]); global2=malloc(340); signal(SIGHUP,sh); signal(SIGTERM,sh); /* Sleep statements added to expand timing window for race condition */ sleep(10); exit(0); }
Bad · C
CVE IDTitleCVSSSeverityPublished
CVE-2024-20309 Cisco IOS XE Software 安全漏洞 — Cisco IOS XE Software 5.6 Medium2024-03-27

Vulnerabilities classified as CWE-828 (非异步安全功能中的信号处理例程) represent 1 CVEs. The CWE taxonomy describes the weakness; review individual CVEs for product-specific impact.