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

CVE-2026-112909: Python filelock Privilege Escalation

CVE-2026-112909 is a privilege escalation vulnerability in Python filelock that allows local users to truncate files or modify permissions through UnixFileLock exploitation. This article covers technical details, affected versions, security impact, and mitigation strategies.

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

CVE-2026-112909 is a local file handling vulnerability in filelock, a platform-independent file lock library for Python. In versions prior to 4.2.1, UnixFileLock can truncate a regular file renamed onto the lock path when another local user holds rename permission or can create hard links under a permissive policy. When callers pass an explicit mode argument, affected versions from 3.10.2 onward can also change the mode of that unrelated file. The flaw maps to [CWE-706: Use of Incorrectly-Resolved Name or Reference]. The issue is fixed in filelock 4.2.1.

Critical Impact

A local attacker with rename or hard-link rights on the lock path can cause UnixFileLock to truncate arbitrary files owned by the lock user and, when an explicit mode is set, alter their permission bits.

Affected Products

  • filelock for Python, versions prior to 4.2.1 (truncation behavior)
  • filelock for Python, versions 3.10.2 through 4.2.0 (additional mode-change behavior when mode is specified)
  • Python applications using UnixFileLock on shared or multi-user Unix-like systems

Discovery Timeline

  • 2026-10-20 - CVE-2026-112909 published to NVD
  • 2026-10-22 - Last updated in NVD database

Technical Details for CVE-2026-112909

Vulnerability Analysis

The filelock package provides advisory file locks implemented through a lock file at a well-known path. On Unix, UnixFileLock opens the lock path and applies flock. The pre-patch implementation did not distinguish between a lock file it created and a file placed at the lock path by another process. When another local user renamed or hard-linked a regular file onto the lock path, the acquire routine opened that file and truncated it. The library also applied the caller-supplied mode to the inode, altering permissions on data the lock user did not create.

The practical consequence is integrity loss for files writable through the lock path. An attacker on the same host, operating under a different account with the ability to rename or hard-link files into the directory holding the lock, can destroy file contents owned by the lock-holding user whenever that user acquires the lock.

Root Cause

The root cause is incorrect name resolution during lock acquisition. UnixFileLock opened the lock path without verifying that the inode was one it had created, and it applied O_TRUNC semantics and chmod-equivalent operations to whatever regular file resolved from that path. The patch note states that UnixFileLock "no longer truncates a file it did not create" and "no longer applies mode to it," with holder-metadata writes moved to an explicit on_acquired hook.

Attack Vector

Exploitation requires local access and either rename permission on the directory containing the lock path or a permissive hard-link policy (such as fs.protected_hardlinks=0). The attacker places a target file at the lock path by rename or hard link. When the victim process calls lock.acquire(), UnixFileLock opens the path, truncates the content, and, if mode was passed to the constructor, changes the permission bits. No network interaction or user interaction is required.

text
// Patch excerpt from docs/changelog/835.bugfix.rst (filelock 4.2.1)
Fix five bugs in opening the lock file. UnixFileLock no longer truncates a file it did not create,
such as one renamed to the lock path, and no longer applies ``mode`` to it. An ``on_acquired`` hook
that writes holder metadata now truncates the file itself. [...] The soft locks' writability check
no longer follows a symlink swapped in at the lock path. On a filesystem without ``flock``, a
contender from another account now waits on a marker it cannot write instead of raising
``PermissionError``.

Source: GitHub Commit e1e825b

Detection Methods for CVE-2026-112909

Indicators of Compromise

  • Lock files at expected UnixFileLock paths that unexpectedly contain non-empty binary or text data, or whose size shrinks to zero after an acquire call.
  • Audit records showing rename or link syscalls targeting a lock path from a UID other than the lock-holding process UID.
  • Permission mode changes on files residing at lock paths that do not match the mode the application intended to set on a fresh lock file.

Detection Strategies

  • Inventory Python dependencies and flag any environment where filelock is installed at a version below 4.2.1, especially versions >=3.10.2 where the mode-change behavior is present.
  • Enable Linux audit rules on directories that host lock files to log rename, renameat, and link syscalls performed by UIDs other than service accounts expected to use those paths.
  • Review application logs for UnixFileLock acquisitions that occurred after unexpected inode or ctime changes on the lock path.

Monitoring Recommendations

  • Monitor process-level file access telemetry for cross-user activity on lock directories shared between accounts.
  • Alert on changes to fs.protected_hardlinks and fs.protected_symlinks sysctl values, since permissive values enable the hard-link variant of the attack.
  • Track Software Bill of Materials (SBOM) output across builds to surface regressions that reintroduce vulnerable filelock versions.

How to Mitigate CVE-2026-112909

Immediate Actions Required

  • Upgrade filelock to version 4.2.1 or later in all Python environments, including container images, virtual environments, and CI runners.
  • Move lock files out of world- or group-writable directories such as /tmp and /var/tmp into directories owned by the service account with mode 0700.
  • Confirm that fs.protected_hardlinks=1 and fs.protected_symlinks=1 are set on all Linux hosts running Python services that use filelock.

Patch Information

The fix is included in filelock release 4.2.1 and merged through Pull Request #835. The vendor advisory is published as GHSA-69hj-f68j-2879. After the patch, UnixFileLock opens the lock file without truncation and does not apply mode to an inode it did not create. Holder-metadata writes have been moved into a dedicated on_acquired hook that truncates its own file.

Workarounds

  • Place lock files in a directory owned by the service account with permissions 0700 so other local users cannot rename or hard-link entries into it.
  • Avoid passing an explicit mode argument to UnixFileLock until the upgrade is deployed, to limit exposure to the permission-change variant.
  • Set the Linux sysctls fs.protected_hardlinks=1 and fs.protected_symlinks=1 to block hard-link-based path substitution by unrelated users.
bash
# Upgrade filelock across Python environments
pip install --upgrade 'filelock>=4.2.1'

# Harden lock file directory
install -d -m 0700 -o appuser -g appuser /var/lib/myapp/locks

# Enforce hard-link and symlink protections at runtime and on boot
sysctl -w fs.protected_hardlinks=1
sysctl -w fs.protected_symlinks=1
cat <<'EOF' >/etc/sysctl.d/60-filelock-hardening.conf
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
EOF

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.