{"id":"CVE-2026-144405","aliases":["DEBIAN-CVE-2026-144405","EUVD-2026-143618","GHSA-386w-3w6q-9c53"],"status":"published","title":"FileLock on Unix lets two processes hold one lock after another user removes the lock file","description":"filelock is a platform-independent file lock for Python. From 3.13.2 until 4.2.12, on Unix, FileLock locks a regular file that already exists at the lock path, including one another local account created. Under a sticky directory such as /tmp that account owns the file and may remove it while a process holds the lock. The next process to acquire the lock creates and locks a new file at the same path, so two processes hold the same exclusive lock. oss-security-shopify reported this through private vulnerability reporting as GHSA-386w-3w6q-9c53, received on 17 November 2026. The affected native Unix lock is UnixFileLock, which FileLock selects where fcntl is available. Two cooperating processes run the protected section at the same time, so whatever the application guards with the lock can be written twice or left inconsistent. The attacker gains no access to that resource and no code execution. What the overlap costs depends on the application and is not established here. This issue is fixed in version 4.2.12.","severity":{"version":"3.1","score":2.5,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N","level":"low","assessor":"cna","from":"cve"},"epss":{"day":"2026-12-04","score":0.00166,"percentile":0.0613,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-667"],"published":"2026-12-03T19:23:23Z","modified":"2026-12-04T22:16:18Z","fixes":[{"ecosystem":"PyPI","package":"filelock","fixed_in":["4.2.12"],"sources":["ghsa"]},{"ecosystem":"Debian:14","package":"python-filelock","fixed_in":["4.3.1-1"],"sources":["osv"]}],"affected":[{"source":"ghsa","ecosystem":"PyPI","package":"filelock","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.13.2"},{"last_affected":"4.2.11"},{"fixed":"4.2.12"}]}]},{"source":"osv","ecosystem":"Debian:12","package":"python-filelock","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["3.12.2-1","3.12.3-1","3.12.4-1","3.13.1-1","3.13.3-1","3.13.4-1","3.14.0-1","3.15.4-1","3.16.1-1","3.16.1-2","3.17.0-1","3.18.0-1","3.19.1-1","3.20.0-1","3.20.2-1","3.20.3-1","3.24.3-1","3.25.0-1","3.25.2-1","3.29.0-1","3.29.4-1","3.29.5-1","3.29.7-1","3.32.0-1","3.32.2-1","3.32.4-1","3.32.4-2","3.32.5-1","3.32.6-1","3.9.0-1","3.9.0-1+deb12u1","4.0.1-1","4.0.12-1","4.1.1-1","4.2.10-1","4.2.8-1","4.3.1-1"]},{"source":"osv","ecosystem":"Debian:13","package":"python-filelock","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"}]}],"versions":["3.18.0-1","3.18.0-1+deb13u1","3.19.1-1","3.20.0-1","3.20.2-1","3.20.3-1","3.24.3-1","3.25.0-1","3.25.2-1","3.29.0-1","3.29.4-1","3.29.5-1","3.29.7-1","3.32.0-1","3.32.2-1","3.32.4-1","3.32.4-2","3.32.5-1","3.32.6-1","4.0.1-1","4.0.12-1","4.1.1-1","4.2.10-1","4.2.8-1","4.3.1-1"]},{"source":"osv","ecosystem":"Debian:14","package":"python-filelock","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"4.3.1-1"}]}],"versions":["3.18.0-1","3.19.1-1","3.20.0-1","3.20.2-1","3.20.3-1","3.24.3-1","3.25.0-1","3.25.2-1","3.29.0-1","3.29.4-1","3.29.5-1","3.29.7-1","3.32.0-1","3.32.2-1","3.32.4-1","3.32.4-2","3.32.5-1","3.32.6-1","4.0.1-1","4.0.12-1","4.1.1-1","4.2.10-1","4.2.8-1"]}],"products":[{"vendor":"tox-dev","product":"filelock"}],"references":[{"url":"https://github.com/tox-dev/filelock/security/advisories/GHSA-386w-3w6q-9c53","tags":["x_refsource_CONFIRM","advisory"]},{"url":"https://github.com/tox-dev/filelock/pull/968","tags":["x_refsource_MISC","fix"]},{"url":"https://github.com/tox-dev/filelock/commit/571eb998ea65c1cdd54157c70e4c592e6ac3cd04","tags":["x_refsource_MISC","fix"]},{"url":"https://github.com/tox-dev/filelock/releases/tag/4.2.12","tags":["x_refsource_MISC","web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-144405","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-386w-3w6q-9c53"},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/144xxx/CVE-2026-144405.json","tags":["advisory"]},{"url":"https://security-tracker.debian.org/tracker/CVE-2026-144405","tags":["advisory"]}],"sources":{"cve":[{"id":"CVE-2026-144405","title":"FileLock on Unix lets two processes hold one lock after another user removes the lock file","description":"filelock is a platform-independent file lock for Python. From 3.13.2 until 4.2.12, on Unix, FileLock locks a regular file that already exists at the lock path, including one another local account created. Under a sticky directory such as /tmp that account owns the file and may remove it while a process holds the lock. The next process to acquire the lock creates and locks a new file at the same path, so two processes hold the same exclusive lock. oss-security-shopify reported this through private vulnerability reporting as GHSA-386w-3w6q-9c53, received on 17 November 2026. The affected native Unix lock is UnixFileLock, which FileLock selects where fcntl is available. Two cooperating processes run the protected section at the same time, so whatever the application guards with the lock can be written twice or left inconsistent. The attacker gains no access to that resource and no code execution. What the overlap costs depends on the application and is not established here. This issue is fixed in version 4.2.12.","status":"published","published":"2026-12-03T19:23:23.407Z","modified":"2026-12-04T14:52:51.296Z","cvss":[{"version":"3.1","score":2.5,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N","level":"low","assessor":"cna"}],"cwes":["CWE-667"],"ssvc":{"exploitation":"none","automatable":"no","technical_impact":"partial","date":"2026-12-04"},"updated_at":"2026-12-04T15:00:15.26956Z"}],"euvd":[{"id":"EUVD-2026-143618","description":"filelock is a platform-independent file lock for Python. From 3.13.2 until 4.2.12, on Unix, FileLock locks a regular file that already exists at the lock path, including one another local account created. Under a sticky directory such as /tmp that account owns the file and may remove it while a process holds the lock. The next process to acquire the lock creates and locks a new file at the same path, so two processes hold the same exclusive lock. oss-security-shopify reported this through private vulnerability reporting as GHSA-386w-3w6q-9c53, received on 17 November 2026. The affected native Unix lock is UnixFileLock, which FileLock selects where fcntl is available. Two cooperating processes run the protected section at the same time, so whatever the application guards with the lock can be written twice or left inconsistent. The attacker gains no access to that resource and no code execution. What the overlap costs depends on the application and is not established here. This issue is fixed in version 4.2.12.","status":"published","published":"2026-12-03T19:23:23Z","modified":"2026-12-04T14:52:51Z","cvss":[{"version":"3.1","score":2.5,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N","level":"low"}],"updated_at":"2026-12-03T20:34:19.386759Z"}],"ghsa":[{"id":"GHSA-386w-3w6q-9c53","title":"FileLock on Unix lets two processes hold one lock after another user removes the lock file","description":"## Summary\n\nOn Unix, `FileLock` locks a regular file that already exists at the lock path, including one another local account created. Under a sticky directory such as `/tmp` that account owns the file and may remove it while a process holds the lock. The next process to acquire the lock creates and locks a new file at the same path, so two processes hold the same exclusive lock.\n\n[oss-security-shopify](https://github.com/oss-security-shopify) reported this through private vulnerability reporting as `GHSA-386w-3w6q-9c53`, received on 17 November 2026.\n\n## Affected area\n\nAcquisition of the native Unix lock, `UnixFileLock`, which `FileLock` names where `fcntl` is available.\n\n## Attacker-controlled input\n\nAnother local account must be able to create the lock file before the victim does, in a sticky directory both can write, and must know or guess the lock path. It does not need access to the resource the lock protects, and it does not need to win a race: it removes the file at any time during a hold.\n\n## Affected code\n\nIn 4.2.11, [`_open_lock_file`](https://github.com/tox-dev/filelock/blob/554c37b565dba0e0a5a92e4064cefc057a309da4/src/filelock/_unix.py#L127-L152) opens an existing file when the exclusive create fails, and [`_finalize_locked_fd`](https://github.com/tox-dev/filelock/blob/554c37b565dba0e0a5a92e4064cefc057a309da4/src/filelock/_unix.py#L178-L185) records the hold after checking only that the file still has a link.\n\n## Mechanism\n\n1. The attacker creates the lock file with mode `0666` in a sticky directory.\n2. The victim's exclusive create fails with `EEXIST`, or with `EACCES` where the kernel protects files in sticky directories ([`fs.protected_regular`](https://www.kernel.org/doc/html/latest/admin-guide/sysctl/fs.html#protected-regular)). Both paths reach `_open_existing_lock_file`, which opens the attacker's file without `O_CREAT`. [#317](https://github.com/tox-dev/filelock/pull/317) added the `EACCES` path in 3.13.2.\n3. The victim takes [`flock`](https://man7.org/linux/man-pages/man2/flock.2.html) on that file. `_finalize_locked_fd` sees `st_nlink == 1` and records the hold. Nothing compares `st_uid` with the caller's user ID.\n4. The attacker unlinks the file. The sticky bit lets a file's owner remove it ([`unlink(2)`](https://man7.org/linux/man-pages/man2/unlink.2.html), `EPERM`). The victim's `flock` stays on the unlinked inode.\n5. A second process creates a new file at the path with `O_CREAT | O_EXCL`, takes `flock` on the new inode and enters the protected section while the first is still in it.\n\nOut of scope: a lock file the caller created, which other accounts cannot remove under a sticky directory; a directory without the sticky bit that other accounts can write, where any of them can remove any file ([the directory boundary](https://py-filelock.readthedocs.io/en/latest/concepts.html#the-directory-boundary)); Windows; the soft locks, which already refuse a coordination directory of another account.\n\n## Reproduction and evidence\n\nRun on Linux 7.3.3 (Fedora 45) in a user namespace that maps three user IDs: 1001 as the attacker and 1002 for both victim processes. Each victim holds the lock for 4 seconds and waits at most 2 seconds for it.\n\nControl, 4.2.11, the attacker leaves the file in place. The second process times out:\n\n```text\nlock file: owner uid 1001, mode 666\ndirectory: mode 1777\nfirst entered 10:57:44\nfilelock._error.Timeout: The file lock '/mnt/shared/app.lock' could not be acquired.\nsecond exit status: 1\nfirst left 10:57:48\n```\n\n4.2.11 (commit `554c37b5`), the attacker removes the file 1.5 seconds into the first hold. Both processes are inside from 10:47:01 to 10:47:04:\n\n```text\nlock file: owner uid 1001, mode 666\ndirectory: mode 1777\nfirst entered 10:47:00\nuid 1001 removed the lock file\nsecond entered 10:47:01\nfirst left 10:47:04\nsecond left 10:47:05\nsecond exit status: 0\n```\n\n3.13.1, the release before #317, refuses the file, so the first process never holds it:\n\n```text\nPermissionError: [Errno 13] Permission denied: '/mnt/shared/app.lock'\n```\n\nWith the fix (commit `4536f7da`), the first process is refused:\n\n```text\nPermissionError: [Errno 13] lock file belongs to uid 1001, not to this process's account or the directory's owner: '/mnt/shared/app.lock'\n```\n\n## Attack sequence\n\n```mermaid\nsequenceDiagram\n    participant A as Attacker (uid 1001)\n    participant P as /tmp/app.lock\n    participant V1 as Victim process 1\n    participant V2 as Victim process 2\n    A-\u003e\u003eP: create file, mode 0666\n    V1-\u003e\u003e+P: open existing file, flock inode 1\n    P--\u003e\u003eV1: lock held\n    rect rgb(255, 214, 214)\n    A-\u003e\u003eP: unlink (owner under sticky directory)\n    V2-\u003e\u003e+P: O_CREAT | O_EXCL creates inode 2, flock\n    P--\u003e\u003eV2: lock held while process 1 still holds inode 1\n    end\n    deactivate P\n    deactivate P\n    rect rgb(216, 243, 220)\n    V1-\u003e\u003eP: fixed: fstat shows another owner\n    P--\u003e\u003eV1: PermissionError, no hold\n    end\n```\n\n## Reproducer files\n\nWritten for this advisory; the report's cross-account steps were not run by the reporter. Install the release to test into a directory, then run from the directory holding both files. It needs `unshare` with subordinate user IDs and no root:\n\n```text\nuv pip install --target site \"filelock==4.2.11\"\nunshare --map-auto --map-root-user --setgroups allow -m sh run.sh \"$PWD/site\" \"$PWD/holder.py\" unlink\n```\n\nPass `control` in place of `unlink` to leave the file in place.\n\n**`holder.py`**\n\n```python\nimport sys\nimport time\n\nfrom filelock import FileLock\n\nwith FileLock(sys.argv[2], timeout=float(sys.argv[3])):\n    print(sys.argv[1], \"entered\", time.strftime(\"%X\"), flush=True)\n    time.sleep(4)\nprint(sys.argv[1], \"left\", time.strftime(\"%X\"), flush=True)\n```\n\n**`run.sh`**\n\n```sh\n# usage: unshare --map-auto --map-root-user --setgroups allow -m sh run.sh \u003csite-dir with filelock\u003e \u003cholder.py\u003e control|unlink\nset -u\nmount -t tmpfs tmpfs /mnt\ncp -r \"$1\" /mnt/site; cp \"$2\" /mnt/holder.py; chmod -R a+rX /mnt\nmkdir /mnt/shared; chmod 1777 /mnt/shared\nlock=/mnt/shared/app.lock\nas() { uid=$1; shift; setpriv --reuid \"$uid\" --regid \"$uid\" --clear-groups \"$@\"; }\nhold() { as 1002 env PYTHONPATH=/mnt/site PYTHONDONTWRITEBYTECODE=1 python3 /mnt/holder.py \"$1\" \"$lock\" 2; }\nas 1001 sh -c \"umask 000; : \u003e $lock\"\nstat -c 'lock file: owner uid %u, mode %a' \"$lock\"; stat -c 'directory: mode %a' /mnt/shared\nhold first \u0026\nsleep 1.5\nif [ \"$3\" = unlink ]; then as 1001 rm \"$lock\" \u0026\u0026 echo \"uid 1001 removed the lock file\"; fi\nhold second; echo \"second exit status: $?\"\nwait\n```\n\n## Impact\n\nTwo cooperating processes run the protected section at the same time, so whatever the application guards with the lock can be written twice or left inconsistent. The attacker gains no access to that resource and no code execution. What the overlap costs depends on the application and is not established here.\n\nReproducibility: moderate. The steps are deterministic and need no race, but they need a second local account and a lock path in a sticky directory that the attacker creates first.\n\nReal-world exposure: niche. Most applications keep locks in a directory only their own account writes. A lock at a fixed path in `/tmp` on a host with other local accounts is the exposed setup, and the documentation named `/tmp` as a suitable sticky directory.\n\nSeverity: 2.5 (Low), `CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N`.\n\n- `AV:L`: the attacker needs a local account on the host.\n- `AC:H`: the attack depends on conditions the attacker does not control. The application must keep its lock at a predictable path in a shared sticky directory, and the attacker must create the file before any victim does.\n- `PR:L`: an unprivileged account suffices.\n- `UI:N`: no user action is needed.\n- `S:U`: the effect stays within the application using the lock.\n- `C:N`: nothing is disclosed.\n- `I:L`: the overlap can corrupt what the lock guards, but the attacker does not choose what is written. The evidence does not show more, so the lower value applies.\n- `A:N`: before this flaw the same attacker could already delay victims by holding the lock.\n\n## Versions tested\n\nReproduced on 3.13.2, 3.20.3, 4.0.0 and 4.2.11. Not reproduced on 3.13.1, which raises `PermissionError`. Releases between those tested were not run.\n\n[PR #968](https://github.com/tox-dev/filelock/pull/968) makes `UnixFileLock` raise `PermissionError` for a lock file under a sticky directory that belongs to neither the caller's account nor the directory's owner. The check runs on the opened file once the lock is taken, and it is the rule `StrictSoftFileLock` and `SoftReadWriteLock` already apply to their coordination directories.\n\n## Known mitigation\n\nKeep the lock file in a directory that only the accounts using the lock can write. Where the lock has to live in a shared sticky directory, have the directory's owner create the file before any other account can.\n\n## Affected release\n\n- [x] 4.2.11\n- [x] 4.0.0\n- [x] 3.20.3\n- [x] 3.13.2\n- [ ] 3.13.1\n\n## Credits\n\n[oss-security-shopify](https://github.com/oss-security-shopify), `GHSA-386w-3w6q-9c53`.","status":"published","published":"2026-12-04T22:16:18Z","modified":"2026-12-04T22:16:18Z","cvss":[{"version":"3.1","score":2.5,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N","level":"low"}],"cwes":["CWE-667"],"updated_at":"2026-12-04T22:29:34.61237Z"}],"nvd":[{"id":"CVE-2026-144405","description":"filelock is a platform-independent file lock for Python. From 3.13.2 until 4.2.12, on Unix, FileLock locks a regular file that already exists at the lock path, including one another local account created. Under a sticky directory such as /tmp that account owns the file and may remove it while a process holds the lock. The next process to acquire the lock creates and locks a new file at the same path, so two processes hold the same exclusive lock. oss-security-shopify reported this through private vulnerability reporting as GHSA-386w-3w6q-9c53, received on 17 November 2026. The affected native Unix lock is UnixFileLock, which FileLock selects where fcntl is available. Two cooperating processes run the protected section at the same time, so whatever the application guards with the lock can be written twice or left inconsistent. The attacker gains no access to that resource and no code execution. What the overlap costs depends on the application and is not established here. This issue is fixed in version 4.2.12.","status":"published","published":"2026-12-03T20:17:47.43Z","modified":"2026-12-04T15:47:41.367Z","cvss":[{"version":"3.1","score":2.5,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N","level":"low","assessor":"secondary"}],"cwes":["CWE-667"],"ssvc":{"exploitation":"none","automatable":"no","technical_impact":"partial","date":"2026-12-04"},"updated_at":"2026-12-04T15:25:18.511352Z"}],"osv":[{"id":"CVE-2026-144405","title":"FileLock on Unix lets two processes hold one lock after another user removes the lock file","description":"filelock is a platform-independent file lock for Python. From 3.13.2 until 4.2.12, on Unix, FileLock locks a regular file that already exists at the lock path, including one another local account created. Under a sticky directory such as /tmp that account owns the file and may remove it while a process holds the lock. The next process to acquire the lock creates and locks a new file at the same path, so two processes hold the same exclusive lock. oss-security-shopify reported this through private vulnerability reporting as GHSA-386w-3w6q-9c53, received on 17 November 2026. The affected native Unix lock is UnixFileLock, which FileLock selects where fcntl is available. Two cooperating processes run the protected section at the same time, so whatever the application guards with the lock can be written twice or left inconsistent. The attacker gains no access to that resource and no code execution. What the overlap costs depends on the application and is not established here. This issue is fixed in version 4.2.12.","status":"published","published":"2026-12-03T19:23:23.407Z","modified":"2026-12-04T21:02:47.108119567Z","cvss":[{"version":"3.1","score":2.5,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N","level":"low"}],"cwes":["CWE-667"],"updated_at":"2026-12-04T21:27:50.529822Z"},{"id":"DEBIAN-CVE-2026-144405","upstream":["CVE-2026-144405"],"description":"filelock is a platform-independent file lock for Python. From 3.13.2 until 4.2.12, on Unix, FileLock locks a regular file that already exists at the lock path, including one another local account created. Under a sticky directory such as /tmp that account owns the file and may remove it while a process holds the lock. The next process to acquire the lock creates and locks a new file at the same path, so two processes hold the same exclusive lock. oss-security-shopify reported this through private vulnerability reporting as GHSA-386w-3w6q-9c53, received on 17 November 2026. The affected native Unix lock is UnixFileLock, which FileLock selects where fcntl is available. Two cooperating processes run the protected section at the same time, so whatever the application guards with the lock can be written twice or left inconsistent. The attacker gains no access to that resource and no code execution. What the overlap costs depends on the application and is not established here. This issue is fixed in version 4.2.12.","status":"published","published":"2026-12-03T20:17:47.43Z","modified":"2026-12-04T11:00:06.463211607Z","cvss":[{"version":"3.1","score":2.5,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N","level":"low"}],"updated_at":"2026-12-04T11:08:31.228907Z"}]}}
