Skip to content

fix(contracts): reject OS-invalid local paths in binary and artifact tools - #1925

Merged
morluto merged 2 commits into
morluto:mainfrom
viniciusdsandrade:fix/contracts-local-tool-path-validation
Oct 12, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
viniciusdsandrade:fix/contracts-local-tool-path-validation

Conversation

@viniciusdsandrade

@viniciusdsandrade viniciusdsandrade commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Enforce localPathStringSchema across inspect_pe_resources, inspect_binary_layout, inspect_recorded_crash, inspect_wasm_artifact, and inspect_evm_interface so OS-invalid paths containing NUL bytes (\x00) are rejected at the advertised schema contract boundary instead of propagating to filesystem operations or throwing untyped errors. export_web_scripts received the same change in #1899, so this branch no longer touches it.

Problem and expected behavior

Previously, these input schemas typed local filesystem path arguments using z.string().min(1). When callers or agents passed paths containing embedded NUL bytes (e.g. /tmp/selected\0filename), the inputs passed schema validation and reached backend services/subprocesses, risking raw filesystem exceptions or unhandled failures. Expected behavior is to reject them at the contract boundary with a typed schema error ("Local filesystem paths cannot contain NUL"), consistent with existing local path tools.

Change and scope

  • Use localPathStringSchema from localPath.ts for:
    • inspect_pe_resources (path)
    • inspect_binary_layout (path)
    • inspect_recorded_crash (path)
    • inspect_wasm_artifact (path, glue_paths, candidate_paths)
    • inspect_evm_interface (path)
  • Add test coverage for all updated tools in tests/acceptance/tools/localToolContracts.test.ts under the real advertised MCP contracts test matrix.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Input schema validation in domain layers (native/peResources, native/binaryLayout, native/recordedCrash, wasm/wasmArtifact, evm/evmInterface).
  • CLI and MCP/tool-catalog contract: Rejects strings containing NUL bytes for local path parameters on these 5 tools; valid paths remain unchanged.
  • Provider, bridge, target-format, or platform compatibility: Cross-platform consistency across POSIX and Windows filesystem boundaries.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Process execution, authorization, cleanup, or containment impact: Prevents execution of subprocesses or filesystem operations with invalid NUL paths.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: tests/acceptance/tools/localToolContracts.test.ts added test cases for inspect_pe_resources, inspect_binary_layout, inspect_recorded_crash, inspect_wasm_artifact, and inspect_evm_interface.
  • Base reproduction or other evidence: Calling these tools with NUL paths previously passed schema validation.
  • User-visible CLI/MCP output (if applicable): Returns standard schema error with "Local filesystem paths cannot contain NUL".
  • Remaining proof gaps: none.

For evidence-bearing changes:

  • 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

  • node --experimental-strip-types --check on touched domain and test files passed without errors.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Only inputs with invalid NUL bytes (which are unusable by OS filesystems) are rejected.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: Eliminates NUL byte path handling bugs at boundary.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 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-11T22:49:33.027650Z 29ef57b New commits
ℹ️ 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.

@baron baron left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source verdict: APPROVE at exact head 7c9f33fbafc0e99685fe5c91ce1c2ac3c3186bfe (PR base / reviewed merge base dfe31172ca0a090be3f40bc134f54d69c08e31d8). No concrete changed-source defects found.

Reviewed the complete seven-file diff and canonical contracts, CLI normalization, MCP registrations, shared validation, and Evidence consumers. The existing localPathStringSchema adds only NUL rejection to nonempty strings: it does not trim, resolve, redact, or reinterpret caller-selected paths. Host-native absolute-path validation remains in the application owner. WASM main/glue/candidate selections and both web-export paths are covered; defaults, array bounds, output schemas, provenance, and resource ownership remain unchanged. Reusing the established domain boundary avoids downstream exception patches or duplicate representations.

