目标达成 感谢每一位支持者 — 我们达成了 100% 目标!

目标: 1000 元 · 已筹: 1336

100%

CWE-828 非异步安全功能中的信号处理例程 类漏洞列表 1

CWE-828 非异步安全功能中的信号处理例程 类弱点 1 条 CVE 漏洞汇总,含 AI 中文分析。

CWE-828 指信号处理函数包含非异步安全代码,如非重入或可被中断的逻辑。攻击者可通过构造特定信号触发竞态条件,导致系统状态异常,进而引发拒绝服务或远程代码执行。开发者应避免在信号处理程序中调用非异步安全函数,确保处理逻辑简洁且线程安全,从而防止不可预期的系统崩溃或恶意利用。

MITRE CWE 官方描述
CWE:CWE-828 包含非异步安全(Asynchronous-Safe)功能信号处理程序 该产品定义了一个信号处理程序(Signal Handler),其中包含非异步安全(Asynchronous-Safe)的代码序列,即该功能不具备可重入性(Reentrant),或者可能被中断。 这可能导致不可预期的系统状态,其潜在后果因上下文而异,包括拒绝服务(Denial of Service)和代码执行(Code Execution)。信号处理程序通常旨在中断程序的正常功能,甚至是其他信号,以通知进程发生了特定事件。当信号处理程序使用全局变量或静态变量,或调用最终依赖于此类状态或其关联元数据的函数时,可能会破坏正常功能正在使用的系统状态。这可能导致程序面临竞态条件(Race Conditions)或其他弱点,从而使攻击者能够导致程序状态被破坏。虽然拒绝服务(Denial of Service)通常是后果,但在某些情况下,此弱点可能被利用来实现代码执行(Code Execution)。引入此问题有多种不同的场景: 1. 在信号处理程序内部调用不可重入(Non-reentrant)函数。一个例子是 `malloc()`,它在管理内存时会修改内部全局变量。实际上,真正具备可重入性(Reentrant)的函数非常少。 2. 代码序列(不一定是函数调用)对全局变量、关联元数据或结构进行了非原子(Non-atomic)使用,而这些内容可能被程序的其他功能(包括其他信号处理程序)访问。 3. 通常,同一个函数被注册用于处理多个信号。信号处理程序函数本意是至多运行一次,但实际上可能被多次调用。这可能由同一信号的重复传递引起,或由具有相同信号处理程序函数(CWE-831)的不同信号的传递引起。 4. 需要注意的是,在某些环境或上下文中,信号处理程序本身也可能被中断。如果信号处理程序和产品的正常行为都必须操作同一组状态变量,且在正常执行修改这些变量的过程中接收到信号,则在信号处理程序执行期间,这些变量可能处于不正确或损坏的状态,并且在返回后可能仍然不正确或损坏。
常见影响 (1)
Integrity, Confidentiality, Availability DoS: 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…
缓解措施 (2)
Implementation, Architecture and Design 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 …
Effectiveness: High
Implementation 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.
代码示例 (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 ID 标题 CVSS 风险等级 Published
CVE-2024-20309 Cisco IOS XE Software 安全漏洞 — Cisco IOS XE Software 5.6 Medium 2024-03-27

CWE-828(非异步安全功能中的信号处理例程) 是常见的弱点类别,本平台收录该类弱点关联的 1 条 CVE 漏洞。