CVE-2026-112936: filelock: ReadWriteLock follows a symlink at the lock path into SQLite
The Python package filelock, versions 3.20.4 through 4.0.8, follows a symlink at the lock path in ReadWriteLock and AsyncReadWriteLock. A local user who can create files in the lock's directory can make a victim process create files it owns elsewhere, lock another application's SQLite database, or break mutual exclusion. Upgrade to 4.0.9.
Published Oct 28, 2026 · Analysis Nov 1, 2026
What an attacker can do
ReadWriteLock.__init__ stores pathlib.Path(lock_file).resolve(), which follows a final symlink. Every connection then opens that path through sqlite3.connect() with no O_NOFOLLOW and no regular-file check. SQLite's VFS resolves the symlink in user space, so the kernel never sees a link to refuse. That means fs.protected_symlinks and the sticky bit on /tmp do not protect you. FileLock (opens with O_NOFOLLOW) and SoftReadWriteLock are not affected.
The attacker needs local access and write access to the lock directory, such as /tmp or a shared cache. In the proof of concept, a symlink from /shared/app.rwlock.db to a path in the victim's private directory makes the victim's process create an empty file there, in a directory the attacker cannot write. Repointing a link between two victim processes lets both hold the write lock at once, which can corrupt whatever the lock protects. A link to another application's database makes that application report database is locked. The flaw reproduces on Linux, macOS and Windows 11.
Who is affected
filelock from 3.20.4 up to and including 4.0.8, only when code uses ReadWriteLock or AsyncReadWriteLock. Code that uses only FileLock or SoftReadWriteLock is not affected. Risk applies where the lock file sits in a directory other users can write to. Check your installed version:
pip show filelockAlso look for filelock pinned in lock files and in tools that vendor it.
filelock
- Ecosystem
- PyPI
- Affected
- >= 3.20.4, <= 4.0.8
- Fixed in
- 4.0.9
- Check
pip show filelock
How to fix it
Upgrade to filelock 4.0.9, which rejects a symlink at the database path instead of following it.
pip install --upgrade "filelock>=4.0.9"The advisory's workaround: keep ReadWriteLock paths in directories that only trusted users can write.
How to tell if you were hit
Search lock directories for symlinks at the paths your code passes to ReadWriteLock:
find /tmp /shared -maxdepth 2 -type l -name "*.db"Adjust the directories to your lock locations. Look for unexpected empty files owned by the service account in private directories, for other applications reporting database is locked, and for resource corruption that suggests two processes held the write lock at once. Grep your code for ReadWriteLock and AsyncReadWriteLock to see exposure.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Summary
ReadWriteLock and AsyncReadWriteLock resolve the lock path with pathlib.Path.resolve() and pass it to sqlite3.connect() without refusing a symlink. A local user who can create names in the lock's directory, such as /tmp or a shared cache, can plant a symlink at the lock path and make the victim's process create, lock, or write the file it points to, or break mutual exclusion between the victim's own processes.
Details
ReadWriteLock.__init__ stores pathlib.Path(lock_file).resolve(), which follows a final symlink, and every connection opens that path through sqlite3.connect() with no O_NOFOLLOW or regular-file check. SQLite's own VFS also resolves the final symlink in user space, so fs.protected_symlinks and the sticky bit do not help: the kernel never sees a symlink to refuse. The other lock classes do not follow a final symlink: FileLock opens with O_NOFOLLOW, and SoftReadWriteLock coordinates through <path>.rw/.
Proof of concept
On Linux, with the victim and attacker as different users and /shared mode 1777 with fs.protected_symlinks=1:
- The attacker runs
ln -s /home/victim/private/pwned.flag /shared/app.rwlock.db. - The victim constructs
ReadWriteLock("/shared/app.rwlock.db"). A plainos.open(..., O_NOFOLLOW)on the same path fails, but the lock creates/home/victim/private/pwned.flag, owned by the victim, inside a directory the attacker cannot write. - With
/shared/cache.rwlock.db -> /shared/a.db, one victim process holds the write lock. The attacker repoints the link to/shared/b.db, and a second victim process acquires the write lock while the first still holds it.
The same behavior reproduces on macOS, on Windows 11, and through AsyncReadWriteLock.
Impact
A local attacker with write access to the lock directory can make the victim create empty files it owns at paths the attacker cannot write, make the victim hold a SQLite lock on another application's database so that application gets database is locked, and give two victim processes the write lock at once, letting them corrupt the resource the lock protects.
Workarounds
Keep ReadWriteLock paths in directories that only trusted users can write.
Credited to Kwstubbs.
Questions
- Is FileLock affected by this filelock advisory?
No. The advisory says FileLock opens with O_NOFOLLOW and SoftReadWriteLock coordinates through a .rw directory. Only ReadWriteLock and AsyncReadWriteLock follow the symlink.
- Does fs.protected_symlinks stop this?
No. SQLite resolves the final symlink in user space, so the kernel never sees a link to refuse. The proof of concept works with protected_symlinks set to 1.
- Can this be exploited remotely?
No. The CVSS vector is local, and the attacker needs to create names in the lock directory, such as a shared /tmp. The sources do not report exploitation in the wild.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More PyPI vulnerabilities
All PyPI entriesCVE-2026-112908
filelock: StrictSoftFileLock creates its claim directories without the lock mode, so another local user with a write bit on them can end a live hold
medium5.3Oct 28, 2026CVE-2026-112909
filelock: UnixFileLock truncates and chmods any regular file another user renames or hard-links onto the lock path
medium6.1Oct 28, 2026CVE-2026-112910
filelock: WindowsFileLock ignores mode: a 0o600 lock file and the ReadWriteLock database inherit the directory ACL
medium5.3Oct 28, 2026CVE-2026-112911
filelock: StrictSoftFileLock and SoftReadWriteLock adopt a protocol directory another user created first, losing mutual exclusion
medium6.3Oct 28, 2026CVE-2026-112912
filelock: Symlink swap during SoftFileLock's writability check leaks whether a path exists and is writable by the lock taker
low2.5Oct 28, 2026CVE-2026-112915
filelock ReadWriteLock: a crafted lock database makes every acquire stall or hang regardless of timeout
medium5.5Oct 28, 2026
