Validate Wasm language memory reads#5569
Merged
maxbrunsfeld merged 1 commit intoMay 6, 2026
Merged
Conversation
maxbrunsfeld
approved these changes
May 6, 2026
Contributor
|
Thank you! Great improvement. |
|
Successfully created backport PR for |
clason
pushed a commit
that referenced
this pull request
May 19, 2026
Problem: Offsets such as parse_table, symbol_names, lex_modes, and the alias/supertype tables are used directly as indexes into the store's memory buffer. A malformed module can point one of those fields outside the current linear memory and make the host process read through an invalid pointer while loading the language. Solution: Add a small checked-memory wrapper for Wasm language loading and routes descriptor reads, table copies, string reads, and the alias-map scan through it. Invalid descriptor addresses now fail loading with TSWasmErrorKindInstantiate. (cherry picked from commit 21cfae7) Co-authored-by: 𝙽!𝙻 <z_hakmi@estin.dz>
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.
Validate offsets from
LanguageInWasmMemorybefore copying language data out of Wasm memory.The language descriptor is provided by the module being loaded. Before this change, offsets such as
parse_table,symbol_names,lex_modes, and the alias/supertype tables were used directly as indexes into the store's memory buffer. A malformed module could point one of those fields outside the current linear memory and make the host process read through an invalid pointer while loading the language.This adds a small checked-memory wrapper for Wasm language loading and routes descriptor reads, table copies, string reads, and the alias-map scan through it. Invalid descriptor addresses now fail loading with
TSWasmErrorKindInstantiate.Local checks:
parse_table = 0x7ffffff0is rejected instead of crashinggit diff --checkAI disclosure: I used assistant support during local investigation and repro drafting; I reviewed the code and verified the patch.