fix(arborist): block symlink escape in patch applier #10129

Open
rootvector2 opened 1:40am on October 15, 2026 wants to merge 25 Ξ” into npm/cli latest from
block-patch-applier-symlink-escape

Pull Request Overview

  • Opened on October 15, 2026
  • Status Open
  • Commit count 1 with first commit October 15, 2026

Total Delta

25 Total Diff Delta

Open Days

Open 16 weekdays

Test Delta

8 Diff Delta in Test Files
Breakdown by Phase

How long has this pull request spent in each phase of its lifecycle?

Fraction of total time Business days Phase
 
0.0 days Authoring 1 commit before pull request opened for review
 
1.0 day Awaiting first review
 
15.3 days Revising work with 0 commits in response to 0 reviews that left 2 comments

Total time for pull request still awaiting merge (longer than repo's target): 16.3 business days

Author avatar

fix(arborist): block symlink escape in patch applier

applyPatchToDir in @npmcli/arborist applies a registered patchedDependencies patch to a package that was just extracted from a registry tarball, and containedTarget is meant to keep every write and delete inside that package directory. The check is purely lexical (reject .. and absolute paths), so a publisher who ships a tarball with a symlink such as evil -> /outside at a directory the patch touches gets past it: the diff path evil/pwned.js looks contained, but the following writeFile/rm follows the symlink and lands outside the package during npm install/npm ci. This reworks the guard to refuse a symlink at the target and to require the real path of the deepest existing ancestor to stay inside the real package directory, which is the only layer that sees the extracted tree.

Added regression tests for the write and delete cases; both escape on the current tree and are blocked with the fix.

Comments Threads Pending Resolution

Resolved Comment Threads

No resolved comments have been left on this PR.