/

CVE-2026-47261

Severity:

HIGH RISK

(7.5)

Access Control Bypass (CWE-284) in Wasmtime WASI Filesystem

CVE-2026-47261

Analyzed

Vulnerability type

Category:

Access Control Bypass

CWE:

CWE-284

Impact:

Unauthorized File Modification within Wasm Sandbox

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A filesystem access control flaw in Wasmtime's WASI implementation allows certain embeddings to bypass configured write restrictions on preopened directories.

When DirPerms::MUTATE is combined with FilePerms::READ only, an attacker can open and truncate files using specific WASI open flags, effectively performing unauthorized writes in sandboxes that were intended to be read-only.

Affected context

This vulnerability appears in Wasmtime deployments that embed wasmtime-wasi and configure preopened directories with DirPerms::MUTATE (or DirPerms::all()) while restricting FilePerms to READ only.

It is specifically triggered when guest WebAssembly modules use wasip2 descriptor.open-at or wasip1 path_open with the TRUNCATE open flag.

Typical affected contexts are custom host applications embedding Wasmtime for sandboxed code execution where the host expects certain directories to be non-writable at the file level despite mutable directory permissions.

Exploit preconditions

  • Attack surface: Guest WebAssembly modules running under Wasmtime with wasmtime-wasi enabled.
  • Required access: Ability to execute or supply a Wasm module in the affected embedding, with access to a preopened directory configured as DirPerms::MUTATE (or DirPerms::all()) plus FilePerms::READ and without FilePerms::WRITE.
  • Trigger point: Calls to wasip2 descriptor.open-at or wasip1 path_open specifying OpenFlags::TRUNCATE, thereby opening a file that should not be writable.
  • Why exploitation is possible: The TRUNCATE flag was not coupled with OpenMode::WRITE in the open logic, so the subsequent access control check did not recognize the operation as a write, allowing the open-and-truncate operation to proceed despite missing FilePerms::WRITE.

Why this happens

The underlying issue is a mismatch between the intended access control policy and its enforcement in the WASI filesystem implementation.

In crates/wasi/src/filesystem.rs, the OpenFlags::TRUNCATE clause failed to mark the open request as a write operation (missing open_mode |= OpenMode::WRITE), even though truncation semantically modifies file contents.

Access checks later compared the computed open_mode against the configured FilePerms; because the write bit was not set, the check incorrectly treated truncation as a read-only operation and permitted it.

This aligns with CWE-284: Improper Access Control, where a security mechanism is implemented incompletely and allows operations that should have been restricted under the configured permissions.

Potential impact

  • Guest modules may truncate files in directories that were intended to be read-only at the file level.
  • Sandboxed code could destroy or corrupt configuration, cache, or data files exposed via preopens.
  • Integrity of host-managed data within the Wasm sandbox can be compromised.
  • Defense-in-depth assumptions about read-only filesystem exposure to untrusted Wasm code may no longer hold.

General mitigation guidance

Effective mitigation focuses on aligning permissions semantics with actual behavior and minimizing trust in guest code:

  • Treat file truncation and similar operations as content-modifying writes in access control logic, ensuring that write-like flags map to corresponding write permissions.
  • Prefer conservative permission profiles for preopened directories, granting only the minimum DirPerms and FilePerms necessary for the guest workload.
  • Separate read-only and mutable data paths explicitly, and avoid configurations that rely on subtle combinations of directory and file permissions for security.
  • Apply defense-in-depth by constraining where sensitive files are mounted into the Wasm environment and by validating permission configurations as part of deployment.

How teams detect issues like this

To detect and monitor similar issues:

  • Use static analysis or code search to identify permission checks that do not fully account for all write-like flags (such as TRUNCATE, APPEND, or CREATE).
  • During code review, verify that each filesystem flag is consistently mapped to a clear read/write/metadata permission model, and that access checks use this unified representation.
  • Implement configuration validation or policy checks that flag suspicious combinations such as DirPerms::MUTATE paired with FilePerms::READ-only semantics for directories exposed to untrusted code.
  • Consider runtime logging or auditing of filesystem operations (particularly open with unusual flag combinations) invoked by guest modules to spot unexpected write behavior.

Sources

SourceLink
github.comgithub.com/bytecodealliance/wasmtime/releases/tag/v24.0.9
github.comgithub.com/bytecodealliance/wasmtime/releases/tag/v36.0.10
github.comgithub.com/bytecodealliance/wasmtime/releases/tag/v44.0.2
github.comgithub.com/bytecodealliance/wasmtime/releases/tag/v45.0.0
github.comgithub.com/bytecodealliance/wasmtime/security/advisories/GHSA-2r75-cxrj-cmph

Frequently asked

questions

It can be, but only if a remote party can supply or influence the WebAssembly module executed by the Wasmtime embedding and that module has access to a preopened directory with the affected permission combination.

An attacker needs the ability to run or control Wasm code in the impacted Wasmtime environment and must be able to reach preopened directories configured with DirPerms::MUTATE (or all) while restricted to FilePerms::READ.

Ensure that all filesystem operations which modify file contents or metadata are consistently treated as writes in permission checks, and avoid permission configurations that rely on subtle distinctions between directory and file capabilities for isolation.

Design a clear permission model for filesystem operations, map every flag to that model in a single, well-reviewed layer, enforce least-privilege preopen configurations, and supplement development with targeted tests and reviews around access control boundaries.

Find out what's already
exploitable in your codebase.