VAITP Dataset

← Back to the dataset

CVE-2026-112941

Cache bypass lets local user replace lock tree, redirecting writes to writable dirs.

  • CVSS 3.3
  • CWE-367
  • Race Conditions
  • Local

filelock is a platform-independent file lock for Python. From 4.1.0 until 4.2.1, SoftReadWriteLock and AsyncSoftReadWriteLock cache a successful check of the <path>.rw lock tree and resolve its names again during later record operations, allowing another local user who can replace that tree after the first acquisition to redirect lock-record writes into directories writable by the lock user. This issue is fixed in version 4.2.1.

CVSS base score
3.3
Published
2026-10-20
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Checking
Code defect classification
Incorrect Check
Category
Race Conditions
Subcategory
Time-of-Check to Time-of-Use
Accessibility scope
Local
Impact
Unauthorized Access
Affected component
filelock
Fixed by upgrading
Yes

Solution

Upgrade filelock to version 4.2.1 or later.

Vulnerable code sample

import os
from filelock import SoftReadWriteLock

def process_file(base_path: str, payload: str) -> None:
    lock_path = os.path.join(base_path, "resource")
    # VULNERABLE: reuse cached lock path after first acquisition
    lock = SoftReadWriteLock(lock_path)

    # First operation: read under lock
    lock.acquire()
    with open(lock_path, "r") as f:
        _ = f.read()
    lock.release()

    # Some unrelated work that could let an attacker replace the lock tree
    do_something_else()

    # Second operation: write under the same lock object (still using cached path)
    lock.acquire()
    with open(lock_path, "a") as f:
        f.write(payload)
    lock.release()

def do_something_else():
    pass

Patched code sample

import os
from filelock import SoftReadWriteLock

def process_file(base_path: str, payload: str) -> None:
    lock_path = os.path.join(base_path, "resource")
    # FIX: create a fresh lock for each critical section to avoid cached path reuse
    # First operation: read under lock
    read_lock = SoftReadWriteLock(lock_path)
    read_lock.acquire()
    with open(lock_path, "r") as f:
        _ = f.read()
    read_lock.release()

    do_something_else()

    # Second operation: write under a new lock instance
    write_lock = SoftReadWriteLock(lock_path)
    write_lock.acquire()
    with open(lock_path, "a") as f:
        f.write(payload)
    write_lock.release()

def do_something_else():
    pass

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(strict): keep claim directories private to the lock (#839) (tox-dev/filelock)
    src/filelock/_lease.py, src/filelock/_soft_rw/_protocol.py, src/filelock/_soft_rw/_protocol.py · Files.create, src/filelock/_soft_rw/_protocol.py · Files.overwrite, src/filelock/_soft_rw/_protocol.py · GenerationLog.commit, src/filelock/_soft_rw/_protocol.py · GenerationLog._extends_the_log, src/filelock/_soft_rw/_protocol.py · GenerationLog._list, src/filelock/_soft_rw/_protocol.py · Ledger.observe, src/filelock/_soft_rw/_protocol.py · Participant.heartbeat, src/filelock/_soft_rw/_protocol.py · Participant.leave, src/filelock/_soft_rw/_protocol.py · Participant._create_holder, src/filelock/_soft_rw/_protocol.py · Participant._refresh_nonce and 44 more

Cite this entry

@misc{vaitp:cve2026112941,
  title        = {{Cache bypass lets local user replace lock tree, redirecting writes to writable dirs.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-112941},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-112941/}}
}

Download this entry as JSON Download the whole dataset

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 ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.