Skip to content

Comments

js_repl: canonicalize paths for node_modules boundary checks#12177

Merged
fjord-oai merged 1 commit intomainfrom
fjord/js_repl_seq---4hspua2-8n4nq5
Feb 18, 2026
Merged

js_repl: canonicalize paths for node_modules boundary checks#12177
fjord-oai merged 1 commit intomainfrom
fjord/js_repl_seq---4hspua2-8n4nq5

Conversation

@fjord-oai
Copy link
Contributor

@fjord-oai fjord-oai commented Feb 18, 2026

Summary

Fix js_repl package-resolution boundary checks for macOS temp directory path aliasing (/var vs /private/var).

Problem

js_repl verifies that resolved bare-package imports stay inside a configured node_modules root.
On macOS, temp directories are commonly exposed as /var/... but canonicalize to /private/var/....
Because the boundary check compared raw paths with path.relative(...), valid resolutions under temp dirs could be misclassified as escaping the allowed base, causing false Module not found errors.

Changes

  • Add fs import in the JS kernel.
  • Add canonicalizePath() using fs.realpathSync.native(...) (with safe fallback).
  • Canonicalize both base and resolvedPath before running the node_modules containment check.

Impact

  • Fixes false-negative boundary checks for valid package resolutions in macOS temp-dir scenarios.
  • Keeps the existing security boundary behavior intact.
  • Scope is limited to js_repl kernel module path validation logic.

git stack

git-stack-id: fjord/js_repl_seq---4hspua2-8n4nq5
git-stack-title: js_repl: canonicalize paths for node_modules boundary checks
@fjord-oai fjord-oai merged commit cc248e4 into main Feb 18, 2026
37 of 39 checks passed
@fjord-oai fjord-oai deleted the fjord/js_repl_seq---4hspua2-8n4nq5 branch February 18, 2026 19:56
@github-actions github-actions bot locked and limited conversation to collaborators Feb 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants