wasmtime-wasi-http: outgoing HTTP body write allows guest-driven host memory exhaustion (DoS)
Description
Impact
wasmtime-wasi-http does not enforce the write allowance that wasi:io/streams.check-write returns for WASIp2 outgoing HTTP bodies.
A guest can call check-write, get the default configured DEFAULT_OUTGOING_BODY_CHUNK_SIZE of 1M (or whatever value the chunk size has been customized to in an embedder's own WasiHttpHooks impl), and then hand a much larger buffer to write. The write call will succeed for sizes larger than permitted by check-write, disobeying the spec's wasi:io/streams, write precondition which says such a write must trap. Due to this behavior, each outgoing-body resource created by the guest (trivial by way of creating an outgoing-request or outgoing-response) can be used to hold a host allocation of at least one linear memory sized vector for the lifetime of the guest's store.
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