Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-112940 Overview
CVE-2026-112940 affects filelock, a platform-independent file lock library for Python maintained by tox-dev. The flaw exists in the ReadWriteLock implementation from version 3.20.4 up to 4.2.1. SQLite reopens the lock database and its side files (-journal, -wal, -shm) by name rather than by file descriptor. On POSIX systems, an attacker with rename permissions in a non-sticky parent directory can swap those names to trigger overwrite or unlink operations against unrelated files. When a writable adjacent hot journal is also present, the attacker can control the content written during SQLite journal replay. The issue is fixed in version 4.2.1.
Critical Impact
Local attackers with directory rename access can cause unintended file overwrites or deletions, and in some conditions write attacker-chosen content to arbitrary paths accessible to the locking process.
Affected Products
- tox-dev filelock versions 3.20.4 through 4.2.0 (Python package)
- Applications using filelock.ReadWriteLock on POSIX systems
- Windows deployments where the database directory ACL permits non-privileged accounts to add or remove names
Discovery Timeline
- 2026-10-20 - CVE-2026-112940 published to NVD
- 2026-10-22 - Last updated in NVD database
Technical Details for CVE-2026-112940
Vulnerability Analysis
The filelock.ReadWriteLock class relies on SQLite to coordinate reader and writer state. SQLite opens its database and auxiliary files (-journal, -wal, -shm) using their path names on each access rather than through persistent descriptors. This name-based reopening creates a time-of-check to time-of-use window [CWE-363] that an attacker can exploit through filesystem link and rename primitives [CWE-59].
An attacker with write access to the parent directory can rename the SQLite side files to point at arbitrary paths. When SQLite subsequently writes journal data or unlinks the files during normal replay, the operation affects the attacker-selected target. If the attacker also controls a writable hot journal adjacent to the database, SQLite's recovery logic will replay attacker-supplied content into the swapped target.
Root Cause
The root cause is reliance on filename resolution rather than file descriptor identity for SQLite's lock database management. Non-sticky parent directories on POSIX allow accounts other than the owner to rename or unlink entries inside, which breaks the implicit assumption that the names SQLite reopens still refer to the same inodes. The upstream patch moves the lock database into a directory writable only by trusted accounts and uses private hard links elsewhere so that name-based reopening cannot be redirected.
Attack Vector
Exploitation requires local access with low privileges and no user interaction. The attacker must have rename permission in the parent directory containing the lock database, which commonly occurs when ReadWriteLock is used in world-writable or shared locations such as /tmp or group-writable project directories. Successful exploitation yields high integrity and availability impact through unlink or overwrite of files the locking process can access, while confidentiality is not directly affected.
# Patch summary from docs/changelog/834.bugfix.rst
Fix filelock.ReadWriteLock acting on -journal, -wal or -shm files another
process puts beside its database: a write could land in another file, a
reader could get in beside a writer, and an acquire could fail. SQLite now
opens the database by name only in a directory no other account can write,
and through a private hard link elsewhere. On Windows the directory's
access control list decides. Where hard links are unavailable, keep the
database in a directory other accounts cannot write, such as one under
%LOCALAPPDATA%. The lock removes link directories through a checked
descriptor rather than by name, reads a link directory's name only when
the locking account owns it, and leaves alone a directory with other
content renamed onto a link directory's name. A database whose schema
takes more than a few kilobytes to load raises ValueError instead of
running past the acquire timeout.
# Source: https://github.com/tox-dev/filelock/commit/5e3f2ec0c5fb17cb2635b60b2b68bc63ab81ca2d
Detection Methods for CVE-2026-112940
Indicators of Compromise
- Presence of -journal, -wal, or -shm files beside a filelock SQLite lock database owned by accounts other than the locking process.
- Unexpected rename() or unlink() syscalls targeting lock side files from processes that are not the lock owner.
- Application logs showing sqlite3.OperationalError or acquire failures from ReadWriteLock in shared or world-writable directories.
Detection Strategies
- Inventory Python environments and identify installations of filelock at versions >=3.20.4,<4.2.1 that use ReadWriteLock.
- Audit directories hosting filelock databases for non-sticky permissions and group or world write access.
- Correlate filesystem telemetry on lock paths with the owning process to flag rename or symlink creation by foreign UIDs.
Monitoring Recommendations
- Enable auditd rules on POSIX hosts for rename, renameat, symlink, and unlink operations targeting known lock database directories.
- Monitor for creation of files named *.db-journal, *.db-wal, or *.db-shm by unexpected processes.
- Alert on write failures or unexpected content changes in files adjacent to tracked lock databases.
How to Mitigate CVE-2026-112940
Immediate Actions Required
- Upgrade filelock to version 4.2.1 or later across all Python environments.
- Relocate ReadWriteLock database files to directories writable only by the locking account, such as per-user directories under $HOME or %LOCALAPPDATA% on Windows.
- Remove any residual -journal, -wal, or -shm files from shared directories before restarting applications.
Patch Information
The fix is delivered in filelock 4.2.1 via pull request GitHub Pull Request #834 and commit 5e3f2ec0c5fb17cb2635b60b2b68bc63ab81ca2d. The patch forces SQLite to open the lock database by name only in directories no other account can write, and uses private hard links elsewhere. See the GitHub Security Advisory GHSA-v4x8-3wr5-3wq8 and Filelock Release 4.2.1 for full details.
Workarounds
- Place the lock database in a directory with mode 0700 owned by the locking account to prevent foreign renames.
- On POSIX systems, apply the sticky bit (chmod +t) to parent directories where lock databases must reside alongside other users.
- On Windows, review the directory ACL and restrict add or remove name rights to the locking account, SYSTEM, and Administrators only.
- Avoid using ReadWriteLock in world-writable paths such as /tmp or /var/tmp until the upgrade is applied.
# Configuration example: upgrade and relocate the lock directory
pip install --upgrade 'filelock>=4.2.1'
# Create a private lock directory
install -d -m 0700 "${HOME}/.local/state/myapp/locks"
# On POSIX, enforce the sticky bit on shared parents if relocation is not possible
chmod +t /path/to/shared/parent
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

