---
title: "CAPEC-26: Leveraging Race Conditions"
url: https://radicalnotion.ai/capec/capec-26
type: capec
description: "The adversary targets a race condition occurring when multiple processes access and manipulate the same resource concurrently, and the outcome of the execution depends on the particular order in which the access takes place. The adversary can leverage a race condition by \"running the race\", modifying the resource and modifying the normal execution flow. For instance, a race condition can occur while accessing a file: the adversary can trick the system by replacing the original file with their version and cause the system to read the malicious file."
updated: 2026-06-01
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CAPEC-26: Leveraging Race Conditions

- **Abstraction:** Meta
- **Status:** Stable
- **Typical severity:** High
- **Likelihood of attack:** High
- **CAPEC catalog version:** 3.9

## Description

The adversary targets a race condition occurring when multiple processes access and manipulate the same resource concurrently, and the outcome of the execution depends on the particular order in which the access takes place. The adversary can leverage a race condition by "running the race", modifying the resource and modifying the normal execution flow. For instance, a race condition can occur while accessing a file: the adversary can trick the system by replacing the original file with their version and cause the system to read the malicious file.

## Execution flow

### Step 1: Explore

The adversary explores to gauge what level of access they have.

### Step 2: Experiment

The adversary gains access to a resource on the target host. The adversary modifies the targeted resource. The resource's value is used to determine the next normal execution action.

### Step 3: Exploit

The resource is modified/checked concurrently by multiple processes. By using one of the processes, the adversary is able to modify the value just before it is consumed by a different process. A race condition occurs and is exploited by the adversary to abuse the target host.

## Prerequisites

- A resource is accessed/modified concurrently by multiple processes such that a race condition exists.
- The adversary has the ability to modify the resource.

## Skills required

- **Medium:** Being able to "run the race" requires basic knowledge of concurrent processing including synchonization techniques.

## Consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality, Access Control, Authorization | Gain Privileges | - |
| Integrity | Modify Data | - |

## Mitigations

- Use safe libraries to access resources such as files.
- Be aware that improper use of access function calls such as chown(), tempfile(), chmod(), etc. can cause a race condition.
- Use synchronization to control the flow of execution.
- Use static analysis tools to find race conditions.
- Pay attention to concurrency problems related to the access of resources.

## Example instances

The Net Direct client for Linux before 6.0.5 in Nortel Application Switch 2424, VPN 3050 and 3070, and SSL VPN Module 1000 extracts and executes files with insecure permissions, which allows local users to exploit a race condition to replace a world-writable file in /tmp/NetClient and cause another user to execute arbitrary code when attempting to execute this client, as demonstrated by replacing /tmp/NetClient/client. See also: CVE-2007-1057

The following code illustrates a file that is accessed multiple times by name in a publicly accessible directory. A race condition exists between the accesses where an attacker can replace the file referenced by the name (see \[REF-107\]). include \<sys/types.h\> include \<fcntl.h\> include \<unistd.h\> define FILE "/tmp/myfile" define UID 100 void test(char \*str) { int fd; fd = creat(FILE, 0644); if(fd == -1) return; chown(FILE, UID, -1); /\* BAD \*/ close(fd); } int main(int argc, char \*\*argv) { char \*userstr; if(argc \> 1) { userstr = argv\[1\]; test(userstr); } return 0; }

## Related weaknesses (CWE)

- [CWE-362](https://radicalnotion.ai/cwe/cwe-362): Concurrent Execution using Shared Resource with Improper Synchronization
- [CWE-363](https://radicalnotion.ai/cwe/cwe-363): Race Condition Enabling Link Following
- [CWE-366](https://radicalnotion.ai/cwe/cwe-366): Race Condition within a Thread
- [CWE-368](https://radicalnotion.ai/cwe/cwe-368): Context Switching Race Condition
- [CWE-370](https://radicalnotion.ai/cwe/cwe-370): Missing Check for Certificate Revocation after Initial Check
- [CWE-662](https://radicalnotion.ai/cwe/cwe-662): Improper Synchronization
- [CWE-665](https://radicalnotion.ai/cwe/cwe-665): Improper Initialization
- [CWE-667](https://radicalnotion.ai/cwe/cwe-667): Improper Locking
- [CWE-689](https://radicalnotion.ai/cwe/cwe-689): Permission Race Condition During Resource Copy
- [CWE-1223](https://radicalnotion.ai/cwe/cwe-1223): Race Condition for Write-Once Attributes
- [CWE-1254](https://radicalnotion.ai/cwe/cwe-1254): Incorrect Comparison Logic Granularity
- [CWE-1298](https://radicalnotion.ai/cwe/cwe-1298): Hardware Logic Contains Race Conditions

## Related attack patterns

| Relationship | CAPEC | Name |
| --- | --- | --- |
| Child | [CAPEC-29](https://radicalnotion.ai/capec/capec-29) | Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions |

## Frequently asked questions

### What is CAPEC-26?

The adversary targets a race condition occurring when multiple processes access and manipulate the same resource concurrently, and the outcome of the execution depends on the particular order in which the access takes place. The adversary can leverage a race condition by "running the race", modifying the resource and modifying the normal execution flow. For instance, a race condition can occur while accessing a file: the adversary can trick the system by replacing the original file with their version and cause the system to read the malicious file.

### How does a Leveraging Race Conditions attack work?

It typically unfolds over 3 phases. It begins with: The adversary explores to gauge what level of access they have.

### How do you prevent CAPEC-26?

Use safe libraries to access resources such as files.

### What weaknesses does CAPEC-26 target?

CAPEC-26 exploits 12 CWE weaknesses, including CWE-362 (Concurrent Execution using Shared Resource with Improper Synchronization), CWE-363 (Race Condition Enabling Link Following), CWE-366 (Race Condition within a Thread) and CWE-368 (Context Switching Race Condition).

### How severe is CAPEC-26?

MITRE rates CAPEC-26 as High severity with high likelihood of attack.

Primary source: [MITRE CAPEC](https://capec.mitre.org/data/definitions/26.html)

---

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