Dev.to Security 🔐 Cybersecurity 👁 2 📖 3 min read

CVE-2026-144350: CVE-2026-144350: Race Condition and Mutual Exclusion Bypass in Python filelock SoftFileLock

CVE-2026-144350: Race Condition and Mutual Exclusion Bypass in Python filelock SoftFileLock Vulnerability ID: CVE-2026-144350 CVSS Score: 3.6 Published: 2026-12-04 CVE-2026-144350 is a local race condition and insuf

CVE-2026-144350: Race Condition and Mutual Exclusion Bypass in Python filelock SoftFileLock

Vulnerability ID: CVE-2026-144350
CVSS Score: 3.6
Published: 2026-12-04

CVE-2026-144350 is a local race condition and insufficient data authenticity verification vulnerability in the Python filelock library (versions 4.2.1 prior to 4.3.0). On POSIX filesystems supporting atomic name exchange, SoftFileLock._stranded_candidates() fails to verify whether the process identifier associated with a lock-break file is currently running. Consequently, contending processes can misidentify an active recovery record as abandoned, leading to concurrent lock acquisition where two processes enter the same critical section simultaneously.

TL;DR

A flaw in Python's filelock library (4.2.1 to < 4.3.0) allows SoftFileLock on POSIX systems with atomic name exchange to misidentify active lock-break records as abandoned. If PID recycling occurs or an unprivileged local user plants markers in a shared sticky directory, racing lock recoveries can admit two processes into the same mutually exclusive critical section. Upgrading to filelock 4.3.0 resolves the issue.

⚠️ Exploit Status: POC

Technical Details

  • CVE ID: CVE-2026-144350 (GHSA-gvhc-qmqx-22pq)
  • CWE Classification: CWE-345 (Insufficient Verification of Data Authenticity)
  • CVSS v3.1 Score: 3.6 Low (CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:L)
  • EPSS Score: 0.149% (4.27th Percentile)
  • Attack Vector: Local (Shared Sticky Directory / POSIX Atomic Name Exchange)
  • Affected Component: filelock.SoftFileLock._stranded_candidates() (4.2.1 to < 4.3.0)
  • Security Impact: Mutual Exclusion Bypass (Concurrent Critical Section Entry)
  • CISA KEV Status: Not Listed

Affected Systems

  • Python filelock library (PyPI: filelock)
  • POSIX systems supporting atomic file exchange (e.g., Linux renameat2 RENAME_EXCHANGE) using SoftFileLock
  • filelock: >= 4.2.1, < 4.3.0 (Fixed in: 4.3.0)

Code Analysis

Commit: 13dae4c

On POSIX systems with atomic name exchange, SoftFileLock waits when a stale marker points to a break name whose PID still runs.

diff --git a/src/filelock/_soft.py b/src/filelock/_soft.py
index 1da37b563..cfb709c92 100644
--- a/src/filelock/_soft.py
+++ b/src/filelock/_soft.py
@@ -347,6 +347,9 @@ def _stranded_candidates(self, breaker_pid: int) -> list[tuple[str, bool]] | Non
                     continue
                 path = str(Path(directory) / entry.name)
                 if stranded.fullmatch(entry.name):
+                    # A stale marker may name a recycled PID whose current process is still breaking another marker.
+                    if 1 <= breaker_pid <= 2**31 - 1 and not owner_is_stale(breaker_pid, host_name(), None):
+                        return None
                     candidates.append((path, False))
                 elif (found := claimed.fullmatch(entry.name)) and 1 <= (recoverer := int(found[1])) <= 2**31 - 1:
                     # No filelock writes a claim outside the pid range; os.kill would raise OverflowError on one.

Exploit Details

  • GitHub: Regression test in tests/test_soft_stale.py demonstrating live breaker marker preservation and reproduction of the race state.

Mitigation Strategies

  • Upgrade the Python filelock package to version 4.3.0 or newer across all environments.
  • Replace SoftFileLock with OS-native FileLock (UnixFileLock) on POSIX systems where kernel-level flock/fcntl locking is supported.
  • Relocate lock files from shared sticky directories (such as /tmp or /var/tmp) to private directories with strict 0700 ownership permissions.

Remediation Steps:

  1. Audit application dependencies and source code to identify usage of filelock versions between 4.2.1 and 4.2.12, specifically checking for explicit instantiation of SoftFileLock.
  2. Run pip install --upgrade "filelock>=4.3.0" or update requirements.txt / pyproject.toml constraints to require filelock>=4.3.0.
  3. Verify that lock file paths used by the application reside in isolated directories accessible only to the executing service user.

References

Read the full report for CVE-2026-144350 on our website for more details including interactive diagrams and full exploit analysis.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.