CVE-2026-144405: Filelock FileLock On Unix Lets Two Vulnerability

LOW
Advisory Identifier: GHSA-386w-3w6q-9c53
CVSS 2.5
CWE-667
Published
Advisory Summary

CVE-2026-144405 is a LOW (CVSS 2.5) filelock on unix lets two vulnerability (CWE-667: Improper Locking) affecting Filelock libraries in the PyPI ecosystem. The issue involves filelock on unix lets two processes hold one lock after another user removes the lock file. Remediation is available by upgrading affected packages to version 4.2.12.

CVE-2026-144405 at a Glance

CVE Identifier CVE-2026-144405
GHSA Identifier GHSA-386w-3w6q-9c53
Severity LOW
CVSS v3.1 Base Score 2.5
CWE Classification CWE-667: Improper Locking
Affected Product Filelock
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 2.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N).

Attack Vector Local (AV:L)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-144405

To remediate this vulnerability, upgrade all affected Filelock dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

filelock fixed: 4.2.12
pip install filelock>=4.2.12
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show filelock

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-144405, inspect your installed packages using pip:

pip show filelock

Analyze the terminal output to locate any version of Filelock in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.2.12), your application is affected.

Note: The pip show filelock command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-667: Improper Locking, where the product does not properly acquire or release a lock on a resource, leading to unexpected resource state changes and behaviors. In Filelock, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary 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](https://github.com/oss-security-shopify) reported this through private vulnerability reporting as `GHSA-386w-3w6q-9c53`, received on 17 November 2026. ## Affected area Acquisition of the native Unix lock, `UnixFileLock`, which `FileLock` names where `fcntl` is available. ## Attacker-controlled input Another 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. ## Affected code In 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. ## Mechanism 1. The attacker creates the lock file with mode `0666` in a sticky directory. 2. 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. 3. 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. 4. 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. 5. 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. Out 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. ## Reproduction and evidence Run 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. Control, 4.2.11, the attacker leaves the file in place. The second process times out: ```text lock file: owner uid 1001, mode 666 directory: mode 1777 first entered 10:57:44 filelock._error.Timeout: The file lock '/mnt/shared/app.lock' could not be acquired. second exit status: 1 first left 10:57:48 ``` 4.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: ```text lock file: owner uid 1001, mode 666 directory: mode 1777 first entered 10:47:00 uid 1001 removed the lock file second entered 10:47:01 first left 10:47:04 second left 10:47:05 second exit status: 0 ``` 3.13.1, the release before #317, refuses the file, so the first process never holds it: ```text PermissionError: [Errno 13] Permission denied: '/mnt/shared/app.lock' ``` With the fix (commit `4536f7da`), the first process is refused: ```text PermissionError: [Errno 13] lock file belongs to uid 1001, not to this process's account or the directory's owner: '/mnt/shared/app.lock' ``` ## Attack sequence ```mermaid sequenceDiagram participant A as Attacker (uid 1001) participant P as /tmp/app.lock participant V1 as Victim process 1 participant V2 as Victim process 2 A->>P: create file, mode 0666 V1->>+P: open existing file, flock inode 1 P-->>V1: lock held rect rgb(255, 214, 214) A->>P: unlink (owner under sticky directory) V2->>+P: O_CREAT | O_EXCL creates inode 2, flock P-->>V2: lock held while process 1 still holds inode 1 end deactivate P deactivate P rect rgb(216, 243, 220) V1->>P: fixed: fstat shows another owner P-->>V1: PermissionError, no hold end ``` ## Reproducer files Written 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: ```text uv pip install --target site "filelock==4.2.11" unshare --map-auto --map-root-user --setgroups allow -m sh run.sh "$PWD/site" "$PWD/holder.py" unlink ``` Pass `control` in place of `unlink` to leave the file in place. **`holder.py`** ```python import sys import time from filelock import FileLock with FileLock(sys.argv[2], timeout=float(sys.argv[3])): print(sys.argv[1], "entered", time.strftime("%X"), flush=True) time.sleep(4) print(sys.argv[1], "left", time.strftime("%X"), flush=True) ``` **`run.sh`** ```sh # usage: unshare --map-auto --map-root-user --setgroups allow -m sh run.sh <site-dir with filelock> <holder.py> control|unlink set -u mount -t tmpfs tmpfs /mnt cp -r "$1" /mnt/site; cp "$2" /mnt/holder.py; chmod -R a+rX /mnt mkdir /mnt/shared; chmod 1777 /mnt/shared lock=/mnt/shared/app.lock as() { uid=$1; shift; setpriv --reuid "$uid" --regid "$uid" --clear-groups "$@"; } hold() { as 1002 env PYTHONPATH=/mnt/site PYTHONDONTWRITEBYTECODE=1 python3 /mnt/holder.py "$1" "$lock" 2; } as 1001 sh -c "umask 000; : > $lock" stat -c 'lock file: owner uid %u, mode %a' "$lock"; stat -c 'directory: mode %a' /mnt/shared hold first & sleep 1.5 if [ "$3" = unlink ]; then as 1001 rm "$lock" && echo "uid 1001 removed the lock file"; fi hold second; echo "second exit status: $?" wait ``` ## Impact 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. Reproducibility: 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. Real-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. Severity: 2.5 (Low), `CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N`. - `AV:L`: the attacker needs a local account on the host. - `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. - `PR:L`: an unprivileged account suffices. - `UI:N`: no user action is needed. - `S:U`: the effect stays within the application using the lock. - `C:N`: nothing is disclosed. - `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. - `A:N`: before this flaw the same attacker could already delay victims by holding the lock. ## Versions tested Reproduced 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. [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. ## Known mitigation Keep 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. ## Affected release - [x] 4.2.11 - [x] 4.0.0 - [x] 3.20.3 - [x] 3.13.2 - [ ] 3.13.1 ## Credits [oss-security-shopify](https://github.com/oss-security-shopify), `GHSA-386w-3w6q-9c53`.

CVE-2026-144405 Affected Filelock Versions

1 component(s)
Fixed Versions:
4.2.12
Product / Package Ecosystem Affected Versions Fixed Version
filelock
PyPI
≥ 3.13.2
< 4.2.12
4.2.12

References

Frequently Asked Questions

What is CVE-2026-144405?
CVE-2026-144405 is a security vulnerability in Filelock involving FileLock on Unix lets two processes hold one lock after another user removes the lock file under CWE-667: Improper Locking.
Which Filelock versions are affected?
Affected versions include releases prior to 4.2.12 across affected packages: filelock.
What version fixes CVE-2026-144405?
Upgrading to 4.2.12 (or the latest patched release for your respective branch) resolves the vulnerability.
Is filelock affected?
Yes, filelock is affected in releases prior to 4.2.12. Upgrade your dependency to 4.2.12 or later.
What is the CVSS score of CVE-2026-144405?
CVE-2026-144405 has a CVSS v3.1 base score of 2.5 (LOW) with vector string CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N.
What CWE is associated with CVE-2026-144405?
CVE-2026-144405 is classified under CWE-667: Improper Locking (The product does not properly acquire or release a lock on a resource, leading to unexpected resource state changes and behaviors.).
How can I check PyPI dependencies for CVE-2026-144405?
Run the dependency tree command: 'pip show filelock'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-386w-3w6q-9c53",
  "modified" : "2026-12-04T22:16:18Z",
  "published" : "2026-12-04T22:16:18Z",
  "aliases" : [ "CVE-2026-144405" ],
  "summary" : "FileLock on Unix lets two processes hold one lock after another user removes the lock file",
  "details" : "## 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->>P: create file, mode 0666\n    V1->>+P: open existing file, flock inode 1\n    P-->>V1: lock held\n    rect rgb(255, 214, 214)\n    A->>P: unlink (owner under sticky directory)\n    V2->>+P: O_CREAT | O_EXCL creates inode 2, flock\n    P-->>V2: 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->>P: fixed: fstat shows another owner\n    P-->>V1: 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 <site-dir with filelock> <holder.py> 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; : > $lock\"\nstat -c 'lock file: owner uid %u, mode %a' \"$lock\"; stat -c 'directory: mode %a' /mnt/shared\nhold first &\nsleep 1.5\nif [ \"$3\" = unlink ]; then as 1001 rm \"$lock\" && 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`.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "filelock"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.13.2"
      }, {
        "fixed" : "4.2.12"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.2.11"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/tox-dev/filelock/security/advisories/GHSA-386w-3w6q-9c53"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-144405"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/tox-dev/filelock/pull/968"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/tox-dev/filelock/commit/571eb998ea65c1cdd54157c70e4c592e6ac3cd04"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/tox-dev/filelock"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/tox-dev/filelock/releases/tag/4.2.12"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-667" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-12-04T22:16:18Z",
    "nvd_published_at" : "2026-12-03T20:17:47Z"
  }
}