CAPECattack pattern
CAPEC-26 Leveraging Race Conditions
High
Official page ↗
- Abstraction
- Meta
- Status
- Stable
- Likelihood of attack
- High
- Typical severity
- High
- CAPEC 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
1. [Explore] The adversary explores to gauge what level of access they have.
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.
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
• 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.
Related
Weakness · CWE (12)
- CWE-1223 Race Condition for Write-Once Attributes weakness
- CWE-1254 Incorrect Comparison Logic Granularity weakness
- CWE-1298 Hardware Logic Contains Race Conditions weakness
- CWE-362 Concurrent Execution using Shared Resource with Improper Synchronization weakness
- CWE-363 Race Condition Enabling Link Following weakness
- CWE-366 Race Condition within a Thread weakness
- CWE-368 Context Switching Race Condition weakness
- CWE-370 Missing Check for Certificate Revocation after Initial Check weakness
- CWE-662 Improper Synchronization weakness
- CWE-665 Improper Initialization weakness
- CWE-667 Improper Locking weakness
- CWE-689 Permission Race Condition During Resource Copy weakness
Referenced by CAPEC · child of (1)
- CAPEC-29 Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions attack pattern
Referenced by CWE · attack pattern (12)
- CWE-1223 Race Condition for Write-Once Attributes weakness
- CWE-1254 Incorrect Comparison Logic Granularity weakness
- CWE-1298 Hardware Logic Contains Race Conditions weakness
- CWE-362 Concurrent Execution using Shared Resource with Improper Synchronization weakness
- CWE-363 Race Condition Enabling Link Following weakness
- CWE-366 Race Condition within a Thread weakness
- CWE-368 Context Switching Race Condition weakness
- CWE-370 Missing Check for Certificate Revocation after Initial Check weakness
- CWE-662 Improper Synchronization weakness
- CWE-665 Improper Initialization weakness
- CWE-667 Improper Locking weakness
- CWE-689 Permission Race Condition During Resource Copy weakness