CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition
BaseLikelihood of exploit: Medium
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.
Consequences
- Integrity, Other: Alter Execution Logic, Unexpected State
- Integrity, Other: Modify Application Data, Modify Files or Directories, Modify Memory, Other
- Integrity, Other: Other
- Non-Repudiation: Hide Activities
- Non-Repudiation, Other: Other
- Other: Unexpected State
How to prevent it
- 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.
Recent advisories
- GHSA-wfhq-q4j2-c37m — filelock: SoftReadWriteLock follows a lock tree swapped in after its first acquire and writes lock records into directories of the user running the lock
- GHSA-fq56-3cx3-fjxp — filelock: SoftFileLock stale-lock break removes a live lock file on a reused inode number and admits two holders
- GHSA-jqc4-5cvw-7w85 — filelock: ReadWriteLock on the hard-link route deletes any directory another user renames onto its .filelock-* link directory name
- GHSA-9vhv-jxww-xfm5 — filelock: ReadWriteLock on Windows acts on SQLite side files another local user places beside its database
- GHSA-322m-ff4g-9vx9 — Ghost: Server-Side Request Forgery in Bookmark Fetching
- GHSA-vv43-5jgx-7qv8 — Electron: Local race condition in Squirrel.Mac update installation on macOS
- EEF-CVE-2026-82761 — Magic link single-use tokens replayable via TOCTOU race in AshAuthentication
- GHSA-4v28-j6q3-5m4r — Open WebUI: SSRF into internal services via DNS rebinding in the Playwright web loader
- GHSA-x9r9-c232-4q39 — Hugging Face Transformers downloads custom generation code before trust consent
- GHSA-p7gw-2pcp-5pf8 — Klever: Marketplace settlement mints KLV when referral % + royalty % exceed the bid (negative seller share silently skipped)
- GHSA-hmfx-4v44-9qw9 — PraisonAI vulnerable to Server-Side Request Forgery via DNS rebinding bypass in webhook_url validation
- GHSA-rg5q-pp8p-f7jm — PraisonAI: Webhook SSRF via DNS fail-open in `JobSubmitRequest.validate_webhook_url()` — bypass of CVE-2026-40114
- EEF-CVE-2026-73829 — Non-atomic hash-credential dedup in mpp Tempo allows replay of a confirmed payment under a concurrent race
- GHSA-vg6p-v9vm-6fgj — praisonaiagents vulnerable to SSRF in web_crawl tool via redirect-following and DNS rebinding (validate-then-fetch gap)
- GHSA-jm7p-cc5g-qwxx — Electron: Parent process code-sign check is spoofable
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor