CVEfocus › CVE database › CVE-2025-68146

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

CVSS 6.3 MediumEPSS 0.2% (higher than 3% of CVEs)Published 2025-12-16Updated 2025-12-17Assigner: GitHub_M

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.

CWE-362CWE-367CWE-59

What to do

Fixed builds are available from Debian, PyPI: see the table below for the fixed version per release.

Ubuntu has not shipped a fix for every release yet.

Is your server affected? One read-only command checks every installed package against this CVE and all others, using each vendor's fixed versions. Get started or get a free API key.

curl -sS "https://api.cvefocus.com/v1/check?format=text" -H "Authorization: Bearer $CVEFOCUS_KEY" \
  -H "Content-Type: text/plain" --data-binary @inventory.txt

Vendor status at a glance

4Fixed
4Fix pending
1Will not fix
1Not affected

Status by vendor and release

From each vendor's own security data and VEX statements. "Fixed" means a fixed build is published for that release.

ReleasePackageStatusFixed versionAdvisory
Ubuntu 26.10python-filelockFix pendingUBUNTU-CVE-2025-68146
Ubuntu 26.04python-filelockNot affected
vulnerable_code_not_present
Ubuntu 25.10python-filelockWill not fix
Ubuntu decided not to fix this in this release
UBUNTU-CVE-2025-68146
Ubuntu 24.04python-filelockFix pending3.13.1-1ubuntu0.1~esm1 (Ubuntu Pro)UBUNTU-CVE-2025-68146
Ubuntu 22.04python-filelockFix pending3.6.0-1ubuntu0.1~esm1 (Ubuntu Pro)UBUNTU-CVE-2025-68146
Ubuntu 18.04python-filelockFix pending3.0.4-1ubuntu0.1~esm1 (Ubuntu Pro)UBUNTU-CVE-2025-68146
Debian 14python-filelockFixed3.20.2-1DEBIAN-CVE-2025-68146
Debian 13python-filelockFixed3.18.0-1+deb13u1DEBIAN-CVE-2025-68146
Debian 12python-filelockFixed3.9.0-1+deb12u1DEBIAN-CVE-2025-68146
PyPI libraryfilelockFixed3.20.1PYSEC-2026-1375

What the vendor says

As published in the CVE record by GitHub_M, the CVE's assigner (usually the vendor). Check the vendor's advisory before acting.

References

About this page

Compiled by CVEfocus from the CVE List, the security data and VEX statements of Ubuntu, Debian, Red Hat, AlmaLinux, Rocky Linux and Microsoft, CISA's Known Exploited Vulnerabilities catalog and FIRST EPSS, refreshed several times a day (data status). Information only; see the disclaimer. Official record: cve.org · NVD.