CWE-828: Signal Handler with Functionality that is not Asynchronous-Safe
查看自定义信息:
这可能会导致意外的系统状态,并取决于上下文,包括拒绝服务和代码执行。 信号处理程序通常旨在中断程序甚至其他信号的正常功能,以通知事件的过程。当信号处理程序使用全局或静态变量,或调用最终取决于该状态或其相关元数据的函数时,它可能会损坏正常功能使用的系统状态。这可能使该计划处于种族条件或其他弱点,这些弱点使攻击者能够使程序状态损坏。虽然拒绝服务通常是结果,但在某些情况下,这种弱点可能被利用用于执行代码。 有几种不同的情况引入了此问题:
请注意,在某些环境或上下文中,信号处理程序可能会被中断。 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.
This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to similar items that may exist at higher and lower levels of abstraction. In addition, relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user may want to explore.
与观点“研究概念”相关(CWE-1000)
与“软件开发”视图相关(CWE-699)
This table specifies different individual consequences associated with the weakness. The Scope identifies the application security area that is violated, while the Impact describes the negative technical impact that arises if an adversary succeeds in exploiting this weakness. The Likelihood provides information about how likely the specific consequence is expected to be seen relative to the other consequences in the list. For example, there may be high likelihood that a weakness will be exploited to achieve a certain impact, but a low likelihood that it will be exploited to achieve a different impact.
示例1 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.
(不良代码)
示例语言:C
char *logmessage;
void handler (int sigNum) {
syslog(log_notice,“%s \ n”,logmessage);
免费(logmessage); /*人为地增加时间窗口的大小,以使这种弱点更容易。*/ sleep(10); 出口(0); int main (int argc, char* argv[]) {
logMessage = strdup(argv [1]);
/*注册信号处理程序。*/ signal(SIGHUP, handler); 信号(Sigterm,处理程序); /*人为地增加时间窗口的大小,以使这种弱点更容易。*/ sleep(10); 处理程序函数使用全局状态(GlobalVar和LogMessage),并且可以通过Sighup和Sigment信号调用。攻击方案可能会遵循以下界限:
在这一点上,堆的状态尚不确定,因为Malloc仍在修改堆的元数据。元数据可能处于不一致的状态。Sigterm Handler呼叫Free()假设元数据是不一致的,可能会导致其在管理堆时将数据写入错误的位置。结果是内存损坏,可能导致崩溃甚至代码执行,具体取决于代码运行的情况。 Note that this is an adaptation of a classic example as originally presented by Michal Zalewski [REF-360];原始示例被证明是可利用代码执行的。 另请注意,strdup(argv [1])呼叫包含一个潜在的缓冲区过读(CWE-126)如果没有任何参数调用程序,因为ARGC为0,而ARGV [1]将指向数组范围之外。 示例2 以下代码注册一个带有多个信号的信号处理程序,以便在发生特定事件时登录并在退出之前释放关联内存。
(不良代码)
示例语言:C
#include
#include #include #include void *global1, *global2; char *什么; 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); 出口(0); int main(int argc,char* argv []){
什么= argv [1];
global1 = strdup(argv [2]); global2 = malloc(340); signal(SIGHUP,sh); 信号(sigterm,sh); /* Sleep statements added to expand timing window for race condition */ sleep(10); 出口(0); 但是,以下事件序列可能会导致双重(CWE-415):
这只是上述代码的一种可能的利用。作为另一个例子,Syslog调用可能使用不是异步信号安全的malloc调用。这可能导致堆管理结构的损坏。有关更多详细信息,请咨询“为娱乐和利润传递信号”中的示例[REF-360]。
提供更多信息 - 请选择其他过滤器。
|
使用共同弱点枚举(CWE)和本网站的相关参考Terms of Use。CWE由美国国土安全部(DHS)网络安全和基础设施安全局(CISA) and managed by the国土安全系统工程和开发研究所(HSSEDI)由manbetx客户端首页(MITER)。版权所有©2006–2023,Miter Comanbetx客户端首页rporation。CWE,CWSS,CWRAF和CWE徽标是Miter Corporation的商标。manbetx客户端首页 |