VAITP Dataset

← Back to the dataset

CVE-2026-112909

UnixFileLock can overwrite or alter files via rename/hard‑link when permissions allow.

  • CVSS 6.1
  • CWE-706
  • Design Defects
  • Local

filelock is a platform-independent file lock for Python. Prior to 4.2.1, UnixFileLock can truncate a regular file renamed onto the lock path when another local user has actual rename permission, or hard-linked there under a permissive hard-link policy; when an explicit mode is requested, affected versions from 3.10.2 can also change that file's mode. This issue is fixed in version 4.2.1.

CVSS base score
6.1
Published
2026-10-20
OWASP
A01 Broken Access Control
Orthogonal defect classification
Assignment
Code defect classification
Incorrect Assignment
Category
Design Defects
Subcategory
Poorly Designed Access Controls
Accessibility scope
Local
Impact
Denial of Service (DoS)
Affected component
filelock
Fixed by upgrading
Yes

Solution

Upgrade the filelock package to version 4.2.1 or later.

Vulnerable code sample

import os
from filelock import UnixFileLock

def process_shared_resource(lock_path: str, data_path: str):
    # VULNERABLE: lock file may truncate an existing regular file
    lock = UnixFileLock(lock_path)
    lock.acquire()
    try:
        with open(data_path, "a") as f:
            f.write("update\n")
    finally:
        lock.release()

Patched code sample

import os
from filelock import UnixFileLock

def process_shared_resource(lock_path: str, data_path: str):
    # FIX: create lock file atomically to avoid truncating an existing file
    fd = os.open(lock_path, os.O_CREAT | os.O_EXCL, 0o600)
    os.close(fd)
    lock = UnixFileLock(lock_path)
    lock.acquire()
    try:
        with open(data_path, "a") as f:
            f.write("update\n")
    finally:
        lock.release()

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(open): keep lock files intact, honor deadlines and mode (#835) (tox-dev/filelock)
    src/filelock/_api.py · BaseFileLock.__init__, src/filelock/_descriptor.py, src/filelock/_read_write.py, src/filelock/_read_write.py · ReadWriteLock._open_connection, src/filelock/_read_write.py · _connect, src/filelock/_read_write.py · _open_lock_database, src/filelock/_soft.py, src/filelock/_soft.py · SoftFileLock._windows_unlink_if_ours, src/filelock/_soft.py · _read_lock_file, src/filelock/_strict.py, src/filelock/_unix.py, src/filelock/_util.py and 4 more

Cite this entry

@misc{vaitp:cve2026112909,
  title        = {{UnixFileLock can overwrite or alter files via rename/hard‑link when permissions allow.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-112909},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-112909/}}
}

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.