fix(dashboard): harden static path traversal checks#2027
Open
fallintoplace wants to merge 3 commits into
Open
Conversation
fallintoplace
requested review from
danielmeppiel and
sergio-sisternes-epam
as code owners
July 4, 2026 23:11
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens static-file path traversal protection in the contributor dashboard’s issue-monitor HTTP server by replacing a prefix-based root check with a path.relative() containment check, and adds a regression test that exercises a sibling-prefix traversal attempt.
Changes:
- Replace
resolved.startsWith(resolve(distDir))with arelative(root, resolved)+../ absolute-path rejection check for/assets/*requests. - Add a regression test that requests
/assets/../../<dist-name>-evil/secret.txtvia raw HTTP to avoid client-side URL normalization.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/apm-contributor-dashboard/.apm/extensions/issue-monitor/server-handler.mjs | Updates the /assets/ static-file containment guard to use path.relative() instead of startsWith() path prefix checks. |
| packages/apm-contributor-dashboard/tests/server.test.mjs | Adds a regression test for sibling-prefix traversal attempts against dist-evil-style paths. |
Comment on lines
+460
to
+462
| const resolved = resolve(root, normalize(urlPath.slice(1))); | ||
| const rel = relative(root, resolved); | ||
| if (rel.startsWith("..") || isAbsolute(rel)) { |
Comment on lines
+459
to
465
| const root = resolve(distDir); | ||
| const resolved = resolve(root, normalize(urlPath.slice(1))); | ||
| const rel = relative(root, resolved); | ||
| if (rel.startsWith("..") || isAbsolute(rel)) { | ||
| res.writeHead(403); res.end("Forbidden"); return; | ||
| } | ||
| serveStatic(res, resolved); |
fallintoplace
force-pushed
the
fix/dashboard-static-path-traversal
branch
from
July 4, 2026 23:15
c405c0a to
aa94da1
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.
Summary
startsWith()root check with safepath.relative()containment check:rel.startsWith('..')orisAbsolute(rel)/assets/../../<dist-name>-evil/secret.txt.Testing