Changed-source anchors: src/domain/native/peResources.ts:19-21, src/domain/native/binaryLayout.ts:20-22, src/domain/native/recordedCrash.ts:54-56, src/domain/evm/evmInterface.ts:10-12, src/domain/wasm/wasmArtifact.ts:13-17, src/domain/webScriptExport.ts:10-15; regression matrix tests/acceptance/tools/localToolContracts.test.ts:94-108.

Validation on macOS in an isolated detached clone, Node 24.18.0 / npm 11.16.0:

  • Locked dependency installation, focused runtime/catalog build, npm run typecheck, and diff whitespace check passed.
  • Nine-file focused run: 15 passed / 5 failed. The changed real-stdio MCP NUL matrix passed. Eight advertised-schema tests, four injected-provider MCP tests preserving inline Evidence/session identity, and the MCP nonregular-capture test passed.
  • Failures are disclosed, not counted as passes: three unrelated process-capture cases returned PTY spawn EPERM; PE resources acceptance timed out at 30 seconds and web-script CLI selection exceeded its existing 5-second deadline. The latter two remain unresolved local validation gaps, not proven PR-caused regressions; no baseline comparison, retries, or timeout inflation was performed.
  • Additional compiled-contract probe: 72 exact-value preservation assertions (Unicode, whitespace, line breaks, punctuation, Windows-shaped paths) and 36 NUL rejection assertions passed across all nine changed fields. Windows-shaped schema strings do not establish native Windows filesystem behavior.

Not run locally: full gate, docs checks, real WABT/pwntools/pwndbg/EVM/provider lanes, or native Windows validation. Injected-provider boundary tests are not real-provider proof.

Hosted CI and integration readiness are independent: the latest pre-publication snapshot has successful static/build/docs/coverage and all four test shards, with Apple E2E and two Darwin package lanes still queued. GitHub reports MERGEABLE / UNSTABLE. This source approval is not a complete green local/hosted gate or merge authorization. Main was preserved; no fixes, commits, pushes, merges, or draft changes.

@baron baron added area: domain Domain logic, errors, and pure functions area: mcp MCP server, transport, and tool registration area: tests Test suite and verification bug Something isn't working labels Oct 11, 2026
@CassieFox23

CassieFox23 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: On Linux the PR works. Every NUL path is now rejected at the schema, in all six tools. The two tests that timed out on macOS pass here, on this PR and on its base.

Results

