-
Notifications
You must be signed in to change notification settings - Fork 715
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
'@' before a quote (") causes a libc++abi.dylib crash using wat2wasm. #2165
Comments
keithw
added a commit
that referenced
this issue
Mar 10, 2023
This adds a bounds-check to WastLexer::GetText to handle the case when the offset is earlier than token_start (e.g. because GetStringToken found a newline in the string and reset token_start to point to it). Also revises GetIdToken -> GetIdChars to stop skipping the initial char in an annotation delimiter, which is an idchar+ but not an id token. Also fixes the WastParser to handle EOF when reading for the end of an annotation, both for code metadata annotation and other kinds. Previously this produced an infinite loop (but only when --enable-annotations was provided). Fixes #2165
Thank you! If you have time, please take a look at #2166 and let me know what you think. |
keithw
added a commit
that referenced
this issue
Mar 10, 2023
This adds a bounds-check to WastLexer::GetText to handle the case when the offset is earlier than token_start (e.g. because GetStringToken found a newline in the string and reset token_start to point at it). Also revises GetIdToken -> GetIdChars to stop skipping the initial char in an annotation delimiter, which is an idchar+ but not an id token. Also fixes the WastParser to handle EOF when reading for the end of an annotation, both for code metadata annotations and other kinds. Previously this produced an infinite loop (but only with --enable-annotations). Fixes #2165
keithw
added a commit
that referenced
this issue
Mar 10, 2023
This adds a bounds-check to WastLexer::GetText to handle the case when the offset is earlier than token_start (e.g. because GetStringToken found a newline in the string and reset token_start to point at it). Also revises GetIdToken -> GetIdChars to stop skipping the initial char in an annotation delimiter, which is an idchar+ but not an id token. Also fixes the WastParser to handle EOF when reading for the end of an annotation, both for code metadata annotations and other kinds. Previously this produced an infinite loop (but only with --enable-annotations). Fixes #2165
This is CVE-2023-31669 for the record. |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Describe the bug
'@' before a quote (") causes a libc++abi.dylib crash while converting ".wat" format into ".wasm" format using wat2wasm.
wat2wasm --version
: 1.0.32 (git~1.0.32-35-g9990b0cf)The following minimized code causes wat2wasm to crash.
Absolute minimum example:
Steps to reproduce:
Here are the test files: (Remove ".txt" and save them ".wat" files)
wabt_crash.wat.txt
wabt_crash_min.wat.txt
Install and build WABT
Run wat2wasm on the test file:
wat2wasm wabt_crash.wat
andwat2wasm wabt_crash_min.wat
Observe the crash:
Expected Behavior:
Expected output should be an error (like the one below) produced by
wat2wasm
instead of a crash.For example, if the test file replaces the '@' with a '*',
wat2wasm
gives the expected error below when run withwat2wasm expected.wat
, which points out the missing end quote.Additional information
A combination of afl-fuzz++4.03a and Wasmlike, an Xsmith-based random program generator produced the snippet of code that caused the crash. https://www.flux.utah.edu/project/xsmith
The text was updated successfully, but these errors were encountered: