Conversation
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ASan on
wasm-interp --wasi, running a valid module that under-declares a WASI import:Found this fuzzing
wasm-interp --wasiwith hand-built modules.WasiBindImportsbinds each import to its host callback by name and keeps thefunc type the module declared. There is a
// TODO(sbc): Validate signaturesright next to it.
Thread::DoCallthen sizes theparams/resultsvectorsfrom that declared type, but every callback indexes
params[]/results[]bythe arity of the real WASI function.
So a module that imports
clock_time_getas(i32) -> i32instead of(i32 i64 i32) -> i32still validates, and the call readsparams[1]past aone-element vector. The
*_gethandlers also doresults[0].Set<...>()on anempty
results, so a mis-declared result count is an out-of-bounds write aswell. Both are reachable from an untrusted module through
wasm-interp --wasi.Fix carries each function's
(num_params, num_results)inwasi_api.defandrejects a mismatched import before
HostFunc::New, so the arity check fails atbind time rather than at the out-of-bounds access. Arity only, deliberately:
some callbacks read i64 params as u32 (
path_openrights,fd_seekoffset),so checking the types here would reject conforming modules. The declared arity
is fixed by the WASI ABI, so valid modules are unaffected.
Test declares
clock_time_getwith the wrong arity and expects the bind-timerejection; the existing
test/wasicases still pass.wasm-interp --wasineeds
-DWITH_WASI=ON.