Skip to content

Fix module instantiation bug: out of bounds memory access #1531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 3, 2025

Conversation

Robbepop
Copy link
Member

@Robbepop Robbepop commented Jun 3, 2025

The following Wasm input was successfully instantiated in Wasmi whereas it should have failed with:

memory access out of bounds
(module
  (memory (;0;) i64 1 1)
  (func (export ""))
  (data (i64.const -1095216660480) "\ff")
)

The bug was that Wasmi was lossily converting a u64 value into a u32 and thus read the (i64.const -1095216660480) offset value as 0 instead of a huge number. This is probably an artifact from the times where Wasmi did not yet support memory64. I wonder why the fuzzing system didn't catch this (earlier).

Thanks @alexcrichton for the report.

Copy link

codecov bot commented Jun 3, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 71.75%. Comparing base (62cd056) to head (0cf3504).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/wasmi/src/module/instantiate/mod.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1531      +/-   ##
==========================================
+ Coverage   71.73%   71.75%   +0.01%     
==========================================
  Files         177      177              
  Lines       16523    16524       +1     
==========================================
+ Hits        11853    11857       +4     
+ Misses       4670     4667       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Robbepop Robbepop merged commit 2254f91 into main Jun 3, 2025
19 checks passed
@Robbepop Robbepop deleted the rf-fix-instantiation-bug branch June 3, 2025 09:08
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Jun 3, 2025
github-merge-queue bot pushed a commit to bytecodealliance/wasmtime that referenced this pull request Jun 3, 2025
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant