WebAssembly / WebAssembly/binaryen

String escaping fuzz bug with wasm-metadce

Open
#8,482 7 comments 0 reactions 1 assignee View on GitHub

@kripken is already working on this.

Since Mar 20, 2026.

Dominant language
WebAssembly
Stars
8.6k
Forks
885
Avg merge
1d 19h
Merged PRs (30d)
69

Description

This is a fuzz bug where the fuzzer runs the CtorEval handler with test/lit/basic/name-high-bytes.wast as its initial contents.

test.wast (reduced):

(module
 (type $0 (func))
 (export "test\\c3\\a9_invoker" (func $0))
 (func $0 (type $0)
  (unreachable)
 )
)

graph.json produced by fuzz_opt.py's filter_exports (reduced):

[
  {
    "name": "outside",
    "reaches": ["export-test\\\\c3\\\\a9_invoker"],
    "root": true
  },
  {
    "name": "export-test\\\\c3\\\\a9_invoker",
    "export": "test\\\\c3\\\\a9_invoker"
  }
]

Here we have an export name containing backslashes. Note that they are escaped in the Wasm text format, so the actual unescaped byte content of the export name is test\c3\a9_invoker. But fuzz_opt.py is not unescaping the string it reads from the disassembly, and then it is JSON-encoding the escaped name, so graph.json ends up with doubly escaped backslashes.

To make matters worse, wasm-metadce is parsing the input JSON in "ASCII" mode, which does not do any unescaping either. So wasm-metadce is rooting an export named test\\\\c3\\\\a9_invoker but in fact the export's name is test\c3\a9_invoker, so the export is removed and the filtered module is empty.

This causes the fuzzer to fail when it later runs wasm-ctor-eval and passes it --kept-exports=test\c3\a9_invoker (note that it has unescaped the string for this step). This errors out because that export no longer exists.

IIUC, the proper fix would be to 1) perform Wasm text format unescaping immediately when extracting export names in get_exports, and 2) perform JSON unescaping when parsing the JSON in wasm-metadce.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.