Intel

AIKIDO-2026-190770

filelock is vulnerable to Race Condition (TOCTOU)

Race Condition (TOCTOU) Pre-CVE
Found by Aikido Intel before public disclosure or CVE publication.
Published Sep 18, 2026

59

Medium Risk

This Affects:

PYTHONfilelock
0.2.0 - 3.29.7
Fixed in 3.30.0
Are you affected? Scan for Free

TL;DR

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.

Who does this affect?

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.

Background info

filelock is vulnerable to Race Condition (TOCTOU) in versions 0.2.0 - 3.29.7.

How to fix this

Upgrade the filelock library to the patch version.

Are You Affected?

Connect your repositories to instantly see whether vulnerable or malicious packages exist in your codebase.

Free. No credit card required.

Aikido Platform