---
title: "CWE-831: Signal Handler Function Associated with Multiple Signals"
url: https://radicalnotion.ai/cwe/cwe-831
type: cwe
description: "The product defines a function that is used as a handler for more than one signal."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-831: Signal Handler Function Associated with Multiple Signals

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 0
- **Of those, in CISA KEV:** 0
- **New in 2026:** 0
- **CWE catalog version:** 4.21

## Description

The product defines a function that is used as a handler for more than one signal.

While sometimes intentional and safe, when the same function is used to handle multiple signals, a race condition could occur if the function uses any state outside of its local declaration, such as global variables or non-reentrant functions, or has any side effects.

An attacker could send one signal that invokes the handler function; in many OSes, this will typically prevent the same signal from invoking the handler again, at least until the handler function has completed execution. However, the attacker could then send a different signal that is associated with the same handler function. This could interrupt the original handler function while it is still executing. If there is shared state, then the state could be corrupted. This can lead to a variety of potential consequences depending on context, including denial of service and code execution.

Another rarely-explored possibility arises when the signal handler is only designed to be executed once (if at all). By sending multiple signals, an attacker could invoke the function more than once. This may generate extra, unintended side effects. A race condition might not even be necessary; the attacker could send one signal, wait until it is handled, then send the other signal.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Availability, Integrity, Confidentiality, Access Control, Other | DoS: Crash, Exit, or Restart, Execute Unauthorized Code or Commands, Read Application Data, Gain Privileges or Assume Identity, Bypass Protection Mechanism, Varies by Context | The most common consequence will be a corruption of the state of the product, possibly leading to a crash or exit. However, if the signal handler is operating on state variables for security relevant libraries or protection mechanisms, the consequences can be far more severe, including protection mechanism bypass, privilege escalation, or information exposure. |

## Demonstrative examples

### Example 1

This code registers the same signal handler function with two different signals.

Bad code:

```c
void handler (int sigNum) {
    ...
}

int main (int argc, char* argv[]) {
    signal(SIGUSR1, handler)
    signal(SIGUSR2, handler)
}
```

### Example 2

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.

Bad code:

```c
char *logMessage;

void handler (int sigNum) {
    syslog(LOG_NOTICE, "%s\n", logMessage);
    free(logMessage);
    /* artificially increase the size of the timing window to make demonstration of this weakness easier. */

    sleep(10);
    exit(0);
}

int main (int argc, char* argv[]) {
    logMessage = strdup(argv[1]);
    /* Register signal handlers. */

    signal(SIGHUP, handler);
    signal(SIGTERM, handler);
    /* artificially increase the size of the timing window to make demonstration of this weakness easier. */

    sleep(10);
}
```

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-364](https://radicalnotion.ai/cwe/cwe-364) | Signal Handler Race Condition |

## Frequently asked questions

### What is CWE-831?

The product defines a function that is used as a handler for more than one signal.

### What are the consequences of CWE-831?

Exploiting CWE-831 can lead to: DoS: Crash, Exit, or Restart, Execute Unauthorized Code or Commands, Read Application Data, Gain Privileges or Assume Identity, Bypass Protection Mechanism, Varies by Context.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/831.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-831). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
