Validate bundle stays within output dir#6277
Merged
lukastaegert merged 1 commit intobackports-rollup-2from Feb 22, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR is a backport of #6275 to Rollup 2, adding validation to prevent path traversal attacks in output file names. The change ensures that bundle file names cannot escape the designated output directory using ".." path segments or other directory traversal techniques, which has security implications for build systems.
Changes:
- Added validation function to check all output bundle file names stay within the output directory
- Implemented browser-compatible
joinfunction and refactoredresolvefunction to use shared path normalization logic - Added comprehensive test coverage for both valid and invalid file name scenarios
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Bundle.ts | Adds validateOutputBundleFileNames function that validates all bundle file names after generation and imports join from path utilities |
| src/utils/error.ts | Adds new error code FILE_NAME_OUTSIDE_OUTPUT_DIRECTORY and error generator function |
| src/utils/path.ts | Exports join function from Node's path module |
| browser/path.ts | Implements browser-compatible join function and refactors resolve to use shared normalizePathSegments helper |
| test/function/samples/file-name-subdirectory-is-valid/* | Tests that subdirectories within output directory are allowed |
| test/function/samples/file-name-mid-path-up-then-down-is-valid/* | Tests that ".." segments that normalize within output directory are allowed |
| test/function/samples/file-name-leading-dot-slash-is-valid/* | Tests that leading "./" prefixes are allowed |
| test/function/samples/error-file-name-path-traversal/* | Tests that path traversal via entryFileNames is rejected |
| test/function/samples/error-file-name-path-traversal-plugin/* | Tests that path traversal via plugin-added files is rejected |
| test/function/samples/error-file-name-dot/* | Tests that "." as a file name is rejected |
| test/function/samples/error-file-name-dot-dot/* | Tests that ".." as a file name is rejected |
| test/function/samples/error-file-name-deep-traversal/* | Tests that deep path traversal attempts are rejected |
| test/browser/samples/error-file-name-path-traversal/* | Browser test for path traversal rejection |
289d2e0 to
26dcf75
Compare
26dcf75 to
0d7a828
Compare
0d7a828 to
d6df495
Compare
d6df495 to
a09fb31
Compare
When a file would leave the output dir, an error is thrown. # Conflicts: # src/Bundle.ts # src/utils/logs.ts # src/utils/path.ts
a09fb31 to
15bcf48
Compare
lukastaegert
added a commit
that referenced
this pull request
Feb 22, 2026
When a file would leave the output dir, an error is thrown. # Conflicts: # src/Bundle.ts # src/utils/logs.ts # src/utils/path.ts
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.
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
This is the backport of #6275 for Rollup 2