Implement validation of custom sections - #2668
Merged
alexcrichton merged 2 commits intoSep 17, 2026
Merged
Conversation
Custom sections aren't validated by default in WebAssembly, but upstream spec tests have an `assert_invalid_custom` directive for still indicating whether a custom section is intended to be invalid or not. Additionally for custom sections like the `name` section the upstream specification still specifies validity criteria. Previously `wasm-tools wast` did not implement the `assert_invalid_custom` directive, simply succeeding on it, and there was no validation of any custom sections. This commit addresses this by implementing the `assert_invalid_custom` directive, adding a `--validate-custom` flag to `wasm-tools validate`, and otherwise implementing validation for custom sections. This is done in such a way to avoid impacting main module validation and is additionally something embedders must opt-in to executing, if even. My hunch is that most embedders won't bother with this and this'll be a niche-useful command line flag but that's pretty much it.
pchickey
approved these changes
Sep 17, 2026
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.
Custom sections aren't validated by default in WebAssembly, but upstream spec tests have an
assert_invalid_customdirective for still indicating whether a custom section is intended to be invalid or not. Additionally for custom sections like thenamesection the upstream specification still specifies validity criteria. Previouslywasm-tools wastdid not implement theassert_invalid_customdirective, simply succeeding on it, and there was no validation of any custom sections.This commit addresses this by implementing the
assert_invalid_customdirective, adding a--validate-customflag towasm-tools validate, and otherwise implementing validation for custom sections. This is done in such a way to avoid impacting main module validation and is additionally something embedders must opt-in to executing, if even. My hunch is that most embedders won't bother with this and this'll be a niche-useful command line flag but that's pretty much it.