Skip to content
OpenAdvisories

Description

filelock is a platform-independent file lock for Python. In versions prior to 3.20.1, a Time-of-Check-Time-of-Use (TOCTOU) race condition allows local attackers to corrupt or truncate arbitrary user files through symlink attacks. The vulnerability exists in both Unix and Windows lock file creation where filelock checks if a file exists before opening it with O_TRUNC. An attacker can create a symlink pointing to a victim file in the time gap between the check and open, causing os.open() to follow the symlink and truncate the target file. All users of filelock on Unix, Linux, macOS, and Windows systems are impacted. The vulnerability cascades to dependent libraries. The attack requires local filesystem access and ability to create symlinks (standard user permissions on Unix; Developer Mode on Windows 10+). Exploitation succeeds within 1-3 attempts when lock file paths are predictable. The issue is fixed in version 3.20.1. If immediate upgrade is not possible, use SoftFileLock instead of UnixFileLock/WindowsFileLock (note: different locking semantics, may not be suitable for all use cases); ensure lock file directories have restrictive permissions (chmod 0700) to prevent untrusted users from creating symlinks; and/or monitor lock file directories for suspicious symlinks before running trusted applications. These workarounds provide only partial mitigation. The race condition remains exploitable. Upgrading to version 3.20.1 is strongly recommended.

Affected products

VendorProductAffectedFixed
tox-dev filelock < 3.20.1 —

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
Debian 14 python-filelock 3.20.2-1 —
Debian 13 python-filelock 3.18.0-1+deb13u1 —
Debian 12 python-filelock 3.9.0-1+deb12u1 —
ReleasePackageFixed inAdvisory
Ubuntu 26.10 python-filelock No fix yet —
Ubuntu 25.10 python-filelock No fix yet —
Show 4 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Ubuntu Pro 24.04 LTS python-filelock 3.13.1-1ubuntu0.1~esm1 USN-7999-1
Ubuntu Pro 22.04 LTS python-filelock 3.6.0-1ubuntu0.1~esm1 USN-7999-1
Ubuntu Pro 20.04 LTS python-filelock 3.0.12-2ubuntu0.1~esm1 USN-7999-1
Ubuntu Pro 18.04 LTS python-filelock 3.0.4-1ubuntu0.1~esm1 USN-7999-1
ReleasePackageFixed inAdvisory
SLES 15 SP7 python-filelock 3.0.12-150100.3.6.1 SUSE-SU-2026:0082-1
SLES 3 python-filelock 3.12.2-150400.10.8.1 SUSE-SU-2026:0220-1
Show 2 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
SLES for SAP 16.0 python-filelock 3.18.0-160000.3.1 SUSE-SU-2026:20216-1
SLES 16.0 python-filelock 3.18.0-160000.3.1 SUSE-SU-2026:20216-1
ReleasePackageFixed inAdvisory
openSUSE Tumbleweed ansible-lint 26.11.0-2.1 openSUSE-SU-2026:12481-1
openSUSE Tumbleweed python-filelock 3.20.2-1.1 openSUSE-SU-2026:10010-1
openSUSE Tumbleweed python-virtualenv 20.36.1-1.1 openSUSE-SU-2026:10055-1
openSUSE Leap 16.0 python-filelock 3.18.0-160000.3.1 openSUSE-SU-2026:20144-1
openSUSE Leap 15.6 python-filelock 3.12.2-150400.10.8.1 SUSE-SU-2026:0220-1

Amazon Linux

ReleasePackageFixed inAdvisory
Amazon Linux 2023 python3-filelock +1 3.3.1-1.amzn2023.0.2 ALAS2023-2026-1415
Amazon Linux 2023 python3.13-filelock 3.18.0-1.amzn2023.0.1 ALAS2023-2026-1411

Azure Linux

ReleasePackageFixed inAdvisory
Azure Linux 3 python-filelock 3.20.1-1 —
Azure Linux 2 (CBL-Mariner) python-filelock No fix yet —

Wolfi

ReleasePackageFixed inAdvisory
Wolfi rolling airflow-3 +3 3.1.5-r0 —
Wolfi rolling datadog-agent-7.72-core-integrations No fix yet —
Wolfi rolling kserve +9 0.16.0-r6 —
Wolfi rolling open-webui +1 0.6.41-r1 —
Wolfi rolling py3-cassandra-medusa +1 0.26.0-r2 —

Affected packages

EcosystemPackageAffectedFixedRecord
PyPI filelock < 3.20.1 3.20.1 GHSA-w853-jp5j-5j7f

Advisories 12

References