CAPEC-29
Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions
This attack targets a race condition occurring between the time of check (state) for a resource and the time of use of a resource. A typical example is file access. The adversary can leverage a file access race condition by "running the race", meaning that they would modify the resource between the first time the target program accesses the file and the time the target program uses the file. During that period of time, the adversary could replace or modify the file, causing the application to behave unexpectedly.
On this page
Ask an AI about this attack pattern
Show the prompt
Explain the attack pattern CAPEC-29: Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions: how it unfolds, what it needs and how to prevent and detect it in my systems. Use https://capec.mitre.org/data/definitions/29.html and https://cve.bz/cve/capec/29?via=ask-ai-copy, which lists recent CVEs with the weaknesses it exploits. Cite the sources.Opens a third-party assistant; its answer is its own, not cve.bz's. The prompt holds only this attack pattern's id and public links.
How the attack unfolds
Explore
The attacker looks for a way in.
The adversary explores to gauge what level of access they have.
Experiment
They probe what they found.
The adversary confirms access to a resource on the target host. The adversary confirms ability to modify the targeted resource.
Exploit
They carry out the attack.
The adversary decides to leverage the race condition by "running the race", meaning that they would modify the resource between the first time the target program accesses the file and the time the target program uses the file. During that period of time, the adversary can replace the resource and cause an escalation of privilege.
Prerequisites
A resource is access/modified concurrently by multiple processes.
The adversary is able to modify resource.
A race condition exists while accessing a resource.
Skills required
- Medium skill
This attack can get sophisticated since the attack has to occur within a short interval of time.
Consequences
| Impact | Affects | Note |
|---|---|---|
| Modify Data | Integrity | |
| Gain Privileges | Confidentiality, Access Control, Authorization | |
| Alter Execution Logic | Confidentiality, Integrity, Availability | |
| Read Data | Confidentiality | |
| Resource Consumption | Availability | Denial of Service |
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.
Weaknesses it exploits
- CWE-362 Concurrent Execution using Shared Resource with Improper Synchronization
- CWE-366 Race Condition within a Thread
- CWE-367 Time-of-check Time-of-use (TOCTOU) Race Condition
- CWE-368 Context Switching Race Condition
- CWE-370 Missing Check for Certificate Revocation after Initial Check
- CWE-662 Improper Synchronization
- CWE-663 Use of a Non-reentrant Function in a Concurrent Context
- CWE-665 Improper Initialization
- CWE-691 Insufficient Control Flow Management
Recent CVEs with these weaknesses
- 5.9CVE-2026-119007
Race condition vulnerability in the location service module. Impact: Successful exploitation of this vulnerability will affect availability.
- 5.3CVE-2026-119010
Race condition vulnerability in the DSoftBus module. Impact: Successful exploitation of this vulnerability will affect availability.
- 7.3CVE-2026-139905
Intego NetUpdate through X9 contains a time-of-check time-of-use race condition that allows local unprivileged users to escalate privileges by replacing a verified update package before root installation. Attackers can swap the user-writab…
- 4.4CVE-2026-139884
Kudu before 1.48.0 contains a time-of-check time-of-use race condition in the File Shredder feature that allows local unprivileged users to overwrite and delete arbitrary files with elevated privileges. Attackers who can write to a shredde…
- 5.9CVE-2026-102961
Zephyr's IPv6, IPv4 and IEEE 802.15.4 (6LoWPAN) fragment reassembly implementations each keep a global reassembly cache that two threads modify with no synchronization. In the IPv6 code in subsys/net/ip/ipv6_fragment.c, the receive path ru…
- 2.3CVE-2026-138030
SylphxAI pdf-reader-mcp 2.4.1 through 3.0.14, 3.0.16, and 3.1.2 through 3.1.4 contains a server-side request forgery vulnerability in its PDF URL loader, which validates the resolved address but does not pin it for fetch(). Attackers contr…
- 6.7CVE-2026-81053
Dell Secure Connect Gateway - Virtual Edition, versions prior to 5.36.00.16, contains a Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition') vulnerability. A low privileged remote attacker could poten…
- 5.3CVE-2026-80504
Dell Secure Connect Gateway - Virtual Edition, versions prior to 5.36.00.16, contains a Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition') vulnerability. A low privileged local attacker could potent…
The newest records naming one of them. Each weakness's page lists them all.
Related attack patterns
- Part of
- CAPEC-26 Leveraging Race Conditions
- More specific patterns
- CAPEC-27 Leveraging Race Conditions via Symbolic Links
Examples
The Net Direct client for Linux before 6.0.5 in Nortel Application Switch 2424, VPN 3050 and 3070, and SSL VP…
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 direct…
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 adversary can replace the file referenced by the name.
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;
}[REF-107]
MITRE's words, unchanged: CAPEC-29 at MITRE. CAPEC is Copyright © 2007–2026, The MITRE Corporation, used under the CAPEC terms of use: “The MITRE Corporation (MITRE) hereby grants you a non-exclusive, royalty-free license to use Common Attack Pattern Enumeration and Classification (CAPEC™) for research, development, and commercial purposes. Any copy you make for such purposes is authorized provided that you reproduce MITRE’s copyright designation and this license in any such copy.” CAPEC and the CAPEC logo are trademarks of The MITRE Corporation. Credits. All attack patterns.