CVE-2026-47261
JSON

7.5high

Wasmtime: WASI path_open(TRUNCATE) bypasses `FilePerms::WRITE` host restriction

Severity
7.5high CVSS:3.1 by GitHub_M
Exploit likelihood
0.36% (higher than 31% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-2r75-cxrj-cmphRUSTSEC-2026-0149

Description

Wasmtime is a runtime for WebAssembly. In versions prior to 24.0.9, 36.0.10, and 44.0.2, when a filesystem preopen is given DirPerms::all() and FilePerms::READ without FilePerms::WRITE, this access control mechanism can be bypassed via the wasip2 descriptor.open-at or wasip1 path_open interfaces by opening a file with only the OpenFlags::TRUNCATE oflag. The root cause is that the clause handling OpenFlags::TRUNCATE in crates/wasi/src/filesystem.rs (Dir::open_at, lines 967–969) did not set open_mode |= OpenMode::WRITE;, which is later used for the access control check against FilePerms to determine whether opening the file is permitted; the single-line fix adds that missing assignment, after which the affected calls correctly fail with error-code.not-permitted and ERRNO_PERM respectively. Only wasmtime-wasi embeddings that combine DirPerms::MUTATE with FilePerms::READ are affected by this bug. In particular, the Wasmtime project's wasmtime-cli's use of wasmtime-wasi is not affected, because it always sets FilePerms::all() for all preopens. This issue has been fixed in versions 24.0.9, 36.0.10 and44.0.2.

Affected

Product or packageVersionsReported by
bytecodealliance wasmtime>= 37.0.0, < 44.0.2, >= 25.0.0, < 36.0.10, < 24.0.9, before 24.0.9, from 25.0.0 before 36.0.10, from 37.0.0 before 44.0.2CVE List, NVD
wasmtime-wasi (crates.io)from 37.0.0 before 44.0.2, from 25.0.0 before 36.0.10, before 24.0.9, from 0.0.0-0 before 24.0.9, from 45.0.0 before 45.0.0GitHub Advisory Database, RustSec Advisory Database

All scores

GitHub_M7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
RustSec Advisory Database7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N

Classification

CWE-284

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.

What each source says

CVE List

Wasmtime is a runtime for WebAssembly. In versions prior to 24.0.9, 36.0.10, and 44.0.2, when a filesystem preopen is given DirPerms::all() and FilePerms::READ without FilePerms::WRITE, this access control mechanism can be bypassed via the wasip2 descriptor.open-at or wasip1 path_open interfaces by opening a file with only the OpenFlags::TRUNCATE oflag. The root cause is that the clause handling OpenFlags::TRUNCATE in crates/wasi/src/filesystem.rs (Dir::open_at, lines 967–969) did not set open_mode |= OpenMode::WRITE;, which is later used for the access control check against FilePerms to determine whether opening the file is permitted; the single-line fix adds that missing assignment, after which the affected calls correctly fail with error-code.not-permitted and ERRNO_PERM respectively. Only wasmtime-wasi embeddings that combine DirPerms::MUTATE with FilePerms::READ are affected by this bug. In particular, the Wasmtime project's wasmtime-cli's use of wasmtime-wasi is not affected, because it always sets FilePerms::all() for all preopens. This issue has been fixed in versions 24.0.9, 36.0.10 and44.0.2.

GitHub Advisory Database

Summary

In wasmtime-wasi, when a filesystem preopen is given DirPerms::all() and FilePerms::READ without FilePerms::WRITE, this wasmtime-wasi enforced access control mechanism can be bypassed by using the wasip2 descriptor.open-at or wasip1 path_open interfaces by opening a file with OpenFlags::TRUNCATE oflag only, for example:

dir_descriptor.open_at(
   PathFlags::empty(),
   FILENAME,
   OpenFlags::TRUNCATE,
   DescriptorFlags::READ,
)
wasip1::path_open(
    dir_fd,
    0,
    FILENAME,
    wasip1::OFLAGS_TRUNC,
    wasip1::RIGHTS_FD_READ,
    0,
    0
)

The root cause is that the clause that considered OpenFlags::TRUNCATE did not set open_mode |= OpenMode::WRITE;, used later in that function for the access control check against FilePerms for whether opening that file is permitted. With the bug corrected, these calls to open-at and path_open fail with error-code.not-permitted and ERRNO_PERM respectively.

The bug in crates/wasi/src/filesystem.rs, Dir::open_at, lines 967–969:

if oflags.contains(OpenFlags::TRUNCATE) {
    opts.truncate(true).write(true);
}

and the single line fix is:

if oflags.contains(OpenFlags::TRUNCATE) {
    opts.truncate(true).write(true);
    open_mode |= OpenMode::WRITE;
}

Only wasmtime-wasi embeddings that use a combination of DirPerms::MUTATE with FilePerms::READ are affected by this bug, e.g. those that use in the WasiCtxBuilder:

builder.preopened_dir("readonly", "readonly", DirPerms::READ | DirPerms::MUTATE, FilePerms::READ);

In particular, the Wasmtime project's wasmtime-cli's use of wasmtime-wasi is not affected, because it always sets FilePerms::all() for all preopens.

RustSec Advisory Database

This is an entry in the RustSec database for the Wasmtime security advisory located at https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-2r75-cxrj-cmph For more information see the GitHub-hosted security advisory.

NVD (es)

Wasmtime es un entorno de ejecución para WebAssembly. En versiones anteriores a la 24.0.9, 36.0.10 y 44.0.2, cuando a una preapertura del sistema de archivos se le otorgan DirPerms::all() y FilePerms::READ sin FilePerms::WRITE, este mecanismo de control de acceso puede ser eludido a través de las interfaces wasip2 descriptor.open-at o wasip1 path_open abriendo un archivo con solo el indicador OpenFlags::TRUNCATE. La causa raíz es que la cláusula que maneja OpenFlags::TRUNCATE en crates/wasi/src/filesystem.rs (Dir::open_at, líneas 967-969) no estableció open_mode |= OpenMode::WRITE;, lo cual se usa posteriormente para la verificación de control de acceso contra FilePerms para determinar si se permite abrir el archivo; la corrección de una sola línea añade esa asignación faltante, después de lo cual las llamadas afectadas fallan correctamente con error-code.not-permitted y ERRNO_PERM respectivamente. Solo las incrustaciones de wasmtime-wasi que combinan DirPerms::MUTATE con FilePerms::READ se ven afectadas por este error. En particular, el uso de wasmtime-wasi por parte de wasmtime-cli del proyecto Wasmtime no se ve afectado, porque siempre establece FilePerms::all() para todas las preaperturas. Este problema ha sido solucionado en las versiones 24.0.9, 36.0.10 y44.0.2.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-47261 changed 2026-06-16CVE Terms of Use
GitHub Advisory DatabaseGHSA-2r75-cxrj-cmph changed 2026-09-10CC-BY-4.0
RustSec Advisory DatabaseRUSTSEC-2026-0149 changed 2026-10-12CC0-1.0
NVDCVE-2026-47261 changed 2026-10-25Public domain