WebAssembly Binary Analysis with WABT

WebAssembly Binary Analysis with WABT

WABT exposes WebAssembly sections, imports, exports and structured control flow without forcing a PE/ELF analysis model onto WASM.

A .wasm file is neither PE nor ELF, but it is not opaque. The most reusable reverse-engineering habit is to separate layers: container structure, import/export contract and instruction flow.

WABT provides a compact toolchain for that workflow.

WASM is not a native executable

WebAssembly uses a stack-based virtual instruction set. A runtime validates the module and may interpret or JIT-compile it. Native instruction addresses are therefore not the first abstraction to inspect.

Magic and version

A WebAssembly module starts with:

00 61 73 6d

followed by a version field. This basic signature is useful in triage and carving before deeper parsing.

wasm-objdump as first pass

I use wasm-objdump to inspect sections, imports, exports, tables, memory and code size. Imports are particularly informative because they show which capabilities the host environment exposes to the module.

Why wasm2wat helps

wasm2wat converts the binary into WebAssembly Text Format. WAT is not recovered source code, but it makes the stack machine and structured block, loop, if, br and call flow easier to follow.

Structured control flow

WebAssembly branches target structured labels rather than arbitrary native addresses. That changes control-flow reconstruction and makes some static reasoning simpler, although indirect calls still require table analysis.

Imports show part of the attack surface

A module obtains filesystem, network or other external capabilities through its host environment. I therefore treat imports as a capability boundary during reverse engineering.

Custom sections matter

Custom sections may contain names, debug information or tool metadata. They are not required for execution but can be valuable evidence.

Validation is not security analysis

A valid WASM module satisfies structural and type rules. It can still implement malicious or vulnerable logic. Format validation answers a narrower question than behavioral security.

wasm2c as an analysis bridge

Translating WASM to C can make existing C analysis tools useful, but it should not be confused with recovering the original source.

Small toolchain first

For triage I prefer:

hex/file identification
→ wasm-objdump
→ wasm2wat
→ targeted runtime observation

before adding heavier instrumentation.

References

  • W3C WebAssembly Core Specification
  • WebAssembly Binary Toolkit (WABT) repository and releases
QR code for this page