Skip to main content
Menu
Advisories

wasmtime-wasi: guest can panic host through filesystem datetime overflow (wasip1, 2, 3)

GHSA-J2G9-4PRP-PF6HPublished Updated GitHub

Description

The wasmtime-wasi crate allows guest WASI programs to trigger a host panic by specifying a filesystem timestamp value where the microseconds field overflows the seconds field. The root cause is that Rust's std::time::Duration::new panics in the overflow case, rather than return an error.

wasip1

The path_filestat_set_times and fd_filestat_set_times functions take a timestamp typed arguments atim and mtim. A host panic is exposed if the microseconds can overflow the seconds field of this struct, e.g. Timestamp { seconds: u64::MAX, microseconds: 1_000_000_000 }, when passed in either argument position (atim or mtim) to these functions, as long as fst_flags does not obviate the atim or mtim argument with the ATIM_NOW/MTIM_NOW flag.

wasip2

The set-times and set-times-at methods on wasi:filesystem/types.descriptor take two new-timestamp typed arguments atim and mtim where the timestamp variant takes a datetime struct. A host panic is exposed if the microseconds can overflow the seconds field of this struct, e.g. NewTimestamp::Timestamp(Datetime { seconds: u64::MAX, microseconds: 1_000_000_000 }), when passed in either argument position (atim or mtim) to these functions.

wasip3

The set-times and set-times-at methods on wasi:filesystem/types.descriptor take two new-timestamp typed arguments atim and mtim where the timestamp variant takes a datetime struct. A host panic is exposed if the microseconds can overflow the seconds field of this struct, e.g. NewTimestamp::Timestamp(Datetime { seconds: i64::MAX, microseconds: 1_000_000_000 }), when passed in either argument position (atim or mtim) to these functions.

Patches

The fix for this issue is present the wasmtime project's main branch, as well as in the following patch releases:

36.0.16 48.0.3 49.0.1

Affected versions

References

GitHub · bytecodealliance/wasmtime