PyPI: filelock
CVE-2026-112941
Safety vulnerability ID: SFTY-20261020-53058
Affected versions of the `filelock` package are vulnerable to Time-of-check Time-of-use (TOCTOU) Race Condition due to caching a successful check of the lock tree and resolving its names again later. `SoftReadWriteLock` and `AsyncSoftReadWriteLock` validate the `<path>.rw` lock tree once and then resolve its names again during later record operations without repeating the check. A local attacker who can replace that tree after the first acquisition can redirect lock record writes into any directory the lock user can write to.
Overview
filelock: SoftReadWriteLock follows a lock tree swapped in after its first acquire and writes lock records into directories of the user running the lock
Advisory
filelock – Time-of-check Time-of-use (TOCTOU) Race Condition
How to Fix
Mitigation and Workarounds
---
Vulnerable Functions
Functions linked to known vulnerabilities.
References
- https://getsafety.com/vulnerabilities/SFTY-20261020-53058/CVE-2026-112941
- https://github.com/tox-dev/filelock/security/advisories/GHSA-wfhq-q4j2-c37m
- https://nvd.nist.gov/vuln/detail/CVE-2026-112941
- https://github.com/tox-dev/filelock/pull/842
- https://github.com/tox-dev/filelock/commit/bfa066d65a1ba9106f86ee9d027f7588b9c77e03
- https://github.com/tox-dev/filelock/releases/tag/4.2.1
- https://github.com/advisories/GHSA-wfhq-q4j2-c37m
Verified by Safety
Our Cybersecurity Intelligence Team reviewed this vulnerability. We combine public data with our own research to find issues not yet reported to public sources.
Learn more
