[PR #1925] [MERGED] fix(contracts): reject OS-invalid local paths in binary and artifact tools #4914

Closed
opened 2026-10-31 00:56:43 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1925
Author: @viniciusdsandrade
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/12/2026
Merged by: @morluto

Base: main ← Head: fix/contracts-local-tool-path-validation


📝 Commits (2)

  • b7f4ba3 fix(contracts): reject OS-invalid local paths in binary and artifact tools
  • 29ef57b style(contracts): wrap pe resources path description under print width

📊 Changes

6 files changed (+35 additions, -19 deletions)

View changed files

📝 src/domain/evm/evmInterface.ts (+5 -4)
📝 src/domain/native/binaryLayout.ts (+4 -4)
📝 src/domain/native/peResources.ts (+5 -1)
📝 src/domain/native/recordedCrash.ts (+4 -4)
📝 src/domain/wasm/wasmArtifact.ts (+7 -6)
📝 tests/acceptance/tools/localToolContracts.test.ts (+10 -0)

📄 Description

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1925 **Author:** [@viniciusdsandrade](https://github.com/viniciusdsandrade) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/12/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/contracts-local-tool-path-validation` --- ### 📝 Commits (2) - [`b7f4ba3`](https://github.com/morluto/rea/commit/b7f4ba304723ae5ec8929ebcef3d048e0e52bad3) fix(contracts): reject OS-invalid local paths in binary and artifact tools - [`29ef57b`](https://github.com/morluto/rea/commit/29ef57b35c86eebe4a072926dd02b88d775d5df4) style(contracts): wrap pe resources path description under print width ### 📊 Changes **6 files changed** (+35 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/evm/evmInterface.ts` (+5 -4) 📝 `src/domain/native/binaryLayout.ts` (+4 -4) 📝 `src/domain/native/peResources.ts` (+5 -1) 📝 `src/domain/native/recordedCrash.ts` (+4 -4) 📝 `src/domain/wasm/wasmArtifact.ts` (+7 -6) 📝 `tests/acceptance/tools/localToolContracts.test.ts` (+10 -0) </details> ### 📄 Description ## 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: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] 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 - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:56:43 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4914
No description provided.