CVE-2026-112937
Filelock's ReadWriteLock cleanup can be hijacked to rename and delete sibling dirs.
- CVSS 6.1
- CWE-367
- Race Conditions
- Local
filelock is a platform-independent file lock for Python. From 4.1.0 until 4.2.1, ReadWriteLock can remove a randomized .filelock-* private-hard-link directory during cleanup, allowing another local user with rename access in a non-sticky parent to observe a live name or forge a dead-owner sweep name and rename a sibling directory onto it for deletion. This issue is fixed in version 4.2.1.
- CWE
- CWE-367
- CVSS base score
- 6.1
- Published
- 2026-10-20
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Timing/Serialization
- Code defect classification
- Serialization 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 filelock to version 4.2.1 or later.
Vulnerable code sample
import os
import tempfile
from filelock import ReadWriteLock
def process_shared_resource(path: str):
lock_path = os.path.join(tempfile.gettempdir(), ".filelock-" + os.path.basename(path))
lock = ReadWriteLock(lock_path)
# VULNERABLE: cleanup removes randomized private-hard-link directory, race condition
lock.acquire()
try:
with open(path, "a+") as f:
f.write("update\n")
finally:
lock.release() # cleanup triggers unsafe removalPatched code sample
import os
import tempfile
from filelock import ReadWriteLock
def process_shared_resource(path: str):
lock_path = os.path.join(tempfile.gettempdir(), ".filelock-" + os.path.basename(path))
lock = ReadWriteLock(lock_path)
# FIX: disable unsafe cleanup to avoid race condition
lock.acquire()
try:
with open(path, "a+") as f:
f.write("update\n")
finally:
lock.release(cleanup=False) # prevent removal of private-hard-link directoryPublished 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(read-write): keep SQLite off shared names, bound schema (#834) (tox-dev/filelock)
src/filelock/_api.py · BaseFileLock.__init__,src/filelock/_read_write.py,src/filelock/_read_write.py · ReadWriteLock._configure_and_begin,src/filelock/_read_write.py · _connect,src/filelock/_read_write.py · _connect_through_descriptor,src/filelock/_read_write.py · _ForkSafeConnection.close,src/filelock/_read_write.py · _ForkSafeConnection.retain_until_close,src/filelock/_read_write.py · _link_beside,src/filelock/_read_write.py · _owner_is_gone,src/filelock/_read_write.py · _ProbeDescriptors.adopt,src/filelock/_read_write.py · _sweep_links_of_the_dead,src/filelock/_windows.pyand 2 more
Cite this entry
@misc{vaitp:cve2026112937,
title = {{Filelock's ReadWriteLock cleanup can be hijacked to rename and delete sibling dirs.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-112937},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-112937/}}
}
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 ::
