Dec 5, 2026·10 min read·1 visit
Unbounded synchronous directory enumeration in Python filelock (< 4.3.0) allows local unprivileged users to cause thread blocking and asyncio event-loop starvation by creating excessive .filelock-* directories inside shared parent paths.
CVE-2026-144338 is a local denial-of-service vulnerability affecting the Python filelock library prior to version 4.3.0. On POSIX systems, when ReadWriteLock or AsyncReadWriteLock operates within a shared parent directory, an unprivileged local user can flood the directory with entries matching the .filelock-* prefix. Because connection initialization executes an unbounded synchronous directory sweep before evaluating user-supplied lock timeouts, this flooding stalls calling threads and starves the asyncio event loop.
The Python filelock library provides a platform-independent file locking mechanism used across Python tooling and multi-process applications. In addition to standard advisory file locks, the library implements ReadWriteLock and AsyncReadWriteLock, which rely on an underlying SQLite database file to coordinate shared read and exclusive write states across processes.
When SQLite operates on a database file, it generates auxiliary side files in the same directory, specifically -journal, -wal (Write-Ahead Logging), and -shm (Shared Memory) files. On POSIX platforms, if the database resides in a multi-tenant or world-writable parent directory such as /tmp, an untrusted local user could plant symbolic links or tamper with these auxiliary files. To mitigate this risk, filelock isolates SQLite operations by creating a private subdirectory (mode 0700) prefixed with .filelock- inside the parent directory and placing a hard link to the target lock database inside that private subdirectory.
Because processes holding locks can terminate abnormally via signals such as SIGKILL without running cleanup handlers, filelock incorporates a garbage collection routine during connection initialization to prune abandoned .filelock-* subdirectories and stale hard links. This vulnerability, classified under CWE-770 (Allocation of Resources Without Limits or Throttling), stems from the unbounded and synchronous execution of this cleanup sweep.
Prior to version 4.3.0, an unprivileged local user with write access to the shared parent directory can populate the directory with thousands of dummy .filelock-* subdirectories. When a victim process attempts to acquire a read-write lock, the synchronous sweep iterates through every matching entry before honoring the caller's timeout parameter. In asynchronous applications using AsyncReadWriteLock, this blocking filesystem traversal executes directly on the main asyncio event loop thread, stalling all concurrent coroutines in the process.
The root cause resides in the _sweep_links_of_the_dead function, which is invoked by _link_beside() whenever a new SQLite connection is initialized for a database residing in a shared directory. The cleanup logic was designed to execute once per unique database identity (_DatabaseIdentity) within a process lifecycle, tracked via the in-memory set _SWEPT_DATABASES.
When _sweep_links_of_the_dead runs, it opens a directory iterator over the parent path using os.scandir(parent) and constructs a list of all directory names starting with _LINK_PREFIX (.filelock-). Immediately afterward, it iterates over the entire collected list and calls _remove_dead_links(parent / name, identity, owner) on each candidate path. Each call performs multiple synchronous filesystem system calls (stat, directory listing, and potentially unlink and rmdir).
Two architectural defects compound this behavior into a denial-of-service vector. First, the directory sweep executes synchronously prior to SQLite connection setup and outside the scope of the lock acquisition timer. Even if an application explicitly specifies a strict non-blocking or short-duration timeout such as lock.write_lock(timeout=0.05), the sweep must finish examining every .filelock-* entry in the parent directory before the timeout logic is reached.
Second, AsyncReadWriteLock delegates its database connection initialization to the same synchronous construction path on the asyncio event loop thread rather than offloading the filesystem I/O to a background thread pool executor. In ADDITION, if a process creates non-singleton lock instances (is_singleton=False) or interacts with modified database identities, or if multiple processes start concurrently against a flooded directory, the synchronous traversal delay is incurred repeatedly.
In versions prior to 4.3.0, the dead-link sweep was implemented as a stateless function backed only by a simple set _SWEPT_DATABASES to record visited database identities. Below is the vulnerable implementation prior to commit d7324f591a2532e28427dae342d73680cc4cf6e7:
def _sweep_links_of_the_dead(parent: pathlib.Path, identity: _DatabaseIdentity, owner: int):
if identity in _SWEPT_DATABASES:
return
_SWEPT_DATABASES.add(identity)
try:
# VULNERABLE: Collects all matching entries in memory in a single synchronous pass
with os.scandir(parent) as entries:
names = [
entry.name
for entry in entries
if entry.name.startswith(_LINK_PREFIX) and entry.is_dir(follow_symlinks=False)
]
except OSError:
return
# VULNERABLE: Unbounded loop executing stat/rmdir syscalls without checking elapsed time
for name in names:
with suppress(OSError):
_remove_dead_links(parent / name, identity, owner)Commit d7324f591a2532e28427dae342d73680cc4cf6e7 replaces _SWEPT_DATABASES and _sweep_links_of_the_dead with a stateful coordinator class named _LinkSweeps. This class enforces a strict time slice budget, rate limiting, non-blocking concurrency, and bounded descriptor caches:
_MAX_REMEMBERED_SWEEPS: Final[int] = 1024
_MAX_PENDING_SWEEPS: Final[int] = 16
_SweepKey: TypeAlias = tuple[pathlib.Path, int, int, _DatabaseIdentity, int]
class _LinkSweeps:
def __init__(self) -> None:
self._gate = threading.Lock()
self._retry_at: collections.OrderedDict[_SweepKey, float] = collections.OrderedDict()
self._pending: collections.OrderedDict[_SweepKey, Generator[None]] = collections.OrderedDict()
def sweep(self, parent: pathlib.Path, identity: _DatabaseIdentity, owner: int) -> None:
# FIX 1: Non-blocking lock acquisition prevents thread pile-up during sweeps
if not self._gate.acquire(blocking=False):
return
try:
with suppress(OSError):
directory = parent.stat()
self._advance((parent, directory.st_dev, directory.st_ino, identity, owner))
finally:
self._gate.release()
def _advance(self, key: _SweepKey) -> None:
now = time.monotonic()
# FIX 2: Enforce 60-second cooldown on incomplete sweeps and permanent skip on finished sweeps
if key in self._retry_at:
self._retry_at.move_to_end(key)
if now < self._retry_at[key]:
return
elif len(self._retry_at) == _MAX_REMEMBERED_SWEEPS:
oldest, _ = self._retry_at.popitem(last=False)
with suppress(KeyError):
self._pending.pop(oldest).close()
parent, _, _, identity, owner = key
# FIX 3: Resume paused generator or start a new lazy generator scan
scan = self._pending.pop(key, None) or self._scan(parent, identity, owner)
self._retry_at[key] = now + 60
try:
for _ in scan:
# FIX 4: Bound execution to _MAX_TRANSITION_WAIT (50 ms)
if time.monotonic() >= now + _MAX_TRANSITION_WAIT:
self._pending[key] = scan
# FIX 5: Cap open os.scandir generators at 16 to prevent EMFILE exhaustion
if len(self._pending) > _MAX_PENDING_SWEEPS:
self._pending.popitem(last=False)[1].close()
return
self._retry_at[key] = float("inf")
finally:
if key not in self._pending:
scan.close()
@staticmethod
def _scan(parent: pathlib.Path, identity: _DatabaseIdentity, owner: int) -> Generator[None]:
with suppress(OSError), os.scandir(parent) as entries:
for entry in entries:
with suppress(OSError):
if entry.name.startswith(_LINK_PREFIX) and entry.is_dir(follow_symlinks=False):
_remove_dead_links(parent / entry.name, identity, owner)
yield> [!NOTE]
> Fix Completeness Assessment: The patch comprehensively addresses both CPU/I/O time exhaustion and secondary resource exhaustion vectors. Because pausing a generator running inside a with os.scandir(parent) block keeps the underlying OS directory file descriptor open, an attacker rotating across multiple directories could have triggered file descriptor exhaustion (EMFILE). The patch mitigates this by capping self._pending at _MAX_PENDING_SWEEPS = 16 and explicitly invoking .close() on evicted generators, as well as registering a fork handler (register_fork_object) to close inherited generators after os.fork().
Exploiting CVE-2026-144338 requires local command execution or filesystem write access as an unprivileged user on a POSIX system where a target application stores its ReadWriteLock or AsyncReadWriteLock file inside a shared directory (such as /tmp, /var/tmp, or a group-writable directory). No elevated privileges or specific race window timings are required.
To trigger the condition, the local attacker creates a large volume of subdirectories inside the shared parent directory that match the _LINK_PREFIX naming convention (.filelock-*). Because _sweep_links_of_the_dead inspects every directory starting with .filelock- before checking whether the contents match the target database's device and inode identity, empty or arbitrary dummy directories force filelock to execute directory opens and stat lookups for every entry.
The following proof-of-concept demonstrates the timeout bypass and thread delay in affected versions (< 4.3.0), derived from the verification suite introduced in tests/test_read_write_private_link.py:
import time
from pathlib import Path
from filelock import ReadWriteLock
# 1. Setup a shared directory representing /tmp or a multi-tenant workspace
shared_dir = Path("/tmp/shared_lock_workspace")
shared_dir.mkdir(parents=True, exist_ok=True)
shared_dir.chmod(0o777)
# 2. Unprivileged attacker floods the shared directory with matching prefixes
for i in range(50000):
dummy_dir = shared_dir / f".filelock-flood-{i}"
dummy_dir.mkdir(exist_ok=True)
# 3. Victim application attempts to acquire an uncontended lock with a 50ms timeout
lock_file = shared_dir / "service.db.lock"
start_time = time.monotonic()
with ReadWriteLock(lock_file, is_singleton=False).write_lock(timeout=0.05):
pass
elapsed_time = time.monotonic() - start_time
print(f"Requested timeout: 0.05s | Actual blocking duration: {elapsed_time:.4f}s")On versions prior to 4.3.0, acquiring the completely uncontended lock with a 50-millisecond timeout blocks the calling thread for several seconds while iterating over the 50,000 entries. When invoked via AsyncReadWriteLock, the entire asyncio event loop freezes for the duration of the filesystem sweep, preventing the process from servicing network sockets, health check endpoints, or concurrent tasks. On patched versions (>= 4.3.0), the sweep pauses immediately after the 50-millisecond budget (_MAX_TRANSITION_WAIT) expires and defers further cleanup for 60 seconds.
The security impact of CVE-2026-144338 is restricted to local availability degradation, reflected by its CVSS v3.1 base score of 3.3 (Low) with vector CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L. The vulnerability does not permit privilege escalation, unauthorized lock bypass, memory corruption, or disclosure of sensitive information.
In synchronous multi-process Python applications (such as worker pools, CLI build tools like tox or virtualenv, and CGI/WSGI workers), the impact manifests as startup latency spikes and violation of strict execution timeouts. Processes that repeatedly spawn short-lived worker instances against a lock in /tmp incur the full traversal penalty on every new process invocation.
In asynchronous Python services built on asyncio (such as web servers or background daemons using AsyncReadWriteLock), the availability impact is amplified. Because asyncio relies on cooperative multitasking on a single operating system thread, any synchronous blocking operation exceeding a few milliseconds stalls all active coroutines. By flooding the lock's parent directory, a local attacker can induce multi-second event loop stalls whenever a new lock database identity is initialized, causing upstream health check failures or request timeouts.
From a threat intelligence perspective, the vulnerability has an EPSS score of 0.00277 (21.51st percentile) and is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog. Because exploitation requires pre-existing local access to the host filesystem and only yields localized availability delays, the likelihood of widespread exploitation in the wild remains low.
The primary remediation is to upgrade the filelock package to version 4.3.0 or later. Version 4.3.0 bounds the dead-link sweep to a 50-millisecond execution window per pass, enforces a 60-second backoff before resuming incomplete sweeps, and utilizes a non-blocking mutex so concurrent threads do not stall waiting for an active sweep.
pip install --upgrade "filelock>=4.3.0"For environments where an immediate dependency upgrade cannot be deployed, operators and developers can eliminate the vulnerable code path through filesystem configuration:
/tmp or /var/tmp into dedicated application-owned directories with permissions set to 0700 (for example, /run/my-app/locks/). When filelock detects that the parent directory is owned exclusively by the effective UID and is not writable by group or others, it bypasses the private hard-link isolation mechanism (_link_beside) and the associated .filelock-* directory sweep entirely.chmod 1777) and apply filesystem inode quotas (usrquota) to restrict the number of directories an unprivileged local user can allocate.systemd-tmpfiles) to remove stale .filelock-* directories in shared temporary locations.CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L| Product | Affected Versions | Fixed Version |
|---|---|---|
filelock tox-dev | < 4.3.0 | 4.3.0 |
| Attribute | Detail |
|---|---|
| CVE ID | CVE-2026-144338 (GHSA-5qxg-3g64-7g62) |
| Weakness Class | CWE-770: Allocation of Resources Without Limits or Throttling |
| Attack Vector | Local Filesystem (Shared POSIX Directories) |
| CVSS v3.1 Score | 3.3 Low (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L) |
| EPSS Score | 0.28% (21.51st Percentile) |
| Impact | Local Denial of Service (Thread Blocking & Asyncio Event-Loop Starvation) |
| Exploit Status | Proof-of-Concept in Repository Test Suite |
| Patched Version | filelock 4.3.0 |
The software allocates a resource (CPU execution time, filesystem I/O, and directory stream descriptors during directory sweeps) without setting limits or throttling mechanisms, allowing an actor to consume excessive resources and bypass user-configured execution timeouts.
CVE-2026-144342 (GHSA-jcqr-c9r9-vgjh) is an uncontrolled resource consumption vulnerability in the Python filelock package affecting Windows environments. When applications utilize the StrictSoftFileLock locking protocol in directories shared across multiple local accounts, a low-privileged user with read-only access can exploit Windows NTFS opportunistic locking (oplock) semantics on aged, abandoned private claim records. By holding an unacknowledged read oplock on a stale temporary file, an attacker forces subsequent lock claimants attempting to unlink the record during directory reclamation scans into an indefinite kernel-level I/O wait, bypassing configured acquisition timeout limits.
CVE-2026-145370 (GHSA-7vw6-2xxx-fch6) is a resource allocation vulnerability in the Istio control plane (istiod). Prior to versions 1.30.9, 1.31.5, and 1.32.1, the JWKS resolver routine getRemoteContentWithRetry used an unbounded io.ReadAll call to retrieve remote JWKS and OpenID discovery documents. An authenticated Kubernetes user with permissions to create or modify a RequestAuthentication custom resource can specify an endpoint that returns an arbitrarily large or infinite stream, exhausting control-plane memory and placing istiod into a persistent CrashLoopBackOff state.
A cross-namespace isolation bypass vulnerability exists in the Istio control plane (istiod) affecting versions 1.30.0 through 1.30.8, 1.31.0 through 1.31.4, and 1.32.0. The strict gateway merging protection mechanism relies solely on user-modifiable Kubernetes resource annotations to identify internal configurations synthesized by the Kubernetes Gateway API controller. Because the admission validation webhook fails to block unprivileged users from specifying the internal.istio.io/gateway-semantics and internal.istio.io/service-account-name annotations on Istio Gateway custom resources, an attacker with permissions to create or update Gateway objects in a single tenant namespace can bypass namespace isolation. This allows the attacker to merge arbitrary listeners and host definitions into managed Gateway API proxy workloads operating in foreign namespaces.
CVE-2026-145372 is a denial of service vulnerability affecting the Istio service mesh control plane (istiod) across the 1.30.x, 1.31.x, and 1.32.x branches. When Kubernetes Gateway API support is explicitly disabled via the PILOT_ENABLE_GATEWAY_API=false flag, two distinct code paths in Pilot invoke methods on the uninitialized GatewayAPIController structure without checking for a nil receiver. An authenticated Kubernetes user with standard namespace-scoped permissions can trigger an unhandled Go runtime panic by applying the gateway.networking.k8s.io/gateway-name label to a sidecar-injected pod or creating an Istio Gateway custom resource containing a cross-namespace TLS secret reference. Because istiod continuously reconciles cluster state upon restart, the control plane enters a persistent CrashLoopBackOff state, halting mesh-wide xDS configuration distribution, mTLS certificate rotation, and admission webhook operations.
CVE-2026-145368 (GHSA-r567-vfff-9c27) is a NULL pointer dereference vulnerability (CWE-476) in the Istio service mesh control plane daemon (istiod). When an xDS client transmits a configuration rejection (NACK) containing an error_detail field for a resource type URL to which the gRPC stream was never subscribed, istiod invokes an internal resource update closure with a nil WatchedResource pointer. Both State-of-the-World (SotW) and Delta Aggregated Discovery Service (ADS) implementations unconditionally dereference this pointer, triggering an unhandled Go runtime panic that terminates the istiod process.
CVE-2026-145371 (GHSA-g435-phf9-7g5m) is a high-severity denial-of-service vulnerability affecting the Istio service mesh control plane (istiod). The flaw resides in the waypoint inbound cluster generation logic used by Istio Ambient mode (`pilot/pkg/networking/core/cluster_waypoint.go`). When an authenticated user with namespace-scoped permissions creates or modifies a `ServiceEntry` configured with `DNS` or `DNS_ROUND_ROBIN` resolution that resolves to zero endpoints, the internal `buildCluster` method returns a `nil` pointer. The calling function `buildWaypointInboundVIPCluster` fails to check for `nil` before dereferencing the returned structure, resulting in an unhandled runtime panic that terminates `istiod` and puts the entire mesh control plane into a continuous crash loop.