fix: reject path traversal in alias extras and validate redirect location - #645
Merged
Conversation
…tion Extras containing parent directory references (..), backslashes, or encoded path separators are rejected before the alias redirect is constructed. A secondary check ensures the constructed location does not resolve to a protocol-relative or absolute URL outside the expected origin.
wkillerud
reviewed
Aug 21, 2026
validators.extra() from @eik/common now performs this validation. The handler retains only the defence-in-depth location check that ensures the constructed redirect stays within the expected origin.
Contributor
Author
|
The @eik/common package needs to be published before this one can pass test vise. |
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 21, 2026
## [2.2.2](v2.2.1...v2.2.2) (2026-08-21) ### Bug Fixes * reject path traversal in alias extras and validate redirect location ([#645](#645)) ([be1a9ef](be1a9ef))
|
🎉 This PR is included in version 2.2.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Extras containing path traversal sequences are rejected before the alias redirect is constructed. A secondary check ensures the constructed redirect location does not resolve outside the expected origin.
The problem
A request such as:
After one round of percent-decoding (performed by the handler), the extras become:
path.jointreats%2Fand%5Cas opaque literals, so no traversal happens at the application level. However, when the redirectLocationheader is followed by an HTTP client that decodes percent-encoding, the path resolves through the..segments and%5C(backslash) becomes/, producing a protocol-relative URL (//external.example) that points to an external host.What this PR adds
Input validation —
validators.extra()from@eik/common(now non-trivial as of v5.2.1) rejects extras containing traversal sequences before the redirect is constructed.Location guard — after constructing the redirect location, a check asserts it does not start with
//or match an absolute URL scheme (https?://). This is defence-in-depth on the output, independent of input validation.What remains allowed
Normal extras are unaffected:
dist/style.css→ redirects to/pkg/@warp-ds/css/1.5.3/dist/style.cssmain/index.js→ redirects to/pkg/@warp-ds/css/1.5.3/main/index.jsCSS and JS relative references (e.g.
url('../fonts/font.woff2')) are also unaffected. Browsers resolve..client-side before making any HTTP request; the literal..never arrives at EIK.Tests
Tests are added that fail before the fix and pass after.