CWE-479: Signal Handler Use of a Non-reentrant Function
The product defines a signal handler that calls a non-reentrant function.
How it's found
Signal Handler Use of a Non-reentrant Function is a specific, narrowly defined instance of a broader pattern. Testers confirm it with targeted code review and a proof-of-concept input that exercises the exact code path this weakness describes.
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 and 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.
Consequences
- Execute Unauthorized Code or Commands: It may be possible to execute arbitrary code through the use of a write-what-where condition.
- Modify Memory, Modify Application Data: Signal race conditions often result in data corruption.
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.
Where this fits in a TurboPentest engagement
TurboPentest's agentic pentest is powerful and covers a broad range of issues automatically. This particular class is best confirmed in a manual IntegSec engagement, where human pentesters apply deeper methodology and a larger context window than any automated pass.
Frequently asked questions
What is CWE-479?
The product defines a signal handler that calls a non-reentrant function.
How do you find Signal Handler Use of a Non-reentrant Function?
Signal Handler Use of a Non-reentrant Function is a specific, narrowly defined instance of a broader pattern. Testers confirm it with targeted code review and a proof-of-concept input that exercises the exact code path this weakness describes.
What is the impact of CWE-479?
Execute Unauthorized Code or Commands: It may be possible to execute arbitrary code through the use of a write-what-where condition. Modify Memory, Modify Application Data: Signal race conditions often result in data corruption.
Does TurboPentest test for Signal Handler Use of a Non-reentrant Function?
TurboPentest's agentic pentest is powerful and covers a broad range of issues automatically. This particular class is best confirmed in a manual IntegSec engagement, where human pentesters apply deeper methodology and a larger context window than any automated pass.
Related CWEs
Find these issues before an attacker does
TurboPentest runs an agentic AI pentest against your target and reports findings with proof, from $99 per target.
Start a $99 pentest