CWEweakness
CWE-367 Time-of-check Time-of-use (TOCTOU) Race Condition
Medium
Official page ↗
- Alternate terms
- TOCTTOU, TOCCTOU
- Abstraction
- Base
- Structure
- Simple
- Status
- Incomplete
- Likelihood of exploit
- Medium
- Languages
- Not Language-Specific
- CWE version
- 5.0
Description
The product checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check.
Common consequences
• Integrity, Other: Alter Execution Logic, Unexpected State — The attacker can gain access to otherwise unauthorized resources.
• Integrity, Other: Modify Application Data, Modify Files or Directories, Modify Memory, Other — Race conditions such as this kind may be employed to gain read or write access to resources which are not normally readable or writable by the user in question.
• Integrity, Other: Other — The resource in question, or other resources (through the corrupted one), may be changed in undesirable ways by a malicious user.
• Non-Repudiation: Hide Activities — If a file or other resource is written in this method, as opposed to in a valid way, logging of the activity may not occur.
• Non-Repudiation, Other: Other — In some cases it may be possible to delete files a malicious user might not otherwise have access to, such as log files.
• Other: Unexpected State — The product may perform invalid actions when the resource is in an unexpected state.
Potential mitigations
• [Implementation] The most basic advice for TOCTOU vulnerabilities is to not perform a check before the use. This does not resolve the underlying issue of the execution of a function on a resource whose state and identity cannot be assured, but it does help to limit the false sense of security given by the check.
• [Implementation] When the file being altered is owned by the current user and group, set the effective gid and uid to that of the current user and group when executing this statement.
• [Architecture and Design] Limit the interleaving of operations on files from multiple processes.
• [Implementation, Architecture and Design] If you cannot perform operations atomically and you must share access to the resource between multiple processes or threads, then try to limit the amount of time (CPU cycles) between the check and use of the resource. This will not fix the problem, but it could make it more difficult for an attack to succeed.
• [Implementation] Recheck the resource after the use call to verify that the action was taken appropriately.
• [Architecture and Design] Ensure that some environmental locking mechanism can be used to protect resources effectively.
• [Implementation] Ensure that locking occurs before the check, as opposed to afterwards, such that the resource, as checked, is the same as it is when in use.
Detection methods
• Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Observed examples
• CVE-2015-1743: TOCTOU in sandbox process allows installation of untrusted browser add-ons by replacing a file after it has been verified, but before it is executed
• CVE-2003-0813: Chain: A multi-threaded race condition (CWE-367) allows attackers to cause two threads to process the same RPC request, which causes a use-after-free (CWE-416) in one thread
• CVE-2004-0594: PHP flaw allows remote attackers to execute arbitrary code by aborting execution before the initialization of key data structures is complete.
• CVE-2008-2958: Chain: time-of-check time-of-use (TOCTOU) race condition in program allows bypass of protection mechanism that was designed to prevent symlink attacks.
• CVE-2008-1570: Chain: time-of-check time-of-use (TOCTOU) race condition in program allows bypass of protection mechanism that was designed to prevent symlink attacks.
Related
Attack pattern · CAPEC (2)
Observed example · CVE (5)
- CVE-2015-1743 Microsoft Internet Explorer 7 through 11 allows remote attackers to gain privileges via a crafted web site, aka "Internet Explorer… vulnerability
- CVE-2008-2958 Race condition in (1) checkinstall 1.6.1 and (2) installwatch allows local users to overwrite arbitrary files and have other impacts via… vulnerability
- CVE-2008-1570 Race condition in the create_lockpath function in policyd-weight 0.1.14 beta-16 allows local users to modify or delete arbitrary files by… vulnerability
- CVE-2004-0594 The memory_limit functionality in PHP 4.x up to 4.3.7, and 5.x up to 5.0.0RC3, under certain conditions such as when register_globals is… vulnerability
- CVE-2003-0813 A multi-threaded race condition in the Windows RPC DCOM functionality with the MS03-039 patch installed allows remote attackers to cause a… vulnerability
Child of · CWE (1)
- CWE-362 Concurrent Execution using Shared Resource with Improper Synchronization weakness
Referenced by CAPEC · weakness (2)
Referenced by CVE · weakness (914)
- CVE-2026-117603 Electrum before 4.7.2 contains a spending limit bypass vulnerability in the Nostr Wallet Connect plugin that allows malicious NWC clients… vulnerability
- CVE-2026-92374 A time-of-check time-of-use (TOCTOU) race condition combined with improper symbolic link handling in the privileged helper of TeamViewer… vulnerability
- CVE-2026-77059 boneIO Black contains a TOCTOU race condition in the create_timedatectl_sudoers_file() function in boneio/webui/routes/timezone_sudoers.py. vulnerability
- CVE-2026-105481 A flaw in Node.js HTTP Agent connection reuse can cause a client to accept as valid a response that was sent before the client has sent the… vulnerability
- CVE-2026-57114 PraisonAI is a multi-agent teams system. vulnerability
- CVE-2026-75524 OpenReception's appointment booking software provides an end-to-end encrypted appointment booking platform. vulnerability
- CVE-2026-112935 filelock is a platform-independent file lock for Python. vulnerability
- CVE-2026-112937 filelock is a platform-independent file lock for Python. vulnerability
- CVE-2026-112941 filelock is a platform-independent file lock for Python. vulnerability
- CVE-2026-80353 Time-of-check time-of-use (TOCTOU) race condition vulnerability in Apache Tomcat when creating unix domain sockets for the APR/Native… vulnerability
- CVE-2025-68404 A time-of-check time-of-use (toctou) race condition vulnerability has been reported to affect QuRouter. vulnerability
- CVE-2026-101308 When an audio channel's buffer needs to be resized, the sound(4) driver checks that the buffer is not memory-mapped and then drops the… vulnerability
- CVE-2026-57569 Lychee is a free, open-source photo-management tool. vulnerability
- CVE-2026-94621 AliasVault is a privacy-first password manager with built-in email aliasing. vulnerability
- CVE-2026-102354 BentoPDF is a privacy-focused PDF toolkit that runs in the browser. vulnerability
- CVE-2026-53612 util-linux is a random collection of Linux utilities. vulnerability
- CVE-2026-53613 util-linux is a random collection of Linux utilities. vulnerability
- CVE-2026-86848 A flaw was found in DPDK lib/vhost vhost-crypto. vulnerability
- CVE-2026-93683 A flaw was found in the DPDK vhost library. vulnerability
- CVE-2026-102672 Electron is a framework for writing cross-platform desktop applications using JavaScript, HTML and CSS. vulnerability
- CVE-2026-102832 JupyterLab is an extensible environment for interactive and reproducible computing, based on the Jupyter Notebook Architecture. vulnerability
- CVE-2026-108396 Time-of-check time-of-use (toctou) race condition in Windows Modern Device Management (MDM) allows an authorized attacker to elevate… vulnerability
- CVE-2026-62840 Time-of-check time-of-use (toctou) race condition in Linux Kernel allows an authorized attacker to elevate privileges locally. vulnerability
- CVE-2026-70075 Time-of-check time-of-use (toctou) race condition in Windows Virtualization-Based Security (VBS) Enclave allows an authorized attacker to… vulnerability
- CVE-2026-70122 Time-of-check time-of-use (toctou) race condition in Windows Broadcast DVR User Service allows an authorized attacker to elevate privileges… vulnerability
- CVE-2026-70288 Time-of-check time-of-use (toctou) race condition in Windows Win32 Kernel Subsystem allows an authorized attacker to disclose information… vulnerability
- CVE-2026-83504 Time-of-check time-of-use (toctou) race condition in Windows SmartScreen allows an authorized attacker to disclose information locally. vulnerability
- CVE-2026-83505 Time-of-check time-of-use (toctou) race condition in Windows Setup Files Cleanup allows an authorized attacker to elevate privileges… vulnerability
- CVE-2026-83510 Time-of-check time-of-use (toctou) race condition in Windows Setup Files Cleanup allows an authorized attacker to elevate privileges… vulnerability
- CVE-2026-83697 Time-of-check time-of-use (toctou) race condition in Windows Modern Device Management (MDM) allows an authorized attacker to perform… vulnerability
Referenced by CWE · can precede (1)
- CWE-609 Double-Checked Locking weakness
Referenced by CWE · child of (1)
- CWE-363 Race Condition Enabling Link Following weakness
Referenced by CWE · has member (1)
- CWE-884 CWE Cross-section view
Referenced by CWE · peer of (1)
- CWE-386 Symbolic Name not Mapping to Correct Object weakness
Referenced by OWASP · mapped cwe (1)
- CS-Business_Logic_Security Business Logic Security Cheat Sheet Cheat Sheet