CVE-2025-68146 filelock has TOCTOU race condition that allows symlink attacks during lock file creation

Medium 6.3 Published Updated

Local attackers can exploit a TOCTOU race condition to corrupt or truncate arbitrary files via symlink attacks during lock file creation.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Local or same network only
Victim action needed
Not needed
Fix
Available

What is CVE-2025-68146?

CVE-2025-68146 is a medium-severity vulnerability in tox-dev filelock, published on 16 Dec 2025. It can only be exploited from the same machine or local network, with no action from the victim.

Official description

filelock is a platform-independent file lock for Python. In versions prior to 3.20.1, a Time-of-Check-Time-of-Use (TOCTOU) race condition allows local attackers to corrupt or truncate arbitrary user files through symlink attacks. The vulnerability exists in both Unix and Windows lock file creation where filelock checks if a file exists before opening it with O_TRUNC. An attacker can create a symlink pointing to a victim file in the time gap between the check and open, causing os.open() to follow the symlink and truncate the target file. All users of filelock on Unix, Linux, macOS, and Windows systems are impacted. The vulnerability cascades to dependent libraries. The attack requires local filesystem access and ability to create symlinks (standard user permissions on Unix; Developer Mode on Windows 10+). Exploitation succeeds within 1-3 attempts when lock file paths are predictable. The issue is fixed in version 3.20.1. If immediate upgrade is not possible, use SoftFileLock instead of UnixFileLock/WindowsFileLock (note: different locking semantics, may not be suitable for all use cases); ensure lock file directories have restrictive permissions (chmod 0700) to prevent untrusted users from creating symlinks; and/or monitor lock file directories for suspicious symlinks before running trusted applications. These workarounds provide only partial mitigation. The race condition remains exploitable. Upgrading to version 3.20.1 is strongly recommended.

Weakness: CWE-59, CWE-367, CWE-362

Which versions are affected by CVE-2025-68146?

3 open source packages ship an affected version, including filelock. It affects 1 product.

PackageAffectedFixed in
filelock PyPIAll versions3.20.1
filelock PyPIAll versions3.20.1
filelock PyPIAll versions3.20.1
Linux distribution packages (3)
python-filelock SUSE:Linux Enterprise Module for Development Tools 15 SP7All versions3.0.12-150100.3.6.1
python-filelock SUSE:Linux Enterprise Module for Package Hub 15 SP7All versions3.0.12-150100.3.6.1
python-filelock openSUSE:TumbleweedAll versions3.20.2-1.1

Products include Tox-Dev Filelock.

How do I fix CVE-2025-68146?

Upgrade filelock to 3.20.1 or later.

Is CVE-2025-68146 being exploited?

There is no known exploitation of CVE-2025-68146 in the wild and no public exploit code.

Sources

Also known as AZL-72739, AZL-79232, BELL-CVE-2025-68146, CLEANSTART-2026-PE38920, DEBIAN-CVE-2025-68146, ECHO-d3c5-64d2-c403 and 13 more.

Is CVE-2025-68146 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free