Time-of-check Time-of-use (TOCTOU) Race Condition Affecting filelock package, versions [3.22.0,4.2.1)


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.1% (1st percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Time-of-check Time-of-use (TOCTOU) Race Condition vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-FILELOCK-21280755
  • published20 Oct 2026
  • disclosed20 Oct 2026
  • creditAnthropic's OSS Scanner

Introduced: 20 Oct 2026

NewCVE-2026-112935  (opens in a new tab)
CWE-367  (opens in a new tab)

How to fix?

Upgrade filelock to version 4.2.1 or higher.

Overview

Affected versions of this package are vulnerable to Time-of-check Time-of-use (TOCTOU) Race Condition via the stale-lock-breaking logic in _try_break_expired_lock and _try_break_stale_lock, where a race condition allows an attacker with write access to the lock directory to replace a held lock file with a new file between the time the inode is read and the time the break is executed. Because the original code did not pin the inode before acting on the stale marker, an attacker can cause the stale-break logic to evict a live lock, allowing two processes to hold the same lock simultaneously and corrupting the integrity guarantee that filelock provides.

Note: This is only exploitable when another local user has write access to the lock file's directory or any of its ancestor directories.

CVSS Base Scores

version 4.0
version 3.1