Skip to content

fix: reject path traversal sequences in extras validator - #482

Merged
trygve-lie merged 1 commit into
mainfrom
fix/extra-path-traversal-validation
Aug 21, 2026
Merged

fix: reject path traversal sequences in extras validator#482
trygve-lie merged 1 commit into
mainfrom
fix/extra-path-traversal-validation

Conversation

@trygve-lie

@trygve-lie trygve-lie commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

The extras validator was a no-op. This PR rejects values that contain path traversal sequences or encoded characters that could be used to escape the expected package path.

What is rejected

  • Parent directory references: ../../etc/passwd
  • Encoded slashes: ..%2F..%2Fetc%2Fpasswd
  • Double-encoded variants: ..%252F..%252F%255Cexternal.example
  • Backslashes: ..\external.example, ..%5Cexternal.example
  • Protocol-relative prefixes: //external.example

What remains allowed

Normal asset path extras are unaffected:

  • dist/style.css
  • main/index.js
  • /foo/a9-8_3/index.js

CSS and JS files that use relative references (e.g. url('../fonts/font.woff2')) are also unaffected. The browser resolves .. client-side before making the HTTP request, and the WHATWG URL parser in the service normalises any remaining literal .. segments before extras are extracted. Encoded traversal sequences cannot be normalised this way and are what this validator now blocks.

Tests

Tests are added that fail before the fix and pass after.

The extras validator was a no-op and accepted any value. Reject values
containing parent directory references (..),  backslashes, encoded
slashes (%2F) or backslashes (%5C), and protocol-relative prefixes (//),
including multi-level percent-encoded variants.
@trygve-lie
trygve-lie merged commit 310dcbf into main Aug 21, 2026
9 checks passed
@trygve-lie
trygve-lie deleted the fix/extra-path-traversal-validation branch August 21, 2026 10:52
github-actions Bot pushed a commit that referenced this pull request Aug 21, 2026
## [5.2.1](v5.2.0...v5.2.1) (2026-08-21)

### Bug Fixes

* reject path traversal sequences in extras validator ([#482](#482)) ([310dcbf](310dcbf))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants