Repository navigation
vfs: prevent RealFSProvider sandbox escape via symlinks - #67971
Open
pipobscure wants to merge 1 commit into
Open
pipobscure wants to merge 1 commit into
pipobscure wants to merge 1 commit into
Conversation
pipobscure
requested review from
mcollina and
trivikr
and removed request for
trivikr
December 2, 2026 15:24
Collaborator
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67971 +/- ##
==========================================
- Coverage 90.58% 90.57% -0.01%
==========================================
Files 802 802
Lines 287050 287077 +27
Branches 55431 55442 +11
==========================================
+ Hits 260013 260017 +4
- Misses 17131 17142 +11
- Partials 9906 9918 +12
🚀 New features to boost your workflow:
|
The containment check in RealFSProvider#resolvePath was thrown inside the try block wrapping fs.realpathSync(). Because the rejection carried an ENOENT code, the `if (err?.code !== 'ENOENT') throw err` catch mistook it for "path does not exist yet" and returned the raw, symlink-containing path, which the caller then opened — following the symlink out of the root. #verifyAncestorInRoot had the same self-swallowing flaw, making it a no-op. As a result readFile/stat/open/write on a symlink pointing outside the root read and wrote real files outside the sandbox. Move the containment checks outside the try/catch so a rejection can no longer be swallowed by the ENOENT handler, and compare against a canonicalized root (#realRoot) so the checks are sound even when the root path itself contains symlinked components (e.g. /tmp -> /private/tmp). Add regression tests covering read/stat/open/write and new-file creation through symlinks that resolve outside the provider root. Signed-off-by: Vinz Spring <vjvsp@yahoo.de>
Contributor
Author
|
The flaky test is fixed in c67d87c on main. So I'm rebasing and running them again to validate. |
pipobscure
force-pushed
the
vfs-symlink-sandbox-escape-fix
branch
from
December 5, 2026 11:13
23850c0 to
58a634b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Taking over #64409 since it seems it's abandoned by the original author and is something we do want to fix.