Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Binaryen: array_ptr_impl can cause buffer overflow in 32-bits build #3541

Closed
guhe120 opened this issue May 29, 2018 · 0 comments
Closed

Binaryen: array_ptr_impl can cause buffer overflow in 32-bits build #3541

guhe120 opened this issue May 29, 2018 · 0 comments
Assignees
Milestone

Comments

@guhe120
Copy link

guhe120 commented May 29, 2018

Hi,

In function array_ptr_impl in Binaryen.hpp:

template

inline array_ptr array_ptr_impl (interpreter_interface* interface, uint32_t ptr, uint32_t length)

{
return array_ptr((T*)(interface->get_validated_pointer(ptr, length * (uint32_t)sizeof(T))));
}

Here we have full control of the |length| parameter, in 32-bits process, length * (uint32_t)sizeof(T) could overflow 32-bits integer range and results in a very small value, which then bypasses the boundary check in get_validated_pointer and returns an over-sized array_ptr.

Then we can read/write out of the bounds of the wasm memory buffer with this over-sized array_ptr.

This is a submission to EOS bug bounty program.

This bug credits to:

Yuki Chen of Qihoo 360 Vulcan Team.

Thank you!

@arhag arhag added this to the Version 1.0 milestone May 29, 2018
@larryk85 larryk85 self-assigned this May 29, 2018
larryk85 added a commit that referenced this issue May 29, 2018
bytemaster added a commit that referenced this issue May 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants