p PatchFirst

CVE-2025-68146

CVE-2025-68146 · filelock has TOCTOU race condition that allows symlink attacks during lock file creation

This page contains facts from public vulnerability sources. Check the original advisory before updating.

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.

CVSS 6.3 · Medium · EPSS 0.2% · Fix available

Published
Updated

Stack: system · python

Affected products and versions

  • filelock

    Versions
    • < 3.20.1: Affected

    No fix published

  • python-filelock Debian:12

    Versions
    • 3.9.0-1
    Affected ranges
    • ECOSYSTEM: < 3.9.0-1+deb12u1

    Update to 3.9.0-1+deb12u1

  • python-filelock Debian:13

    Versions
    • 3.18.0-1
    Affected ranges
    • ECOSYSTEM: < 3.18.0-1+deb13u1

    Update to 3.18.0-1+deb13u1

  • python-filelock Debian:14

    Versions
    • 3.18.0-1
    • 3.19.1-1
    • 3.20.0-1
    Affected ranges
    • ECOSYSTEM: < 3.20.2-1

    Update to 3.20.2-1

  • filelock PyPI

    Versions
    • 0.2.0
    • 0.2.1
    • 0.2.2
    • 1.0.0
    • 1.0.1
    • 1.0.2
    • 1.0.3
    • 2.0.0
    • 2.0.1
    • 2.0.10
    • 2.0.11
    • 2.0.12
    • 2.0.13
    • 2.0.4
    • 2.0.5
    • 2.0.6
    • 2.0.7
    • 2.0.8
    • 2.0.9
    • 3.0.0
    • 3.0.10
    • 3.0.12
    • 3.0.2
    • 3.0.3
    • 3.0.4
    • 3.0.6
    • 3.0.8
    • 3.0.9
    • 3.1.0
    • 3.10.0
    • 3.10.1
    • 3.10.2
    • 3.10.3
    • 3.10.4
    • 3.10.5
    • 3.10.6
    • 3.10.7
    • 3.11.0
    • 3.12.0
    • 3.12.1
    • 3.12.2
    • 3.12.3
    • 3.12.4
    • 3.13.0
    • 3.13.1
    • 3.13.2
    • 3.13.3
    • 3.13.4
    • 3.14.0
    • 3.15.0
    • 3.15.1
    • 3.15.2
    • 3.15.3
    • 3.15.4
    • 3.16.0
    • 3.16.1
    • 3.17.0
    • 3.18.0
    • 3.19.1
    • 3.2.0
    • 3.2.1
    • 3.20.0
    • 3.3.0
    • 3.3.1
    • 3.3.2
    • 3.4.0
    • 3.4.1
    • 3.4.2
    • 3.5.0
    • 3.5.1
    • 3.6.0
    • 3.7.0
    • 3.7.1
    • 3.8.0
    • 3.8.1
    • 3.8.2
    • 3.9.0
    • 3.9.1
    Affected ranges
    • ECOSYSTEM: < 3.20.1

    Update to 3.20.1

  • python-filelock Ubuntu:Pro:18.04:LTS

    Versions
    • 2.0.11-1
    • 2.0.12-1
    • 2.0.13-1
    • 3.0.0-2
    • 3.0.3-1
    • 3.0.4-1
    Affected ranges
    • ECOSYSTEM: < 3.0.4-1ubuntu0.1~esm1

    Update to 3.0.4-1ubuntu0.1~esm1

  • python-filelock Ubuntu:Pro:22.04:LTS

    Versions
    • 3.0.12-2
    • 3.3.2-1
    • 3.4.0-1
    • 3.4.2-1
    • 3.4.2-2
    • 3.6.0-1
    Affected ranges
    • ECOSYSTEM: < 3.6.0-1ubuntu0.1~esm1

    Update to 3.6.0-1ubuntu0.1~esm1

  • python-filelock Ubuntu:Pro:24.04:LTS

    Versions
    • 3.12.2-1
    • 3.12.4-1
    • 3.13.1-1
    Affected ranges
    • ECOSYSTEM: < 3.13.1-1ubuntu0.1~esm1

    Update to 3.13.1-1ubuntu0.1~esm1

  • python-filelock Ubuntu:25.10

    Versions
    • 3.18.0-1
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • python-filelock Ubuntu:26.10

    Versions
    • 3.20.3-1
    • 3.29.4-1
    • 3.32.0-1
    • 3.32.2-1
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

  • python-filelock Ubuntu:26.04:LTS

    Versions
    • 3.18.0-1
    • 3.20.0-1
    • 3.20.2-1
    • 3.20.3-1
    Affected ranges
    • ECOSYSTEM: (−∞, +∞)

    No fix published

Original sources

Check your server →