danleh / wasabi

A dynamic analysis framework for WebAssembly programs.
http://wasabi.software-lab.org
MIT License
363 stars 47 forks source link

'__wasabi_hooks' is not an Object #10

Closed LFYSec closed 5 years ago

LFYSec commented 5 years ago

When I tested the taint.js and call-graph.js, I found some bugs in *.wasabi.js.

Some errors occurred when I was testing importObjectWithHooks in the console such as "importObjectWithHooks.__wasabi_hooks was undefineded."

call-graph.js's error: wasm streaming compile failed: TypeError: import object field '__wasabi_hooks' is not an Object ... and many Wasabi.HOOK_NAMES func not found.

taint.js 's error: Starting taint analysis taint.js:13:13 Warning: No exported source function found. taint.js:53:42 Warning: No exported sink function found. taint.js:54:40 wasm streaming compile failed: TypeError: import object field '__wasabi_hooks' is not an Object test.html:1246:19 falling back to ArrayBuffer instantiation test.html:1246:19 nop hook not provided by Wasabi.analysis, add empty function as fallback test.wasabi.js:142:25 unreachable hook not provided by Wasabi.analysis, add empty function as fallback

danleh commented 5 years ago

Hm, could be a broken runtime.js. Can you check if it works with this old runtime.js instead: https://github.com/danleh/wasabi/blob/937d5af674614f01f6ae21c3ddae35963c1fadcc/lib/runtime.js (i.e. replace lib/runtime.js with this file, rebuild Wasabi, rerun Wasabi instrumentation, rerun analysis)

danleh commented 5 years ago

The wasm streaming compile error looks like the import object given to the WebAssembly.instantiateStreaming() doesn't have a __wasabi_hooks property. Can you confirm that as the source of the issue?

Also some more details would be useful:

LFYSec commented 5 years ago

I tested the call-graph.js, and the console show me this message: asm streaming compile failed: TypeError: import object field '__wasabi_hooks' is not an Object test.html:1246:19 printErr http://127.0.0.1:8081/test.html:1246 instantiateAsync http://127.0.0.1:8081/test.js:1668 falling back to ArrayBuffer instantiation test.html:1246:19

start hook not provided by Wasabi.analysis, add empty function as fallback test.wasabi.js:142:25 if_ hook not provided by Wasabi.analysis, add empty function as fallback test.wasabi.js:142:25 ...

I use firefox,and use the example file:test_copy_taint_via_locals.c, and I use the default *.wasabi.js which generated by wasabi.But there still is some error like this.