Skip to content

fix(wasm): preserve leading BOM in custom section names - #2102

Merged
morluto merged 1 commit into
morluto:mainfrom
1052326311:fix/wasm-custom-name-bom
Oct 12, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
1052326311:fix/wasm-custom-name-bom

Conversation

@1052326311

Copy link
Copy Markdown
Contributor

Summary

Preserve leading U+FEFF in WABT custom-section names so valid WASM modules return Evidence instead of unreadable_output.

No existing issue covers this specific decoding error. Searches for WabtWat, WABT BOM, and custom-section names found the already merged NUL-display fix #1981 and debug-name fix #1967; neither preserves leading U+FEFF during custom-name decoding.

Problem and expected behavior

Compile this valid fixture with WABT 1.0.42 wat2wasm --enable-all:

(module (@custom "\ef\bb\bfname" "payload"))

WASM names are length-delimited UTF-8. U+FEFF is part of the name, not stream framing. TextDecoder currently removes it, turning the name into the special name section and attempting to parse arbitrary payload as debug metadata. The real CLI returns unreadable_output with Incomplete WABT name-section metadata.. Other leading-U+FEFF names disagree with the exact objdump header and are also rejected.

Expected: preserve the complete name and return the original producer output and Evidence.

Change and scope

Use ignoreBOM: true for custom names, matching the existing module-name decoder. Extend the existing producer fixture and CLI/MCP verifier for leading U+FEFF, U+FEFF followed by name, and U+FEFF-only versus empty names. Retain fatal UTF-8 decoding and existing framing, range, NUL-display and actual debug-name controls.

Contract and boundary impact

  • Semantic owner and earliest changed stage: parseWabtWat, decoding length-delimited custom names.
  • CLI and MCP/tool-catalog contract: unchanged schemas; valid modules previously rejected now return Evidence.
  • Provider, bridge, target-format, or platform compatibility: existing WABT 1.0.42 profile.
  • Evidence, artifact, provenance, or reconstruction contract: retain exact names, original WAT, header/details text, digests and section extents.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: one focused parser regression plus existing custom-names.wat and real-tool verifier expectations. Invalid UTF-8 remains rejected.

  • Base reproduction: on main 79156e5bed1d72b83ade0483246f457b337b7e59, the new parser regression fails (11 controls pass). The compiled real-tool lane also fails at the CLI result for the expanded custom-name fixture, despite successful WABT validation.

  • User-visible CLI/MCP output: before, unreadable_output / Incomplete WABT name-section metadata.; after, both surfaces return equal Evidence with descriptions retaining U+FEFF. The verifier checks unmodified bytes, exact WAT/header/detail output, digests, and retained evidence bundles.

  • Remaining proof gaps: no Windows/Linux execution or full deterministic suite; hosted CI remains separate.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Executed on macOS arm64 with Node 24.18.0, npm 11.16.0 and upstream WABT 1.0.42 (release archive SHA-256 verified):

  • npm run test:local -- src/wasm/WabtOutput.test.ts src/wasm/WabtArtifactProvider.test.ts src/application/wasm/WasmArtifactService.test.ts - 32 tests passed.
  • REA_WABT_BIN_DIRECTORY=<absolute WABT bin> npm run verify:wasm:artifact -- --require-tools - 42 cases passed through compiled CLI and stdio MCP, including valid and malformed modules.
  • npm run check - all six tasks and architecture guards passed. An earlier attempt stopped on the build command lock before checks ran; the sequential retry completed.
  • git diff --check - passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: real WABT on macOS arm64; other providers not involved.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new authority; fatal UTF-8 decoding and exact output framing remain enforced.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and a conventional title.
  • Reason for not linking an issue is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs and contracts are updated where needed; schemas are unchanged.
  • User-visible CLI/MCP changes include representative output.
  • Final diff checked for secrets, unrelated cleanup, and unsupported claims. Pre-commit also removed one redundant quote escape in an existing test string without changing its value.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T08:27:33.288709Z e800a2c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@morluto
morluto merged commit abc8c6d into morluto:main Oct 12, 2026
31 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants