CVE-2026-112906
Stale file lock reuse allows attackers to bypass locking and remove live markers.
- CVSS 4.7
- CWE-362
- Race Conditions
- Local
filelock is a platform-independent file lock for Python. From 4.1.0 until 4.2.1, SoftFileLock versions from 4.1.0 can reuse a stale observation when an attacker pre-dates and removes its own marker, at least two lock-user processes are waiting, coarse or matching modification times preserve the observation, and an honest contender creates a fresh marker on the reused inode, causing that live marker to be removed as stale. This issue is fixed in version 4.2.1.
- CWE
- CWE-362
- CVSS base score
- 4.7
- Published
- 2026-10-20
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Timing/Serialization
- Code defect classification
- Timing Issues
- Category
- Race Conditions
- Subcategory
- Race Condition in File Operations
- Accessibility scope
- Local
- Impact
- Denial of Service (DoS)
- Affected component
- Python
- Fixed by upgrading
- Yes
Solution
Upgrade the filelock package to version 4.2.1 or newer.
Vulnerable code sample
import os
from filelock import SoftFileLock
def write_shared_file(path: str, data: str) -> None:
lock_path = f"{path}.lock"
# VULNERABLE: SoftFileLock can reuse a stale marker leading to a race condition
lock = SoftFileLock(lock_path)
with lock:
with open(path, "a") as f:
f.write(data + "\n")Patched code sample
import os
from filelock import FileLock
def write_shared_file(path: str, data: str) -> None:
lock_path = f"{path}.lock"
# FIX: Use FileLock which does not reuse stale markers
lock = FileLock(lock_path)
with lock:
with open(path, "a") as f:
f.write(data + "\n")Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- 🐛 fix(soft): break stale markers without emptying the lock path (#843) (tox-dev/filelock)
src/filelock/_api.py,src/filelock/_api.py · BaseFileLock._try_break_expired_lock,src/filelock/_lease.py,src/filelock/_lease.py · SoftFileLease._read_peer,src/filelock/_lease.py · SoftFileLease._try_break_stale_lock,src/filelock/_lease.py · _RefreshLoop.run,src/filelock/_marker.py,src/filelock/_marker.py · MarkerSoftFileLock._try_break_stale_lock,src/filelock/_soft.py,src/filelock/_soft.py · SoftFileLock._acquire,src/filelock/_soft.py · SoftFileLock._marker_unchanged_for,src/filelock/_soft.py · SoftFileLock._releaseand 7 more
Cite this entry
@misc{vaitp:cve2026112906,
title = {{Stale file lock reuse allows attackers to bypass locking and remove live markers.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-112906},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-112906/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
