fix(browser): block upload symlink escapes#21972
Merged
Conversation
mbelinky
added a commit
that referenced
this pull request
Feb 20, 2026
9520890 to
f74e977
Compare
|
Do the tests cover “non-regular file” cases (f.e. directories/FIFOs) across platforms, or is that intentionally out of scope for now? Happy to help add coverage if needed |
f74e977 to
4381ef9
Compare
Contributor
Author
6 tasks
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.
Summary\n- add resolveExistingPathsWithinRoot() to validate upload paths via safe file-open under root\n- reject symlink and non-regular file escapes while preserving existing not-found behavior\n- update browser upload call sites to await the new validator\n- add dedicated tests for traversal and symlink-escape cases\n\n## Why\nThis lands the browser path-hardening piece from #21268 separately from app deep-link changes.
Greptile Summary
Added
resolveExistingPathsWithinRoot()to validate file upload paths via safe file-open operations, preventing symlink escapes and path traversal attacks while preserving existing behavior for non-existent files.openFileWithinRoot()fromfs-safe.tsConfidence Score: 5/5
openFileWithinRoot()fromfs-safe.ts. All call sites properly await the new async function, error handling follows project conventions, and comprehensive tests validate the security improvements. The backward-compatible handling of non-existent files preserves existing behavior.Last reviewed commit: 9520890