Time-of-check Time-of-use (TOCTOU) Race Condition Affecting filelock package, versions [4.1.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-21280752
  • published20 Oct 2026
  • disclosed20 Oct 2026
  • creditAnthropic's OSS Scanner

Introduced: 20 Oct 2026

NewCVE-2026-112937  (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 ReadWriteLock cleanup logic in _read_write.py, which removes a randomized .filelock-* private hard-link directory during sweep operations. A local attacker with rename access in a non-sticky parent directory can observe a live link-directory name or forge a dead-owner sweep name, then rename a sibling directory onto it before the cleanup removes it, causing an arbitrary directory to be deleted. The link-directory name is derived from a digest that includes output from host_name(), which only adds a PID-namespace tag when /proc/self/ns/pid is readable, making the name predictable to any local user on macOS or systems without /proc.

Note: Exploitation requires either a macOS host or a Linux attacker that can enter a private mount namespace and mount an empty tmpfs over /proc, obscuring the PID-namespace tag.

CVSS Base Scores

version 4.0
version 3.1