结构: Simple
Abstraction: Variant
状态: Draft
被利用可能性: Low
The program defines a signal handler that calls a non-reentrant function.
Non-reentrant functions are functions that cannot safely be called, interrupted, and then recalled before the first call has finished without resulting in memory corruption. This can lead to an unexpected system state an unpredictable results with a variety of potential consequences depending on context, including denial of service and code execution.
Many functions are not reentrant, but some of them can result in the corruption of memory if they are used in a signal handler. The function call syslog() is an example of this. In order to perform its functionality, it allocates a small amount of memory as "scratch space." If syslog() is suspended by a signal call and the signal handler calls syslog(), the memory used by both of these functions enters an undefined, and possibly, exploitable state. Implementations of malloc() and free() manage metadata in global structures in order to track which memory is allocated versus which memory is available, but they are non-reentrant. Simultaneous calls to these functions can cause corruption of the metadata.
cwe_Nature: ChildOf cwe_CWE_ID: 828 cwe_View_ID: 1000 cwe_Ordinal: Primary
cwe_Nature: ChildOf cwe_CWE_ID: 828 cwe_View_ID: 699 cwe_Ordinal: Primary
cwe_Nature: ChildOf cwe_CWE_ID: 663 cwe_View_ID: 1000
cwe_Nature: ChildOf cwe_CWE_ID: 663 cwe_View_ID: 699
cwe_Nature: CanPrecede cwe_CWE_ID: 123 cwe_View_ID: 1000
Language: [{'cwe_Name': 'C', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'C++', 'cwe_Prevalence': 'Undetermined'}]
范围 | 影响 | 注释 |
---|---|---|
['Integrity', 'Confidentiality', 'Availability'] | Execute Unauthorized Code or Commands | It may be possible to execute arbitrary code through the use of a write-what-where condition. |
Integrity | Modify Application Data | Signal race conditions often result in data corruption. |
策略:
Require languages or libraries that provide reentrant functionality, or otherwise make it easier to avoid this weakness.
策略:
Design signal handlers to only set flags rather than perform complex functionality.
策略:
Ensure that non-reentrant functions are not found in signal handlers.
策略:
Use sanity checks to reduce the timing window for exploitation of race conditions. This is only a partial solution, since many attacks might fail, but other attacks still might work within the narrower window, even accidentally.
In this example, a signal handler uses syslog() to log a message:
bad
标识 | 说明 | 链接 |
---|---|---|
CVE-2005-0893 | signal handler calls function that ultimately uses malloc() | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-0893 |
CVE-2004-2259 | SIGCHLD signal to FTP server can cause crash under heavy load while executing non-reentrant functions like malloc/free. | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-2259 |
映射的分类名 | ImNode ID | Fit | Mapped Node Name |
---|---|---|---|
CLASP | Unsafe function call from a signal handler | ||
CERT C Secure Coding | SIG30-C | Exact | Call only asynchronous-safe functions within signal handlers |
CERT C Secure Coding | SIG34-C | Do not call signal() from within interruptible signal handlers | |
The CERT Oracle Secure Coding Standard for Java (2011) | EXP01-J | Never dereference null pointers | |
Software Fault Patterns | SFP3 | Use of an improper API |