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 6dfollowed 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.
Section sizes and function counts help identify where the module concentrates code and data. Imported functions are indexed alongside defined functions, so index interpretation must include the import count. Exported names describe an interface; they need not preserve the original program's internal structure.
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.
Recovered names may come from optional metadata, while stripped modules may expose only indices. WAT makes instructions readable without reconstructing source-level types, comments or original abstractions. Maintain the original binary as the evidence object and record tool versions for derived representations.
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.
An indirect call depends on table contents and the relevant type constraints. Static inspection should therefore relate table initialization and updates to the call sites. Linear-memory accesses also need analysis of address calculations and bounds behavior; structured branching does not remove memory-related application errors.
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.
Capability assessment must include the host's implementation of imports and any runtime-specific interfaces. An import name alone does not prove which files or network resources are reachable. Conversely, a small import set can expose broad capability if the host implements a powerful dispatcher.
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 observationbefore adding heavier instrumentation.
Dynamic observation can focus on one input and one suspected behavior after static triage. Use an isolated environment with explicitly restricted host capabilities and preserve input/output traces. A successful validation step establishes module-format validity, not the safety of executing its logic. Tool feature support should match the module's WebAssembly features before interpreting a validation error as evidence of corruption.
References