CVE-2026-47261: Wasmtime: WASI path_open(TRUNCATE) bypasses `FilePerms::WRITE` host restriction
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 pathopen interfaces by opening a file with OpenFlags::TRUNCATE oflag only, for example:
rust dirdescriptor.openat( PathFlags::empty(), FILENAME, OpenFlags::TRUNCATE, DescriptorFlags::READ, )
rust wasip1::pathopen( dirfd, 0, FILENAME, wasip1::OFLAGSTRUNC, wasip1::RIGHTSFDREAD, 0, 0 )
The root cause is that the clause that considered OpenFlags::TRUNCATE did not set openmode |= 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 pathopen fail with error-code.not-permitted and ERRNOPERM respectively.
The bug in crates/wasi/src/filesystem.rs, Dir::openat, lines 967–969:
rust if oflags.contains(OpenFlags::TRUNCATE) { opts.truncate(true).write(true); } and the single line fix is: rust if oflags.contains(OpenFlags::TRUNCATE) { opts.truncate(true).write(true); openmode |= 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: rust builder.preopeneddir("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.
Other sources
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 pathopen 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::openat, lines 967–969) did not set openmode |= 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 ERRNOPERM 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.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
rust/wasmtime-wasito a version that resolves this vulnerability.Fixed in 24.0.9 - Upgrade
Upgrade
rust/wasmtime-wasito a version that resolves this vulnerability.Fixed in 36.0.10 - Upgrade
Upgrade
rust/wasmtime-wasito a version that resolves this vulnerability.Fixed in 44.0.2 - Configuration
Ensure preopened directories are granted FilePerms::all() (or otherwise include FilePerms::WRITE) instead of only FilePerms::READ to prevent TRUNCATE-only opens from bypassing write-restriction checks.
WasiCtxBuilder preopened_dir preopen file permissions = FilePerms::all()
Event History
Frequently Asked Questions
What is the severity of CVE-2026-47261?
The severity of CVE-2026-47261 is rated high with a score of 7.5.
What type of vulnerability is CVE-2026-47261?
CVE-2026-47261 is a bypass of the access control mechanism in the wasmtime-wasi library.
How do I fix CVE-2026-47261?
To fix CVE-2026-47261, ensure that filesystem preopens do not use DirPerms::all() with FilePerms::READ without FilePerms::WRITE.
What software is affected by CVE-2026-47261?
CVE-2026-47261 affects the rust/wasmtime-wasi software package.
When was CVE-2026-47261 published?
CVE-2026-47261 was published on June 5, 2026.