[PR #3606] [MERGED] fix(contracts): reject NUL bytes in keyed archive and extraction paths #5851

Closed
opened 2026-10-31 01:09:55 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3606
Author: @qorvr
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @morluto

Base: main ← Head: fix/contracts-keyed-archive-extraction-paths


📝 Commits (1)

  • 5880639 fix(contracts): reject NUL bytes in keyed archive and extraction paths

📊 Changes

2 files changed (+4 additions, -2 deletions)

View changed files

📝 src/contracts/artifactToolContracts.ts (+2 -1)
📝 src/domain/apple/keyedArchive.ts (+2 -1)

📄 Description

Summary

Ensures advertised and execution contracts for inspect_keyed_archive and extract_artifact reject NUL bytes in path inputs, aligning with established local tool contract boundaries.

Problem and expected behavior

  • In src/domain/apple/keyedArchive.ts, keyedArchiveInputSchema.path used z.string().min(1).default(".") instead of localPathStringSchema.default(".").
  • In src/contracts/artifactToolContracts.ts, artifactExtractionExecutionSchema.output_root used z.string().min(1) instead of localPathStringSchema.
  • Passing paths containing NUL bytes (\0) bypassed schema validation and subsequently triggered low-level Node runtime TypeError [ERR_INVALID_ARG_VALUE] exceptions during archive and directory processing.
  • Expected behavior: Reject strings containing NUL bytes cleanly at the contract schema boundary with a descriptive validation error.

Change and scope

  • Route keyedArchiveInputSchema.path and artifactExtractionExecutionSchema.output_root through localPathStringSchema.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: keyedArchiveInputSchema in src/domain/apple/keyedArchive.ts and artifactExtractionExecutionSchema in src/contracts/artifactToolContracts.ts.
  • Contribution scope fit and linked maintainer decision: not applicable (existing boundaries and contract hardening).
  • CLI and MCP/tool-catalog contract: inspect_keyed_archive and extract_artifact path input validation.
  • Provider, bridge, target-format, or platform compatibility: all platforms.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/filesystem/keyedArchiveSelection.test.ts.
  • Base reproduction or other evidence: passing paths with \0 bypassed schema parsing and failed during internal filesystem access with raw Node ERR_INVALID_ARG_VALUE.
  • User-visible CLI/MCP output (if applicable): MCP validation error describing invalid path character instead of unhandled runtime error.
  • 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

  • npx oxfmt --check . — all matched files passed formatting check.
  • npm run typecheck — 0 errors.
  • npm run check:fast — turbo typecheck, lint passed cleanly.
  • npx vitest run tests/boundary/filesystem/keyedArchiveSelection.test.ts tests/boundary/mcp/keyedArchiveNumberMetadataMcp.test.ts — 32 passed (100%).

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: local file contracts across Linux/macOS/Windows.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: Prevents NUL-byte injection in path inputs across artifact tools.

Author readiness

Human owner: @qorvr

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • 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/3606 **Author:** [@qorvr](https://github.com/qorvr) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/contracts-keyed-archive-extraction-paths` --- ### 📝 Commits (1) - [`5880639`](https://github.com/morluto/rea/commit/5880639668991dd8746893e0934b745c6ca81e5e) fix(contracts): reject NUL bytes in keyed archive and extraction paths ### 📊 Changes **2 files changed** (+4 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/contracts/artifactToolContracts.ts` (+2 -1) 📝 `src/domain/apple/keyedArchive.ts` (+2 -1) </details> ### 📄 Description ## Summary Ensures advertised and execution contracts for `inspect_keyed_archive` and `extract_artifact` reject NUL bytes in path inputs, aligning with established local tool contract boundaries. ## Problem and expected behavior - In `src/domain/apple/keyedArchive.ts`, `keyedArchiveInputSchema.path` used `z.string().min(1).default(".")` instead of `localPathStringSchema.default(".")`. - In `src/contracts/artifactToolContracts.ts`, `artifactExtractionExecutionSchema.output_root` used `z.string().min(1)` instead of `localPathStringSchema`. - Passing paths containing NUL bytes (`\0`) bypassed schema validation and subsequently triggered low-level Node runtime `TypeError [ERR_INVALID_ARG_VALUE]` exceptions during archive and directory processing. - Expected behavior: Reject strings containing NUL bytes cleanly at the contract schema boundary with a descriptive validation error. ## Change and scope - Route `keyedArchiveInputSchema.path` and `artifactExtractionExecutionSchema.output_root` through `localPathStringSchema`. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Unresolved scope, authority, side effects, or required verification block integration. Link the required maintainer scope decision for new providers or capabilities involving target execution, injection, mutation, or protection recovery; ordinary fixes within existing boundaries may state "not applicable". Draft PRs may leave the scope decision pending and the readiness and merge checklists unchecked. Maintainers can help resolve open questions. ## Contract and boundary impact - Semantic owner and earliest changed stage: `keyedArchiveInputSchema` in `src/domain/apple/keyedArchive.ts` and `artifactExtractionExecutionSchema` in `src/contracts/artifactToolContracts.ts`. - Contribution scope fit and linked maintainer decision: not applicable (existing boundaries and contract hardening). - CLI and MCP/tool-catalog contract: `inspect_keyed_archive` and `extract_artifact` path input validation. - Provider, bridge, target-format, or platform compatibility: all platforms. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details (if applicable): none. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact (CI generates and validates ignored catalogs and `skills/`; edit authored instructions in `.agents/skills/reverse-engineer-anything/` and never commit build outputs): none. Expected effects: - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [x] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `tests/boundary/filesystem/keyedArchiveSelection.test.ts`. - Base reproduction or other evidence: passing paths with `\0` bypassed schema parsing and failed during internal filesystem access with raw Node `ERR_INVALID_ARG_VALUE`. - User-visible CLI/MCP output (if applicable): MCP validation error describing invalid path character instead of unhandled runtime error. - 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 - `npx oxfmt --check .` — all matched files passed formatting check. - `npm run typecheck` — 0 errors. - `npm run check:fast` — turbo typecheck, lint passed cleanly. - `npx vitest run tests/boundary/filesystem/keyedArchiveSelection.test.ts tests/boundary/mcp/keyedArchiveNumberMetadataMcp.test.ts` — 32 passed (100%). ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: local file contracts across Linux/macOS/Windows. - Package or release metadata impact: none. - Security, privacy, process, or containment review: Prevents NUL-byte injection in path inputs across artifact tools. ## Author readiness Human owner: @qorvr - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [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 01:09:55 +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#5851
No description provided.