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


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0% (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-14458335
  • published17 Dec 2025
  • disclosed16 Dec 2025
  • creditGeorge Tsigourakos

Introduced: 16 Dec 2025

CVE-2025-68146  (opens in a new tab)
CWE-362  (opens in a new tab)
CWE-367  (opens in a new tab)
CWE-59  (opens in a new tab)

How to fix?

Upgrade filelock to version 3.20.1 or higher.

Overview

Affected versions of this package are vulnerable to Time-of-check Time-of-use (TOCTOU) Race Condition during lock file creation. An attacker can corrupt or truncate arbitrary files by exploiting a race condition between the existence check and file opening with O_TRUNC, allowing the creation of a symlink that is followed and results in the target file being truncated.

Note:

This is only exploitable if the attacker has local filesystem access and the ability to create symlinks in the lock file directory.

Workaround

This vulnerability can be mitigated by using SoftFileLock instead of UnixFileLock/WindowsFileLock, ensuring lock file directories have restrictive permissions (chmod 0700), and monitoring lock file directories for suspicious symlinks before running trusted applications.

References

CVSS Base Scores

version 4.0
version 3.1