CVE-2025-68146 Details
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.
A Time-of-Check-Time-of-Use (TOCTOU) race condition vulnerability has been identified in the filelock library for Python, affecting versions prior to 3.20.1. This vulnerability allows local attackers to corrupt or truncate arbitrary user files through symlink attacks. The issue arises during the lock file creation process on both Unix and Windows platforms. When filelock checks if a file exists before opening it with the O_TRUNC flag, an attacker can create a symlink to a target file in the brief interval between the check and the open operation. As a result, the os.open() function follows the symlink and truncates the intended file, leading to data loss or corruption. All users of filelock on Unix, Linux, macOS, and Windows systems are impacted, and the vulnerability also affects dependent libraries such as virtualenv and PyTorch. Exploitation requires local filesystem access and the ability to create symlinks, with success rates of 25-90% depending on the target application.
Users are advised to upgrade to filelock version 3.20.1 or later. If an immediate upgrade is not possible, consider using SoftFileLock instead of UnixFileLock or WindowsFileLock, ensuring that lock file directories have restrictive permissions to prevent untrusted users from creating sylinks, and monitoring lock file directories for suspicious symlinks before running trusted applications.
Metrics
CVSS 4.0 Severity and Vector Strings:
No CVSS 4.0 data is available for this CVE.
CVSS 3.x Severity and Vector Strings:
No data available for CVSS Version 2.0 on this CVE.
CISA-ADP
Assessed Dec 17, 2025References to Advisories, Solutions, and Tools
By selecting these links, you will be leaving this site. These are references gathered from the official CVE record and are not endorsed by Volerion.
| URL | Source(s) | Tag(s) |
|---|---|---|
| https://github.com/tox-dev/filelock/commit/4724d7f8c3393ec1f048c93933e6e3e6ec321f0e | [email protected] | Patch |
| https://github.com/tox-dev/filelock/pull/461 | [email protected] | Issue TrackingPatch |
| https://github.com/tox-dev/filelock/releases/tag/3.20.1 | [email protected] | ProductRelease Notes |
| https://github.com/tox-dev/filelock/security/advisories/GHSA-w853-jp5j-5j7f | [email protected] | ExploitMitigationVendor Advisory |
Weakness Enumeration
| CWE-ID | CWE Name | Source |
|---|---|---|
| CWE-367 | Time-of-check Time-of-use (TOCTOU) Race Condition | [email protected] |
| CWE-362 | Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition') | [email protected] |
| CWE-367 | Time-of-check Time-of-use (TOCTOU) Race Condition | [email protected] |
| CWE-59 | Improper Link Resolution Before File Access ('Link Following') | [email protected] |
Affected Products
| Product | Versions |
|---|---|
| tox-dev filelock | < 3.20.1 |
CPE
Remediation
| |
Change History
4 change records found show changes
| Date | Action | Recorded By |
|---|---|---|
| Jun 17, 2026 | CVE Modified | [email protected] |
| Jun 17, 2026 | CVE Modified | CISA-ADP |
| Mar 5, 2026 | Initial Analysis | [email protected] |
| Dec 16, 2025 | New CVE Received | [email protected] |