Common Weakness Enumeration

A Community-Developed List of Software Weakness Types

CWE/SANS Top 25 Most Dangerous Software Errors
Home > CWE List > CWE- Individual Dictionary Definition (2.11)  

CWE-479: Signal Handler Use of a Non-reentrant Function

Weakness ID: 479
Abstraction: Variant
Status: Draft
Presentation Filter:
+ Description

Description Summary

The program defines a signal handler that calls a non-reentrant function.

Extended Description

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.

+ Time of Introduction
  • Architecture and Design
  • Implementation
+ Applicable Platforms




+ Common Consequences

Technical Impact: Execute unauthorized code or commands

It may be possible to execute arbitrary code through the use of a write-what-where condition.


Technical Impact: Modify application data

Signal race conditions often result in data corruption.

+ Likelihood of Exploit


+ Demonstrative Examples

Example 1

In this example, a signal handler uses syslog() to log a message:

char *message;
void sh(int dummy) {
int main(int argc,char* argv[]) {

If the execution of the first call to the signal handler is suspended after invoking syslog(), and the signal handler is called a second time, the memory allocated by syslog() enters an undefined, and possibly, exploitable state.

+ Observed Examples
signal handler calls function that ultimately uses malloc()
handler for SIGCHLD uses non-reentrant functions
+ Potential Mitigations

Phase: Requirements

Require languages or libraries that provide reentrant functionality, or otherwise make it easier to avoid this weakness.

Phase: Architecture and Design

Design signal handlers to only set flags rather than perform complex functionality.

Phase: Implementation

Ensure that non-reentrant functions are not found in signal handlers.

Phase: 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.

Effectiveness: Defense in Depth

+ Relationships
NatureTypeIDNameView(s) this relationship pertains toView(s)
ChildOfCategoryCategory429Handler Errors
Development Concepts699
ChildOfCategoryCategory634Weaknesses that Affect System Processes
Resource-specific Weaknesses (primary)631
ChildOfWeakness BaseWeakness Base663Use of a Non-reentrant Function in a Concurrent Context
Development Concepts699
Research Concepts1000
ChildOfCategoryCategory745CERT C Secure Coding Section 11 - Signals (SIG)
Weaknesses Addressed by the CERT C Secure Coding Standard (primary)734
ChildOfWeakness BaseWeakness Base828Signal Handler with Functionality that is not Asynchronous-Safe
Development Concepts (primary)699
Research Concepts (primary)1000
ChildOfCategoryCategory847CERT Java Secure Coding Section 02 - Expressions (EXP)
Weaknesses Addressed by the CERT Java Secure Coding Standard (primary)844
ChildOfCategoryCategory879CERT C++ Secure Coding Section 11 - Signals (SIG)
Weaknesses Addressed by the CERT C++ Secure Coding Standard (primary)868
ChildOfCategoryCategory1001SFP Secondary Cluster: Use of an Improper API
Software Fault Pattern (SFP) Clusters (primary)888
CanPrecedeWeakness BaseWeakness Base123Write-what-where Condition
Research Concepts1000
+ Affected Resources
  • System Process
+ Taxonomy Mappings
Mapped Taxonomy NameNode IDFitMapped Node Name
CLASPUnsafe function call from a signal handler
CERT C Secure CodingSIG30-CCall only asynchronous-safe functions within signal handlers
CERT C Secure CodingSIG32-CDo not call longjmp() from inside a signal handler
CERT C Secure CodingSIG33-CDo not recursively invoke the raise() function
CERT C Secure CodingSIG34-CDo not call signal() from within interruptible signal handlers
CERT Java Secure CodingEXP01-JNever dereference null pointers
CERT C++ Secure CodingSIG30-CPPCall only asynchronous-safe functions within signal handlers
CERT C++ Secure CodingSIG33-CPPDo not recursively invoke the raise() function
CERT C++ Secure CodingSIG34-CPPDo not call signal() from within interruptible signal handlers
Software Fault PatternsSFP3Use of an improper API
+ References
[REF-7] Mark Dowd, John McDonald and Justin Schuh. "The Art of Software Security Assessment". Chapter 13, "Signal Vulnerabilities", Page 791.. 1st Edition. Addison Wesley. 2006.
+ Content History
Submission DateSubmitterOrganizationSource
CLASPExternally Mined
Modification DateModifierOrganizationSource
2008-07-01Eric DalciCigitalExternal
updated Time_of_Introduction
2008-09-08CWE Content TeamMITREInternal
updated Applicable_Platforms, Common_Consequences, Description, Relationships, Other_Notes, Taxonomy_Mappings
2008-11-24CWE Content TeamMITREInternal
updated Relationships, Taxonomy_Mappings
2010-09-27CWE Content TeamMITREInternal
updated Relationships
2010-12-13CWE Content TeamMITREInternal
updated Demonstrative_Examples, Description, Name, Observed_Examples, Other_Notes, Potential_Mitigations, Relationships
2011-06-01CWE Content TeamMITREInternal
updated Common_Consequences, Relationships, Taxonomy_Mappings
2011-06-27CWE Content TeamMITREInternal
updated Common_Consequences
2011-09-13CWE Content TeamMITREInternal
updated Relationships, Taxonomy_Mappings
2012-05-11CWE Content TeamMITREInternal
updated References, Relationships, Taxonomy_Mappings
2012-10-30CWE Content TeamMITREInternal
updated Demonstrative_Examples
2014-07-30CWE Content TeamMITREInternal
updated Relationships, Taxonomy_Mappings
Previous Entry Names
Change DatePrevious Entry Name
2010-12-13Unsafe Function Call from a Signal Handler

More information is available — Please select a different filter.
Page Last Updated: May 05, 2017