Repository navigation
Validate component model type depth - #2570
Merged
alexcrichton merged 2 commits intoJul 17, 2026
Merged
Conversation
This commit adds a new validation to `wasmparser` to ensure that component model types aren't "too deep". The primary goal of this commit is to resolve `wasmparser` stack-overflowing during validation of a component which otherwise has an arbitrarily deeply nested type (e.g. `list<list<list<...`). The limit placed on types right now is 100. One important part to note here is that this has some interesting relation to the checks Wasmtime does. Wasmtime actually already has a check for type depth as well, additionally limiting to 100. This is what gives rise to the value chosen here and additionally confidence that this won't break any realistic components in the wild. One important note though is that Wasmtime's depth-check actually only prevents stack overflow at runtime and it's still possible to stack-overflow at translation time (due to the order of when checks are applied). The fix here will resolve this problem in Wasmtime as well. A final note is that the rationale for this check is that many algorithms over component model types are modeled as recursive algorithms. In this situation an arbitrarily nested type can lead to stack overflow easily not just in validation but when processing elsewhere in the system. For example this means that even if the stack overflow were fixed in `wasmparser` itself that would not be sufficient to fully support arbitrarily nested types everywhere in the component ecosystem (e.g. WIT crates, etc).
pchickey
approved these changes
Jul 17, 2026
alexcrichton
enabled auto-merge
July 17, 2026 16:47
social4hyq
pushed a commit
to social4hyq/homebrew-core
that referenced
this pull request
Sep 20, 2026
wasm-tools 1.254.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## What's Changed * Reject out-of-range NaN payloads and bare type-index value types by @vouillon in bytecodealliance/wasm-tools#2563 * Implement upstream spec changes for component text syntax by @alexcrichton in bytecodealliance/wasm-tools#2562 * wasmparser: require result equivalence for `(on $t switch)` handler by @vouillon in bytecodealliance/wasm-tools#2564 * Prevent unbounded recursion when parsing WITs by @alexcrichton in bytecodealliance/wasm-tools#2565 * Add a parse recurse limit to `wasm-wave` by @alexcrichton in bytecodealliance/wasm-tools#2566 * wasm-metadata: Place a limit on decompression size by @alexcrichton in bytecodealliance/wasm-tools#2567 * Fix limiting 32-bit tables with `wasm-smith` by @alexcrichton in bytecodealliance/wasm-tools#2569 * Validate component model type depth by @alexcrichton in bytecodealliance/wasm-tools#2570 * Fix requiring `realloc` for `async`-lowered results-with-pointers by @alexcrichton in bytecodealliance/wasm-tools#2572 * Call `__wasm_init_task` for `_initialize` hook by @alexcrichton in bytecodealliance/wasm-tools#2574 * Release wasm-tools 1.254.0 by @github-actions[bot] in bytecodealliance/wasm-tools#2575 ## New Contributors * @vouillon made their first contribution in bytecodealliance/wasm-tools#2563 **Full Changelog**: https://github.com/bytecodealliance/wasm-tools/compare/v1.253.0...v1.254.0</pre> <p>View the full release notes at <a href="https://github.com/bytecodealliance/wasm-tools/releases/tag/v1.254.0">https://github.com/bytecodealliance/wasm-tools/releases/tag/v1.254.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!14731
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.
This commit adds a new validation to
wasmparserto ensure that component model types aren't "too deep". The primary goal of this commit is to resolvewasmparserstack-overflowing during validation of a component which otherwise has an arbitrarily deeply nested type (e.g.list<list<list<...). The limit placed on types right now is 100.One important part to note here is that this has some interesting relation to the checks Wasmtime does. Wasmtime actually already has a check for type depth as well, additionally limiting to 100. This is what gives rise to the value chosen here and additionally confidence that this won't break any realistic components in the wild. One important note though is that Wasmtime's depth-check actually only prevents stack overflow at runtime and it's still possible to stack-overflow at translation time (due to the order of when checks are applied). The fix here will resolve this problem in Wasmtime as well.
A final note is that the rationale for this check is that many algorithms over component model types are modeled as recursive algorithms. In this situation an arbitrarily nested type can lead to stack overflow easily not just in validation but when processing elsewhere in the system. For example this means that even if the stack overflow were fixed in
wasmparseritself that would not be sufficient to fully support arbitrarily nested types everywhere in the component ecosystem (e.g. WIT crates, etc).