Skip to content

Fix container-overflow in BinaryReaderInterp (#2747) - #2812

Open
ANAMASGARD wants to merge 2 commits into
WebAssembly:mainfrom
ANAMASGARD:fix/interp-function-body-oob
Open

Fix container-overflow in BinaryReaderInterp (#2747)#2812
ANAMASGARD wants to merge 2 commits into
WebAssembly:mainfrom
ANAMASGARD:fix/interp-function-body-oob

Conversation

@ANAMASGARD

Copy link
Copy Markdown

Fixes #2747

Summary

  • Add OnFunctionBodyCount guard to BinaryReaderInterp to prevent container-overflow when stop_on_first_error=false and the Function section fails before all FuncDesc entries are appended.
  • Guard uses count != module_.funcs.size() (interp stores defined funcs only, unlike IR reader).
  • Add regression test with the 18-byte PoC from OOB read in wabt Interpreter Binary Reader #2747.

Test plan

  • ./wabt-unittests --gtest_filter='InterpTest.FunctionBodyCountMismatchWithCollectErrors'
  • ./wabt-unittests
  • PoC with stop_on_first_error=false returns error without crash

image

When stop_on_first_error=false, a failed OnFunction left module_.funcs
empty while OnFunctionCount had reserved capacity. BeginFunctionBody then
wrote past the vector's logical end (ASan container-overflow).
Add OnFunctionBodyCount guard matching the established BinaryReaderIR
pattern, adapted for interp where module_.funcs holds defined funcs only.
Fixes WebAssembly#2747

Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
Wrap comments and reformat the PoC byte array to satisfy
scripts/clang-format-diff.sh.

Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
@sbc100

sbc100 commented Aug 8, 2026

Copy link
Copy Markdown
Member

If this only applies with stop_on_first_error=false then i don't think we need to fix it since the interpreter should never be run in this mode.

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.

OOB read in wabt Interpreter Binary Reader

2 participants