Repository navigation
wasm2c: fix to check address + offset addition for memory64 - #2785
Merged
Merged
Conversation
sbc100
approved these changes
Jul 3, 2026
shravanrn
enabled auto-merge (rebase)
July 3, 2026 21:52
shravanrn
force-pushed
the
mem64-codegen-fixes
branch
from
July 3, 2026 21:52
cefc50e to
770e756
Compare
Collaborator
Author
|
Just an fyi, looks like I accidentally made the commit title include a (Security) prefix. To clarify, this is not a security issue. |
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.
As part of routine audit we found a bugs in the wasm2c code-generation for modules supporting memory64. Memory32 is not affected.
The wasm2c code generator for
LoadExprandStoreExpremits(u64)(addr) + offsetasuint64_taddition. This is fine for memory32 due to theuint64_tpromotion but hides an overflow for memory64 load/store that will violate Wasm semantics (but not break security).When the addr and offset addition overflow in Memory64 (e.g., addr=1 + offset=0xFFFFFFFFFFFFFFFF wraps to 0), the wrapped value is passed to
i32_store/i32_load, whereMEMCHECK_GENERAL->RANGE_CHECKonly checks the already-wrapped (small) value againstmem->size. The overflow is undetected and the access succeeds at the wrong address instead of trapping.