[PR #6955] [MERGED] fix(apple): keep dyld candidates inside the analyzed root on Windows #7473

Closed
opened 2026-11-01 21:48:05 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6955
Author: @Adolanium
Created: 10/24/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @morluto

Base: main ← Head: fix/dylib-resolution-root-containment


📝 Commits (1)

  • e5b05cd fix(apple): keep dyld candidates inside the analyzed root on Windows

📊 Changes

3 files changed (+187 additions, -10 deletions)

View changed files

📝 docs/apple-application-analysis.md (+3 -0)
📝 src/artifacts/apple/DylibResolutionReader.ts (+37 -10)
📝 tests/boundary/mcp/dylibResolutionMcp.test.ts (+147 -0)

📄 Description

Summary

Fixes #6956.

On Windows hosts, trace_dylib_resolution mapped root-relative dyld paths to host paths with path.join, which treats \ as a separator. A dyld path component containing \ could therefore be normalized to a file outside the analyzed root, which was then opened, parsed and hashed as a candidate. This change keeps every candidate inside the analyzed root on Windows, as it already is on POSIX hosts.

Problem and expected behavior

Dyld path components are POSIX names: on macOS, \ and : are ordinary characters in a file name. On a Windows host, join(root, path) reads \ as a separator and : as a stream delimiter, so a load command or LC_RPATH value naming such a component does not denote a file in the analyzed tree. The same applies to symlink text read on Windows, which separates components with \.

Expected: a candidate that cannot name a file inside the analyzed root is absent, the documented containment (escapes-target for links that leave the root) holds on every host, and no file outside the root is read.

Change and scope

  • src/artifacts/apple/DylibResolutionReader.ts:
    • FilesystemTreeView.hostPath maps a root-relative path to its host path and refuses one that lands outside the root, before any file is opened. Entry probes, image reads (through main's DylibFileAccess) and the per-image digests all use it.
    • On Windows, a path containing \ or : is absent, since no file in the tree has that name.
    • On Windows, symlink text is split on \, so the existing escapes-target check sees its real components.
  • docs/apple-application-analysis.md states the Windows rule next to the existing symlink containment rule.

Not included: macOS and Linux behavior is unchanged; a POSIX file name containing \ still resolves there.

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.

Contribution scope: not applicable. This is a fix inside the existing artifact-reading boundary.

Contract and boundary impact

  • Semantic owner and earliest changed stage: FilesystemTreeView in DylibResolutionReader.ts, where root-relative dyld paths become host paths.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: no schema change. On Windows, candidates whose components contain \ or : report absent.
  • Provider, bridge, target-format, or platform compatibility: Windows hosts only; macOS and Linux unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: candidate paths and digests now always describe files inside the analyzed root.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): reads stay within the caller-selected root.
  • 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 (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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/mcp/dylibResolutionMcp.test.ts, through stdio MCP (open_binary, then trace_dylib_resolution), with a Mach-O dylib placed next to the analyzed directory:
    • "does not read outside the root through backslashes in Windows dyld names" (Windows only): load commands and an LC_RPATH whose components contain \. No candidate resolves to the outside file and its digest appears nowhere in the result.
    • "follows relative symlinks only while they stay inside the root": a link inside the root resolves, and a relative link leading out of it is escapes-target.
    • "resolves a POSIX file name that contains backslashes" (non-Windows): such a name still resolves on POSIX hosts.
  • Base reproduction or other evidence: on Windows, with src/artifacts/apple/DylibResolutionReader.ts from upstream/main and the new tests, the first two tests fail. With this change, they pass.
  • User-visible CLI/MCP output (if applicable): candidate outcomes on Windows, as described above.
  • Remaining proof gaps: no real macOS bundle on a Windows host; fixtures are synthetic Mach-O images.

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

At e5b05cda8 (on upstream/main bcd18d289):

  • Windows 11, Node 24.22.1 (Windows native artifact restored from the matching rea-agents@6.7.0 package, as native/windows/README.md describes), after npm run build:cached: tests/boundary/mcp/dylibResolutionMcp.test.ts passed in three runs (20 passed, 3 POSIX-only skipped), with the Windows test executed. The negative check above failed the two containment tests.
  • Linux (WSL Ubuntu, Node 24.22.1), after npm ci and npm run build:cached: npx tsc -p . --noEmit passed; oxfmt --check clean on the changed files; oxlint 1 warning on the changed source and test files, the same as on the base; npm run docs:check passed. npx vitest run tests/boundary/mcp/dylibResolutionMcp.test.ts src/artifacts/apple src/domain/apple in two runs: 458 passed, 1 skipped, with 2 failures (InterfaceBuilderDecodeBudget.test.ts "retains explicit date uncertainty for an overlapping binary plist object", keyedArchive.test.ts "enforces one traversal budget across root values") that fail the same way on the base bcd18d289.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: Windows 11 and Linux; macOS not run, its path is unchanged.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: reads stay inside the caller-selected root on Windows hosts.

Author readiness

Human owner: @Adolanium

  • 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/6955 **Author:** [@Adolanium](https://github.com/Adolanium) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/dylib-resolution-root-containment` --- ### 📝 Commits (1) - [`e5b05cd`](https://github.com/morluto/rea/commit/e5b05cda8d730a94d013572b7a4002f75e101a67) fix(apple): keep dyld candidates inside the analyzed root on Windows ### 📊 Changes **3 files changed** (+187 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `docs/apple-application-analysis.md` (+3 -0) 📝 `src/artifacts/apple/DylibResolutionReader.ts` (+37 -10) 📝 `tests/boundary/mcp/dylibResolutionMcp.test.ts` (+147 -0) </details> ### 📄 Description ## Summary Fixes #6956. On Windows hosts, `trace_dylib_resolution` mapped root-relative dyld paths to host paths with `path.join`, which treats `\` as a separator. A dyld path component containing `\` could therefore be normalized to a file outside the analyzed root, which was then opened, parsed and hashed as a candidate. This change keeps every candidate inside the analyzed root on Windows, as it already is on POSIX hosts. ## Problem and expected behavior Dyld path components are POSIX names: on macOS, `\` and `:` are ordinary characters in a file name. On a Windows host, `join(root, path)` reads `\` as a separator and `:` as a stream delimiter, so a load command or `LC_RPATH` value naming such a component does not denote a file in the analyzed tree. The same applies to symlink text read on Windows, which separates components with `\`. Expected: a candidate that cannot name a file inside the analyzed root is `absent`, the documented containment (`escapes-target` for links that leave the root) holds on every host, and no file outside the root is read. ## Change and scope - `src/artifacts/apple/DylibResolutionReader.ts`: - `FilesystemTreeView.hostPath` maps a root-relative path to its host path and refuses one that lands outside the root, before any file is opened. Entry probes, image reads (through main's `DylibFileAccess`) and the per-image digests all use it. - On Windows, a path containing `\` or `:` is `absent`, since no file in the tree has that name. - On Windows, symlink text is split on `\`, so the existing `escapes-target` check sees its real components. - `docs/apple-application-analysis.md` states the Windows rule next to the existing symlink containment rule. Not included: macOS and Linux behavior is unchanged; a POSIX file name containing `\` still resolves there. 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. Contribution scope: not applicable. This is a fix inside the existing artifact-reading boundary. ## Contract and boundary impact - Semantic owner and earliest changed stage: `FilesystemTreeView` in `DylibResolutionReader.ts`, where root-relative dyld paths become host paths. - Contribution scope fit and linked maintainer decision: not applicable. - CLI and MCP/tool-catalog contract: no schema change. On Windows, candidates whose components contain `\` or `:` report `absent`. - Provider, bridge, target-format, or platform compatibility: Windows hosts only; macOS and Linux unchanged. - Evidence, artifact, provenance, or reconstruction contract: candidate paths and digests now always describe files inside the analyzed root. - Target selection, authority, upstream behavior, and cleanup details (if applicable): reads stay within the caller-selected root. - 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 (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] 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/mcp/dylibResolutionMcp.test.ts`, through stdio MCP (`open_binary`, then `trace_dylib_resolution`), with a Mach-O dylib placed next to the analyzed directory: - "does not read outside the root through backslashes in Windows dyld names" (Windows only): load commands and an `LC_RPATH` whose components contain `\`. No candidate resolves to the outside file and its digest appears nowhere in the result. - "follows relative symlinks only while they stay inside the root": a link inside the root resolves, and a relative link leading out of it is `escapes-target`. - "resolves a POSIX file name that contains backslashes" (non-Windows): such a name still resolves on POSIX hosts. - Base reproduction or other evidence: on Windows, with `src/artifacts/apple/DylibResolutionReader.ts` from upstream/main and the new tests, the first two tests fail. With this change, they pass. - User-visible CLI/MCP output (if applicable): candidate outcomes on Windows, as described above. - Remaining proof gaps: no real macOS bundle on a Windows host; fixtures are synthetic Mach-O images. 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 At e5b05cda8 (on upstream/main bcd18d289): - Windows 11, Node 24.22.1 (Windows native artifact restored from the matching `rea-agents@6.7.0` package, as `native/windows/README.md` describes), after `npm run build:cached`: `tests/boundary/mcp/dylibResolutionMcp.test.ts` passed in three runs (20 passed, 3 POSIX-only skipped), with the Windows test executed. The negative check above failed the two containment tests. - Linux (WSL Ubuntu, Node 24.22.1), after `npm ci` and `npm run build:cached`: `npx tsc -p . --noEmit` passed; `oxfmt --check` clean on the changed files; `oxlint` 1 warning on the changed source and test files, the same as on the base; `npm run docs:check` passed. `npx vitest run tests/boundary/mcp/dylibResolutionMcp.test.ts src/artifacts/apple src/domain/apple` in two runs: 458 passed, 1 skipped, with 2 failures (`InterfaceBuilderDecodeBudget.test.ts` "retains explicit date uncertainty for an overlapping binary plist object", `keyedArchive.test.ts` "enforces one traversal budget across root values") that fail the same way on the base bcd18d289. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: Windows 11 and Linux; macOS not run, its path is unchanged. - Package or release metadata impact: none. - Security, privacy, process, or containment review: reads stay inside the caller-selected root on Windows hosts. ## Author readiness <!-- The human owner completes these declarations before requesting review. The PR author is the owner by default. A different owner must explicitly accept ownership on this PR. AI agents must leave these declarations to a human to dictate to them or there could be catastrophic consequences for many users of REA. Draft PRs may leave them unchecked. These declarations record initial readiness when opening the PR for review; later pushes do not require a new human sign-off. Keep the description and validation evidence current as the work changes. See CONTRIBUTING.md#pull-request-ownership-and-readiness. --> Human owner: @Adolanium - [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 <!-- Draft PRs may leave pending items unchecked. Resolve material scope and authority questions before integration. --> - [ ] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:48:05 +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#7473
No description provided.