[PR #6272] [MERGED] fix(environment): refuse UNC pathname in file:// URI before fileURLToPath #7246

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6272
Author: @ithis0623-png
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @morluto

Base: main ← Head: fix/network-share-file-uri-refusal


📝 Commits (1)

  • f710ee6 fix(environment): refuse UNC pathname in file:// URI before fileURLToPath

📊 Changes

1 file changed (+1 additions, -0 deletions)

View changed files

📝 src/server/environment/stateIntake.ts (+1 -0)

📄 Description

Summary

Refuse UNC pathnames in file:// URIs as network shares before calling Node's fileURLToPath.

Problem and expected behavior

When a file:// URI contains leading slashes representing a UNC path (such as file:////remote.example.test/share/state.json), Node's fileURLToPath on Windows throws ERR_INVALID_FILE_URL_PATH because Windows paths expect a drive letter or standard absolute path. The exception handler caught this and returned "invalid params: a file:// uri names a local absolute path" instead of the intended "invalid params: a file:// uri names a path on this host, not a network share", causing src/server/environment/serveEnvironmentState.test.ts to fail on Windows.

Change and scope

Check UNC_PATH.test(url.pathname) before calling fileURLToPath in localFilePath (src/server/environment/stateIntake.ts). This ensures UNC paths with leading slashes (//... or \\...) are consistently recognized and refused as network shares across all platforms.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/server/environment/stateIntake.ts
  • Contribution scope fit and linked maintainer decision: not applicable (existing input validation bug fix)
  • CLI and MCP/tool-catalog contract: none
  • Provider, bridge, target-format, or platform compatibility: Windows and POSIX parity
  • 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: none

Expected effects:

  • Documentation or usability only; no target interaction.

Evidence and regression coverage

  • Tests added or updated: src/server/environment/serveEnvironmentState.test.ts (existing test opens file uris only on this host, refusing another host or a network share before opening anything now passes on Windows)
  • Base reproduction or other evidence: On Windows without this fix, fileURLToPath(new URL("file:////remote.example.test/share/state.json")) threw ERR_INVALID_FILE_URL_PATH, triggering the local absolute path error instead of the network share error.
  • User-visible CLI/MCP output (if applicable): not applicable
  • 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

  • npm.cmd run test:local -- src/server/environment/serveEnvironmentState.test.ts ? 23 passed (23)
  • npm.cmd run check:fast ? 2 successful, 0 errors (typecheck + lint)
  • npm.cmd run format:check ? all matched files use correct format (oxfmt)
  • npm.cmd run verify:architecture-guards ? passed across 1760 source files
  • npm.cmd run verify:module-boundaries ? passed across 2543 source files

Compatibility, safety, and release

  • Breaking changes or migration steps: none
  • Real Hopper/Ghidra, browser, or OS coverage: Windows x64 tested
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: preserves and enforces network share boundary

Author readiness

Human owner: @ithis0623-png

  • 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/6272 **Author:** [@ithis0623-png](https://github.com/ithis0623-png) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/network-share-file-uri-refusal` --- ### 📝 Commits (1) - [`f710ee6`](https://github.com/morluto/rea/commit/f710ee6feca09f4dac3388f8ac0796cfd5a13f0c) fix(environment): refuse UNC pathname in file:// URI before fileURLToPath ### 📊 Changes **1 file changed** (+1 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/server/environment/stateIntake.ts` (+1 -0) </details> ### 📄 Description ## Summary Refuse UNC pathnames in `file://` URIs as network shares before calling Node's `fileURLToPath`. ## Problem and expected behavior When a `file://` URI contains leading slashes representing a UNC path (such as `file:////remote.example.test/share/state.json`), Node's `fileURLToPath` on Windows throws `ERR_INVALID_FILE_URL_PATH` because Windows paths expect a drive letter or standard absolute path. The exception handler caught this and returned `"invalid params: a file:// uri names a local absolute path"` instead of the intended `"invalid params: a file:// uri names a path on this host, not a network share"`, causing `src/server/environment/serveEnvironmentState.test.ts` to fail on Windows. ## Change and scope Check `UNC_PATH.test(url.pathname)` before calling `fileURLToPath` in `localFilePath` (`src/server/environment/stateIntake.ts`). This ensures UNC paths with leading slashes (`//...` or `\\...`) are consistently recognized and refused as network shares across all platforms. ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/server/environment/stateIntake.ts` - Contribution scope fit and linked maintainer decision: not applicable (existing input validation bug fix) - CLI and MCP/tool-catalog contract: none - Provider, bridge, target-format, or platform compatibility: Windows and POSIX parity - 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: none Expected effects: - [x] Documentation or usability only; no target interaction. ## Evidence and regression coverage - Tests added or updated: `src/server/environment/serveEnvironmentState.test.ts` (existing test `opens file uris only on this host, refusing another host or a network share before opening anything` now passes on Windows) - Base reproduction or other evidence: On Windows without this fix, `fileURLToPath(new URL("file:////remote.example.test/share/state.json"))` threw `ERR_INVALID_FILE_URL_PATH`, triggering the local absolute path error instead of the network share error. - User-visible CLI/MCP output (if applicable): not applicable - 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 - `npm.cmd run test:local -- src/server/environment/serveEnvironmentState.test.ts` ? 23 passed (23) - `npm.cmd run check:fast` ? 2 successful, 0 errors (typecheck + lint) - `npm.cmd run format:check` ? all matched files use correct format (oxfmt) - `npm.cmd run verify:architecture-guards` ? passed across 1760 source files - `npm.cmd run verify:module-boundaries` ? passed across 2543 source files ## Compatibility, safety, and release - Breaking changes or migration steps: none - Real Hopper/Ghidra, browser, or OS coverage: Windows x64 tested - Package or release metadata impact: none - Security, privacy, process, or containment review: preserves and enforces network share boundary ## Author readiness Human owner: @ithis0623-png - [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-11-01 21:46:28 +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#7246
No description provided.