VAITP Dataset

← Back to the dataset

CVE-2026-112940

SQLite file lock bypass allows attackers to rename and overwrite DB files.

  • CVSS 7.1
  • CWE-59
  • Race Conditions
  • Local

filelock is a platform-independent file lock for Python. From 3.20.4 until 4.2.1, ReadWriteLock let SQLite reopen the database and side files by name; on POSIX systems an attacker with rename access in a non-sticky parent can swap those names to cause overwrite or unlink operations, while a writable adjacent hot journal is additionally required for attacker-chosen content overwrites. This issue is fixed in version 4.2.1.

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

Solution

Upgrade filelock to version 4.2.1 or later.

Vulnerable code sample

import sqlite3
from filelock import ReadWriteLock

def open_database(db_path: str):
    # VULNERABLE: uses ReadWriteLock allowing name swap attack
    lock = ReadWriteLock(f"{db_path}.lock")
    with lock.read_lock():
        conn = sqlite3.connect(db_path)
        return conn

Patched code sample

import sqlite3
from filelock import FileLock

def open_database(db_path: str):
    # FIX: exclusive FileLock prevents rename race
    lock = FileLock(f"{db_path}.lock")
    with lock:
        conn = sqlite3.connect(db_path)
        return conn

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(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.py and 2 more

Cite this entry

@misc{vaitp:cve2026112940,
  title        = {{SQLite file lock bypass allows attackers to rename and overwrite DB files.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-112940},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-112940/}}
}

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.