filelock is vulnerable to Race Condition (TOCTOU)
59
CVE Score
Medium
Race Condition (TOCTOU)
filelock's Unix backend opens the lock file with O_TRUNC and calls fchmod before it confirms exclusive access through fcntl.flock, so any process attempting to acquire the lock, including one that ultimately fails to get it, first truncates and re-permissions the file the current holder relies on. The Windows backend has a parallel timing gap: its reparse-point check runs against the lock path rather than the already-opened handle, so the path can be swapped to a symlink between the check and the open. Both gaps let a co-resident process on the same lock directory corrupt or redirect another process's lock state while that process still believes it holds exclusive access. The fix defers file mutation until after the OS lock is confirmed and binds the Windows reparse check to the opened handle.
Upgrade the filelock library to the patch version.
You are affected if you are using a version that falls within the vulnerable range and another process with write access to the same lock file or directory can run concurrently while you hold or attempt to acquire the lock.
0.2.0 - 3.29.7
Fixed in 3.30.0filelock is vulnerable to Race Condition (TOCTOU) in versions 0.2.0 - 3.29.7.
Secure your code, cloud, and runtime in one central system. Connect a repo to discover what the reasoning agents find in your codebase.
No credit card required | Scan results in 32 seconds.
I consent to receiving marketing communications based on Aikido’s Privacy Policy.
SOC 2Compliant
ISO 27001Compliant
ISO 42001Compliant© All Intel data is openly available and commercially licensed.