Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…

CVE-2025-68146: CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition in tox-dev filelock

0
Medium
VulnerabilityCVE-2025-68146cvecve-2025-68146cwe-367cwe-59cwe-362
Published: Tue Dec 16 2025 (12/16/2025, 18:10:54 UTC)
Source: CVE Database V5
Vendor/Project: tox-dev
Product: filelock

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.

AI-Powered Analysis

AILast updated: 12/16/2025, 18:40:43 UTC

Technical Analysis

The vulnerability CVE-2025-68146 affects the tox-dev project's filelock Python library, which provides platform-independent file locking mechanisms. In versions before 3.20.1, a TOCTOU race condition exists during lock file creation on both Unix-like and Windows systems. The flaw occurs because filelock first checks if a lock file exists and then opens it with the O_TRUNC flag to truncate it if present. Between the existence check and the open call, an attacker with local filesystem access can create a symbolic link pointing to an arbitrary target file. When filelock opens the lock file path, it follows the symlink and truncates the target file, leading to corruption or data loss. This attack requires the ability to create symlinks, which is standard for non-privileged users on Unix systems and possible on Windows 10+ with Developer Mode enabled. The attack is facilitated when lock file paths are predictable, and exploitation typically succeeds within 1-3 attempts. Because filelock is widely used and included as a dependency in many Python projects, this vulnerability can cascade to numerous applications across multiple platforms. The vulnerability impacts integrity and availability of files but does not directly affect confidentiality. The issue is fixed in version 3.20.1 of filelock. Until upgrading, mitigations include switching to SoftFileLock (which uses different locking semantics and may not be suitable for all use cases), enforcing strict permissions (chmod 0700) on lock file directories to prevent unauthorized symlink creation, and monitoring these directories for suspicious symlinks. However, these mitigations only partially reduce risk, as the race condition remains exploitable. No known exploits in the wild have been reported as of publication.

Potential Impact

For European organizations, this vulnerability poses a significant risk to the integrity and availability of critical files managed by Python applications that rely on the filelock library. Since filelock is used for coordinating access to shared resources, successful exploitation could lead to data corruption, loss of important files, or disruption of services that depend on reliable file locking. This could affect software development environments, automated deployment pipelines, configuration management, and other operational processes that use filelock for concurrency control. The local nature of the attack limits remote exploitation but insider threats, compromised endpoints, or malicious local users could leverage this vulnerability to cause damage. The cascading effect through dependent libraries increases the attack surface, potentially impacting a broad range of applications. For organizations handling sensitive or regulated data, such as financial institutions, healthcare providers, and critical infrastructure operators, file corruption or service disruption could lead to compliance violations, operational downtime, and reputational damage. The requirement for local access and symlink creation privileges somewhat limits the threat but does not eliminate it, especially in environments with multiple users or less restrictive permissions.

Mitigation Recommendations

The primary mitigation is to upgrade all instances of the filelock library to version 3.20.1 or later, which contains the fix for the TOCTOU race condition. For environments where immediate upgrade is not feasible, organizations should: 1) Replace UnixFileLock and WindowsFileLock with SoftFileLock cautiously, understanding the different locking semantics and evaluating suitability for their use cases. 2) Restrict permissions on directories used for lock files to mode 0700 or equivalent, ensuring only trusted users can create files or symlinks there. 3) Implement monitoring and alerting for the creation of unexpected symbolic links within lock file directories to detect potential exploitation attempts. 4) Review and harden local user permissions to minimize the ability of untrusted users to create symlinks, especially on Windows systems by disabling Developer Mode if not required. 5) Audit dependent libraries and applications for usage of vulnerable filelock versions and coordinate patching across the software supply chain. 6) Incorporate file integrity monitoring on critical files to detect unexpected truncation or corruption. These steps collectively reduce the risk but do not fully eliminate it until the upgrade is applied.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.2
Assigner Short Name
GitHub_M
Date Reserved
2025-12-15T19:06:04.108Z
Cvss Version
3.1
State
PUBLISHED

Threat ID: 6941a4041a61eff6269a9342

Added to database: 12/16/2025, 6:25:08 PM

Last enriched: 12/16/2025, 6:40:43 PM

Last updated: 12/17/2025, 12:21:26 AM

Views: 43

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats