Skip to main content
Menu
Advisories

WASI filesystem sandbox escape on Windows through a drive-prefixed path component

GHSA-F2PQ-268W-886CPublished Updated GitHub

Description

Wasmtime's filesystem implementation in the wasmtime-wasi crate had a bug on Windows that let guests escape their filesystem sandbox and read and write files and directories outside of it. Any guest given access to a directory can reach any file or directory the host process can access, on any drive. With write access, the guest can read, create, overwrite, and delete files outside the sandbox. With read-only access, it can read any file the host process can read. This bug is a full filesystem sandbox escape for guests.

Details

Wasmtime's sandboxed path resolution splits a guest's path into components and then hands each one to the OS layer as a standalone path. The path ./C:foo from a guest was parsed at this layer as a normal component with the name C:foo, but the next layer of Wasmtime's implementation treated this as a drive-relative path C:foo. This different interpretation in the meaning of the path meant the operation went to the host filesystem through ambient APIs instead of relative to the sandboxed directory. Paths containing such components could reach the escape directly, through any WASI filesystem function that takes a path (WASIp1 path_open, WASIp2/WASIp3 open-at, and the related stat, create, remove, rename, and link functions), or indirectly, through the target of a symlink inside the sandbox.

This bug only affects Wasmtime running on Windows hosts. Other platforms do not have drive prefixes and are not affected.

Impact

Guests on Windows are able to read or write any path on the filesystem through this vulnerability. Guests need be given any preopened directory, and through that all contents of the filesystem could be read or written. If guests were only given read-only access then the filesystem could only be read, not written.

Affected versions

References

GitHub · bytecodealliance/wasmtime