CWEweakness
CWE-479 Signal Handler Use of a Non-reentrant Function
Low
Official page ↗
- Abstraction
- Variant
- Structure
- Simple
- Status
- Draft
- Likelihood of exploit
- Low
- Languages
- C, C++
- CWE version
- 5.0
Description
The product defines a signal handler that calls a non-reentrant function.
Extended description
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.
Common consequences
• 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 Memory, Modify Application Data — Many functions are not reentrant, but some of them can result in the corruption of memory if they are used in a signal handler.
• Availability: Unexpected State, DoS: Crash, Exit, or Restart — This can lead to an unexpected system state and unpredictable results with a variety of potential consequences depending on context, including program crash.
Potential mitigations
• [Requirements] Require languages or libraries that provide reentrant functionality, or otherwise make it easier to avoid this weakness.
• [Architecture and Design] Design signal handlers to only set flags rather than perform complex functionality.
• [Implementation] Ensure that non-reentrant functions are not found in signal handlers.
• [Implementation] 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.
Detection methods
• Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Observed examples
• CVE-2005-0893: signal handler calls function that ultimately uses malloc()
• CVE-2004-2259: SIGCHLD signal to FTP server can cause crash under heavy load while executing non-reentrant functions like malloc/free.
Related
Observed example · CVE (2)
- CVE-2005-0893 modes.c in smail 3.2.0.120 implements signal handlers with certain unsafe library calls, which may allow attackers to execute arbitrary… vulnerability
- CVE-2004-2259 vsftpd before 1.2.2, when under heavy load, allows attackers to cause a denial of service (crash) via a SIGCHLD signal during a malloc or… vulnerability
Can precede · CWE (1)
- CWE-123 Write-what-where Condition weakness
Child of · CWE (2)
Referenced by CVE · weakness (2)
- CVE-2026-44011 Craft CMS is a content management system (CMS). vulnerability
- CVE-2021-26948 Null pointer dereference in the htmldoc v1.9.11 and before may allow attackers to execute arbitrary code and cause a denial of service via… vulnerability