Skip to main content
Menu
Advisories

Panic when a component cancels a stream or future copy on the wrong end

GHSA-XRVR-8678-5WP8Published Updated GitHub

Description

A WebAssembly component can make Wasmtime panic by calling stream.cancel-write on the readable end of a stream while a read is pending, or the equivalent for stream.cancel-read, future.cancel-write and future.cancel-read. The panic needs a store with two component instances, and the host must have passed a stream or future from one to the other.

Details

The Component Model specification requires stream.cancel-write and future.cancel-write to trap unless they are given a writable end, and stream.cancel-read and future.cancel-read to trap unless they are given a readable end. Wasmtime checks this only while no copy is in progress. Once a read or write has started and is waiting, Wasmtime records only that the end is busy, not which direction the copy is going. A cancel on the wrong end is then accepted. Wasmtime cancels the copy pending on the other end of the stream or future and delivers that end's pending event.

If both ends belong to the same component, this doesn't panic, but the component's handles are left inconsistent and further operations can return an error and poison the store.

If the two ends belong to different component instances, then the wrong type information can be used when processing an operation and this type lookup can panic when the index is out of bounds.

Impact

This affects embedders that enable the component model async feature and do both of the following:

  1. Instantiate more than one component in the same Store
  2. Pass a stream or future from one component instance to another through the host, for example by passing a StreamReader returned by one component's export to another component's import or export.

Panics are considered a denial-of-service vector in Wasmtime. Embedders that run a single component instance per store, or that never move streams or futures between component instances, see at most a trap.

Affected versions

References

GitHub · bytecodealliance/wasmtime