filelock is vulnerable to Race Condition (TOCTOU)
59
Medium Risk
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.
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.
filelock is vulnerable to Race Condition (TOCTOU) in versions 0.2.0 - 3.29.7.
Upgrade the filelock library to the patch version.
Connect your repositories to instantly see whether vulnerable or malicious packages exist in your codebase.
Free. No credit card required.

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.