filelock
Affected
- introduced
0, fixed3.20.3(ecosystem)
Fixed versions
3.20.3
Fix
- Fixed version
3.20.3pip install --upgrade filelock==3.20.3
Advisory
Also known as: CVE-2026-22701, GHSA-qmgc-5h2g-mvrw
filelock Time-of-Check-Time-of-Use (TOCTOU) Symlink Vulnerability in SoftFileLock
Vulnerability Summary
Title: Time-of-Check-Time-of-Use (TOCTOU) Symlink Vulnerability in SoftFileLock
Affected Component: filelock package - SoftFileLock class
File: src/filelock/_soft.py lines 17-27
CWE: CWE-362, CWE-367, CWE-59
---
Description
A TOCTOU race condition vulnerability exists in the SoftFileLock implementation of the filelock package. An attacker with local filesystem access and permission to create symlinks can exploit a race condition between the permission validation and file creation to cause lock operations to fail or behave unexpectedly.
The vulnerability occurs in the _acquire() method between raise_on_not_writable_file() (permission check) and os.open() (file creation). During this race window, an attacker can create a symlink at the lock file path, potentially causing the lock to operate on an unintended target file or leading to denial of service.
Attack Scenario
1. Lock attempts to acquire on /tmp/app.lock
2. Permission validation passes
3. [RACE WINDOW] - Attacker creates: ln -s /tmp/important.txt /tmp/app.lock
4. os.open() tries to create lock file
5. Lock operates on attacker-controlled target file or fails
---
Impact
_What kind of vulnerability is it? Who is impacted?_
This is a Time-of-Check-Time-of-Use (TOCTOU) race condition vulnerability affecting any application using SoftFileLock for inter-process synchronization.
Affected Users:
filelock.SoftFileLock directlyFileLock on systems without fcntl support (e.g., GraalPy)Consequences:
CVSS v4.0 Score: 5.6 (Medium)
Vector: CVSS:4.0/AV:L/AT:L/PR:L/UI:N/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N
Attack Requirements:
---
Patches
_Has the problem been patched? What versions should users upgrade to?_
Yes, the vulnerability has been patched by adding the O_NOFOLLOW flag to prevent symlink following during lock file creation.
Patched Version: Next release (commit: 255ed068bc85d1ef406e50a135e1459170dd1bf0)
Mitigation Details:
O_NOFOLLOW flag is added conditionally and gracefully degrades on platforms without supportO_NOFOLLOW support (most modern systems): symlink attacks are completely preventedO_NOFOLLOW (e.g., GraalPy): TOCTOU window remains but is documentedUsers should:
UnixFileLock or WindowsFileLock instead of the fallback SoftFileLock---
Workarounds
_Is there a way for users to fix or remediate the vulnerability without upgrading?_
For users unable to update immediately:
UnixFileLock or WindowsFileLock when available (these were already patched for CVE-2025-68146) chmod 700 /path/to/lock/directory
---
References
_Are there any links users can visit to find out more?_
---
Reported by: George Tsigourakos (@tsigouris007)
Medium Basis: CVSS v3 score 5.3, vector CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:H
0, fixed 3.20.3 (ecosystem)3.20.3
3.20.3pip install --upgrade filelock==3.20.3Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: PyPA Advisory Database · CC BY 4.0