Skip to main content
Vulnerability Database/CVE-2026-112941

CVE-2026-112941: Tox-dev Filelock Privilege Escalation

CVE-2026-112941 is a privilege escalation flaw in Tox-dev Filelock that allows local users to redirect lock operations into writable directories. This article covers technical details, affected versions, and mitigation.

Published:

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-112941 Overview

CVE-2026-112941 is a time-of-check time-of-use (TOCTOU) race condition in the filelock Python library maintained by tox-dev. The SoftReadWriteLock and AsyncSoftReadWriteLock classes cache a successful ownership check of the <path>.rw lock tree and later re-resolve the path by name during record operations. A local user with write access to the parent directory can replace the lock tree between the check and subsequent use, redirecting lock-record writes into attacker-controlled directories. The flaw affects versions 4.1.0 through 4.2.0 and is fixed in version 4.2.1. It is classified under CWE-367.

Critical Impact

A local, authenticated user can redirect lock-record writes performed by another user into directories the attacker controls, enabling integrity tampering of lock state.

Affected Products

  • tox-dev/filelock for Python, versions 4.1.0 through 4.2.0
  • Applications using filelock.SoftReadWriteLock
  • Applications using filelock.AsyncSoftReadWriteLock

Discovery Timeline

  • 2026-10-20 - CVE-2026-112941 published to NVD
  • 2026-10-21 - Last updated in NVD database

Technical Details for CVE-2026-112941

Vulnerability Analysis

The SoftReadWriteLock implementation performs an ownership check on the <path>.rw coordination directory during acquisition and caches that result. Subsequent record operations such as writing holder entries or heartbeat updates resolve the same path by name rather than by a stable file descriptor. This gap between check and use is the classic TOCTOU window.

A local attacker who can modify the parent directory of the lock path can replace <path>.rw with a tree pointing at directories writable only by the lock-holding user. When the legitimate process next writes a record under that cached-but-stale assumption, the write lands in the attacker-controlled location. The confidentiality impact is None, but integrity of the lock state is compromised, which can poison coordination between cooperating processes.

Root Cause

The root cause is path-based re-resolution after a one-time ownership verification. Lock-record operations traversed <path>.rw, gen, and holders by name, so a symlink or junction swapped in after the initial check altered the write target. The fixed implementation holds those directories open through descriptors opened with no-follow semantics and refuses junctions on Windows, as described in the 842.bugfix.rst changelog.

Attack Vector

Exploitation requires local access and low privileges on the host. The attacker must share filesystem write access to a directory where the victim process creates its <path>.rw coordination tree. User interaction is not required. The attack cannot be launched over the network and does not yield code execution or data disclosure on its own.

text
# Patch excerpt from docs/changelog/842.bugfix.rst
:class:`~filelock.SoftReadWriteLock` reaches its records through descriptors of ``<path>.rw`` and ``gen`` or ``holders``
opened without following symlinks. On Windows it holds those directories open and refuses a junction (a directory that
points at another directory). A tree swapped in after an earlier acquire therefore cannot redirect them. Its heartbeat
rewrites a holder record only when the name still leads to the file it created, and does not block on a FIFO (a named
pipe). A heartbeat that finds ``<path>.rw`` replaced by a symlink or junction reports the hold lost instead of ending
the heartbeat thread. A live lock object repeats the ownership check whenever the tree it opens is not the one it
prepared.

Source: tox-dev/filelock commit bfa066d

Detection Methods for CVE-2026-112941

Indicators of Compromise

  • Unexpected symlinks or junctions replacing <path>.rw, <path>.rw/gen, or <path>.rw/holders directories created by filelock
  • Lock-record files appearing in directories owned by a different user than the application process
  • Heartbeat threads reporting the hold as lost without a legitimate release event
  • Lock-coordination directories whose inode or ownership differs from the directory originally created at acquisition time

Detection Strategies

  • Inventory Python environments for installed filelock versions and flag any instance between 4.1.0 and 4.2.0 inclusive
  • Audit filesystem permissions on parent directories where applications instantiate SoftReadWriteLock or AsyncSoftReadWriteLock
  • Enable file integrity monitoring on known <path>.rw lock paths used by production services

Monitoring Recommendations

  • Alert on symlink or junction creation events targeting .rw lock directories under service-owned paths
  • Log and review process-level file open events using tools such as auditd or Sysmon for the lock paths
  • Track application logs for filelock heartbeat warnings that indicate a lost hold or sentinel mismatch

How to Mitigate CVE-2026-112941

Immediate Actions Required

  • Upgrade filelock to version 4.2.1 or later across all Python environments
  • Audit shared or world-writable directories used by applications holding SoftReadWriteLock instances and tighten permissions
  • Ensure lock paths are placed inside directories writable only by the service account that owns the lock

Patch Information

The fix is included in filelock 4.2.1, released by the tox-dev project. The remediation holds <path>.rw, gen, and holders through descriptors opened without following symlinks, refuses Windows junctions, and re-validates ownership whenever the opened tree differs from the one originally prepared. See the GitHub Security Advisory GHSA-wfhq-q4j2-c37m, pull request #842, and the v4.2.1 release notes.

Workarounds

  • Place lock files inside directories owned exclusively by the service user with mode 0700 to prevent replacement attacks
  • Avoid using SoftReadWriteLock under shared sticky directories such as /tmp until upgraded
  • Replace SoftReadWriteLock with an OS-level file lock implementation in environments where multiple local users share the filesystem
bash
# Upgrade filelock to the patched release
pip install --upgrade 'filelock>=4.2.1'

# Verify installed version
python -c "import filelock; print(filelock.__version__)"

# Restrict lock directory ownership and permissions
install -d -m 0700 -o appuser -g appuser /var/lib/myapp/locks

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

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.