Skip to content
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

WASM serialization calls std::vector::resize(SIZE_MAX) which always leads to crash #152

Open
zhangbo-miuNEST opened this issue Mar 15, 2019 · 6 comments
Assignees

Comments

@zhangbo-miuNEST
Copy link

100% crash.

file: libraries/wasm-jit/Source/WASM/WASMSerialization.cpp
line: 384

OutputStream::capacity() always returns SIZE_MAX, so std::vector::resize(SIZE_MAX) always leads to crash. Please comment it out. Thanks.

void serialize(OutputStream& stream,UserSection& userSection)
{
userSection.data.resize( sectionStream.capacity() ? sectionStream.capacity() : 1 );
}

The latest WAVM source code has commented it out, but EOS and gxb-core don't synchronize with it yet.
https://github.com/EOSIO/eos/blob/master/libraries/wasm-jit/Source/WASM/WASMSerialization.cpp

@lanhaoxiang
Copy link
Member

Thanks a lot, can you also leave your gxchain account so we can send you the bug bounty for your contributions.

@zhangbo-miuNEST
Copy link
Author

my gxchain account is z16166. thanks

@ddggstudy
Copy link
Member

thank you very much!

can you supply an example code or method which can leading a crash which can help us to fix the problems ASAP.

@zhangbo-miuNEST
Copy link
Author

just build the target "gxc-wast2wasm" from gxb-core, and run it, it will core dump.
This tool is for WASM assembling.

command:
gxc-wast2wasm gxb-core/libraries/wasm-jit/Test/fuzzy/address.wast ./address.wasm

@RootkitKiller
Copy link
Contributor

Thank you very much for the great work you have done, @zhangbo-miuNEST .

Have you found that the "witness_node" crash caused by this bug?(witness_node is node program).

gxc-wast2wasm is a compilation tool. We first compile the cpp code into a wasm bytecode and then deploy the wasm bytecode to the blockchain. The crash process took place in the first phase. I haven't found any impact on the witness_node node. Is there more fuzz files or contracts?

@zhangbo-miuNEST
Copy link
Author

No, witness_node is not affected.

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

No branches or pull requests

4 participants