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

> Local attackers can exploit a TOCTOU race condition to corrupt or truncate arbitrary files via symlink attacks during lock file creation.

- **Severity:** Medium 6.3 (`CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 16 Dec 2025
- **Updated:** 17 Dec 2025
- **Also known as:** AZL-72739, AZL-79232, BELL-CVE-2025-68146, CLEANSTART-2026-PE38920, DEBIAN-CVE-2025-68146, ECHO-d3c5-64d2-c403, GHSA-w853-jp5j-5j7f, MINI-26cm-36mw-fwf4, MINI-2qxc-6647-jh58, MINI-7j94-rcmf-27r7, MINI-9xh9-7mfr-rpf9, MINI-gr58-6cfc-g6c8, MINI-j6gg-363m-c3x3, OESA-2026-3143, PYSEC-2026-1375, ROOT-APP-PYPI-CVE-2025-68146, SUSE-SU-2026:0082-1, UBUNTU-CVE-2025-68146, openSUSE-SU-2026:10010-1

## What is CVE-2025-68146?

CVE-2025-68146 is a medium-severity vulnerability in tox-dev filelock, published on 16 Dec 2025. It can only be exploited from the same machine or local network, with no action from the victim.

### Official 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.

Weakness: CWE-59 (Improper Link Resolution Before File Access), CWE-367 (Time-of-check Time-of-use (TOCTOU) Race Condition), CWE-362 (Concurrent Execution using Shared Resource with Improper Synchronization)

## Which versions are affected by CVE-2025-68146?

3 open source packages ship an affected version, including filelock. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `filelock` | PyPI | All versions | 3.20.1 |
| `filelock` | PyPI | All versions | 3.20.1 |
| `filelock` | PyPI | All versions | 3.20.1 |
| `python-filelock` | SUSE:Linux Enterprise Module for Development Tools 15 SP7 | All versions | 3.0.12-150100.3.6.1 |
| `python-filelock` | SUSE:Linux Enterprise Module for Package Hub 15 SP7 | All versions | 3.0.12-150100.3.6.1 |
| `python-filelock` | openSUSE:Tumbleweed | All versions | 3.20.2-1.1 |

Products: Tox-Dev Filelock.

## How do I fix CVE-2025-68146?

Upgrade filelock to 3.20.1 or later.

## Is CVE-2025-68146 being exploited?

There is no known exploitation of CVE-2025-68146 in the wild and no public exploit code.

## Other vulnerabilities in tox-dev filelock

- [CVE-2026-112940](https://insights.sbomify.com/CVE-2026-112940/): filelock ReadWriteLock: SQLite reopens the lock database by name, so a planted symlink or journal file makes the lock user's process overwrite or unlink its own files (high 7.1)
- [CVE-2026-112911](https://insights.sbomify.com/CVE-2026-112911/): filelock: StrictSoftFileLock and SoftReadWriteLock adopt a protocol directory another user created first, losing mutual exclusion (medium 6.3)
- [CVE-2026-112909](https://insights.sbomify.com/CVE-2026-112909/): filelock: UnixFileLock truncates and chmods any regular file another user renames or hard-links onto the lock path (medium 6.1)
- [CVE-2026-112934](https://insights.sbomify.com/CVE-2026-112934/): filelock: SoftReadWriteLock holder refresh writes through a hard link and hangs on a named pipe that another local user renames over its record (medium 6.1)
- [CVE-2026-112936](https://insights.sbomify.com/CVE-2026-112936/): filelock: ReadWriteLock follows a symlink at the lock path into SQLite (medium 6.1)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-68146 and fix it if it is affected.

What it is: CVE-2025-68146 is a medium-severity vulnerability in tox-dev filelock, published on 16 Dec 2025. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2025-68146 in the wild and no public exploit code.

Affected packages and fixed versions:
- filelock (PyPI): affected all versions; fixed in 3.20.1
- filelock (PyPI): affected all versions; fixed in 3.20.1
- filelock (PyPI): affected all versions; fixed in 3.20.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2025-68146/ (Markdown: https://insights.sbomify.com/CVE-2025-68146/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2025-68146
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-68146
- OSV: https://osv.dev/vulnerability/CVE-2025-68146

---
From sbomify Insights: https://insights.sbomify.com/CVE-2025-68146/
Summaries are generated and may contain mistakes; the official description above is the record.