I tested head 7c9f33f against its merge base dfe3117. Main has since moved to d802304 (#1902). The PR conflicts with it. I tested the head as it stands and did not try a merge.

Check Node 22.23.1 Node 24.18.0 Node 26.11.1
New NUL matrix (5 tests) pass pass pass
PE resources acceptance test pass, 8.9 s (1 run) pass, 7.1 to 7.6 s (3 runs) pass, 7.1 s (1 run)
Web-script CLI selection test pass, 1.0 s (1 run) pass, 0.83 to 0.92 s (3 runs) pass, 0.77 s (1 run)
Six related MCP files (13 tests) pass pass pass
  • Base needs the fix. I ran the PR's new test file against the base source. The NUL matrix fails at its first row. The other four tests in the file pass.
  • Fast suite on Node 24. On head, npm run test:fast ran 398 files. It passed 4,862 tests, skipped 3, and failed none.
  • baron's two timeouts. The PE test took 7.0 to 7.6 s against its 30 s limit. The CLI test took 0.80 to 0.92 s against its 5 s limit. I ran each three times on head and three times on base. None timed out, and base and head look the same. A cold start of the CLI takes about 0.8 s here.
  • Likely baron's set. Nine files together give 20 tests, the same count as baron's run. All 20 passed on Node 24 here. I guessed the file list from his counts, so it is unverified.

NUL paths over real MCP stdio

I started each build's own server and sent the nine requests from the PR's matrix. A shell argument cannot carry NUL, so the CLI cannot test this.

  • Head: all 9 return the schema error "Local filesystem paths cannot contain NUL". The error names the field, including glue_paths.0 and candidate_paths.0. Both export_web_scripts fields are covered too.
  • Base: all 9 return an error, but not a clean one. Five carry Node's null-bytes message, some only in the details. Three stop earlier on the missing WABT tool, so the NUL never reaches the path check. One stops on my missing capture file, so base is not shown for that field.

Valid paths changed nothing. I sent 8 requests to both builds. The responses were byte for byte the same. Three were real successes: a PE file, an ELF file and an EVM hex file. Five were errors that match on both builds. They were a missing core file, a missing capture file, and three WASM requests with no WABT.

Path fields the PR did not cover

The head build's schemas show eight more path inputs with no NUL pattern, across five tools. Two of three that I probed reached the file system on head. The PR names six tools, so this is a possible follow-up, not a flaw in this PR. The list is in the fold below.

Not run

  • The full suite and the CI gate.
  • Real WABT, so no WASM request ever succeeded.
  • Windows and macOS. I did not repeat baron's macOS result.
  • A merge of this head with current main.
  • NUL requests to the other tools.
  • baron's exact nine-file command, which I do not have.

Edit: the two struck items are now covered in a follow-up at the new head.

Thanks, baron, for the careful review and for naming the two unresolved timeouts.

Other path fields without the NUL pattern

I walked every tool's input schema in the head build. The PR adds the pattern to the nine fields it names and changes nothing else. These file-path inputs still lack it:

  • inspect_keyed_archive: path
  • trace_web_module_imports: manifest_path, import_map.path
  • trace_web_source_location: manifest_path, source_map.path
  • inspect_web_network_capture: capture_path
  • compare_javascript_export_shapes: left_module_path, right_module_path

The last pair may be module names, not files. I did not check.

I sent NUL to three of these on head. Two reached the file system. Each returned a plain failure with Node's null-bytes note. The third stopped at "No app is open", so its path was never reached.

Base results for the nine NUL requests
  • PE resources, path: file error with Node's null-bytes note.
  • Binary layout, path: run failure, Node note in the details.
  • Recorded crash, path: run failure, Node note in the details.
  • WASM, path: tool error, WABT not set.
  • WASM, glue paths: tool error, WABT not set.
  • WASM, candidate paths: tool error, WABT not set.
  • EVM interface, path: run failure, Node note in the details.
  • Web export, capture path: file error with Node's null-bytes note.
  • Web export, output directory: bad request, because my capture file did not exist.
Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1 (built once on 24.18.0, npm 11.16.0)
  • Head / base: 7c9f33f / dfe3117
  • Other: the box was shared with other test runs, so treat all timings as rough. The load average (tasks wanting a CPU, on 24 threads) read 7.2 after the runs.
Commands
# one file at a time, per Node
node node_modules/vitest/vitest.mjs run --project acceptance tests/acceptance/tools/localToolContracts.test.ts
node node_modules/vitest/vitest.mjs run --project acceptance tests/acceptance/applications/peResources.test.ts
node node_modules/vitest/vitest.mjs run --project cli-boundary tests/boundary/cli/webScriptSelectionCli.test.ts
npm run test:fast
# NUL probe: starts the build's own server and calls each tool
node probe.mjs nul out.json
node probe.mjs valid out.json

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@viniciusdsandrade
viniciusdsandrade force-pushed the fix/contracts-local-tool-path-validation branch from 039c7b3 to b354b9b Compare October 11, 2026 21:54
…tools

Enforce localPathStringSchema across inspect_pe_resources,
inspect_binary_layout, inspect_recorded_crash, inspect_wasm_artifact,
and inspect_evm_interface input schemas to reject embedded NUL bytes at
the contract boundary instead of failing later during filesystem
operations.

Add corresponding acceptance test cases to the advertised MCP contracts
matrix in localToolContracts.test.ts.

Signed-off-by: Vinícius DS Andrade <[email protected]>
Wrap the inspectPeResourcesInputSchema path property description to keep lines within the 80-column oxfmt limit.

Signed-off-by: Vinícius DS Andrade <[email protected]>
@viniciusdsandrade
viniciusdsandrade force-pushed the fix/contracts-local-tool-path-validation branch from b354b9b to 29ef57b Compare October 11, 2026 22:47
@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: Yes. This PR now refuses a NUL byte in all seven fields of its five tools, and #1899 covers five of the eight from my earlier note. Four fields in three tools still accept a NUL byte, but none returned Node's null-bytes error.

Results

I tested head 29ef57b against its base 89f5e48 (#1972). The PR was rebased since my last post. #1899 is now in the base, so this PR no longer touches export_web_scripts. I sent NUL bytes over real MCP stdio, to each build's own server. This time I supplied WABT 1.0.42, so the three WASM rows are real on both builds. Refused means a schema error that says paths cannot contain NUL.

Tool Fields Base Head Clean path on head
inspect_pe_resources path Node error refused real result
inspect_binary_layout path Node error refused real result
inspect_recorded_crash path Node error refused file not found
inspect_evm_interface path Node error refused real result
inspect_wasm_artifact path, glue_paths, candidate_paths Node error, 3 of 3 refused, 3 of 3 real result, 3 of 3
export_web_scripts capture_path, output_directory refused refused file not found
trace_web_module_imports manifest_path, import_map.path refused refused file not found
trace_web_source_location manifest_path, source_map.path refused refused file not found
inspect_web_network_capture capture_path refused refused file not found
inspect_keyed_archive path accepted accepted file read
compare_javascript_export_shapes left_module_path, right_module_path accepted accepted real result
analyze_javascript_application source_paths accepted accepted real result
  • Fixed here. The seven fields of this PR go from Node's null-bytes error to a clean refusal. The web rows match on base and head, because fix(web): reject NUL bytes in web tool local path inputs #1899 fixed them first.
  • Still accepted: four fields. Three are left from my earlier note. source_paths is new. The last three tools look a name up in an app bundle, an Evidence graph or a file inventory. Given a NUL byte, the keyed archive says "No regular file exists". The export shapes say "No exact export binding matched". The file inventory says "Select an exact relevant file path". I read the keyed archive and export shape code. I did not read the source_paths code.
  • Tests. The PR's localToolContracts.test.ts passes 5 of 5 on Node 22.23.1, 24.18.0 and 26.11.1. Against the base source, its NUL test fails at the first new row, inspect_pe_resources.
  • Clean paths. Base and head gave identical answers for all 18 clean-path requests.

Still not run

  • A real core file, so the crash row shows file not found only.
  • A real web export manifest, capture or source map, so the web rows show file not found only.
  • A real macOS app bundle for inspect_keyed_archive. My fake bundle opened as a Linux program.
  • The full suite, CI, Windows and macOS. No checks had reported on this head yet.
  • Path-like strings inside Evidence inputs, such as the entries in compare_source_to_bundle. I saw them in the schemas and sent no NUL byte to them.

Thanks, Vinícius, for the quick follow-up, and DeryFerd, for #1899.

Commands
# per tree, Node 24.18.0
npm ci && npm run build && npm run test:prepare
# probes: start the tree's own server, call each tool (sets: nul, web, control)
PROBE_WABT=1 node probe.mjs nul out.json
# the PR's test file, per Node
node node_modules/vitest/vitest.mjs run --project acceptance tests/acceptance/tools/localToolContracts.test.ts
# schema walk over each build's tool list
python3 walkschemas.py tools-head.json
Test setup

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@morluto
morluto merged commit 976c2c0 into morluto:main Oct 12, 2026
2 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions area: mcp MCP server, transport, and tool registration area: tests Test suite and verification bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants