Skip to content

fix: block path traversal in disk and http file proxies - #178

Open
darzasassing-hub wants to merge 1 commit into
tscircuit:mainfrom
darzasassing-hub:fix/block-path-traversal-proxies
Open

darzasassing-hub wants to merge 1 commit into
tscircuit:mainfrom
darzasassing-hub:fix/block-path-traversal-proxies

Conversation

@darzasassing-hub

Copy link
Copy Markdown

Summary

Fixes #173 — Path traversal in disk and http file proxies allowed reading files outside the proxy root via .. segments.

Changes

  1. Early rejection: In resolveFileProxy, check if any segment of relativePath is .. and return 400 Bad Request (Invalid path: path traversal not allowed). This immediately blocks traversal on both disk and http proxies.
  2. Defense in depth: In resolveDiskProxy, use resolve() to compute the target path and verify it stays strictly contained within the resolved root of diskPath, returning 403 Forbidden if escaped.
  3. Tests: Added tests/routes/path-traversal-proxy.test.ts testing unit-level rejection on disk and http proxies as well as route-level query parameter verification.

Verification

  • bun test: All tests pass (including existing file-proxy suites and new path traversal tests).
  • Biome check: Formatted and passing with 0 errors.

/claim #173
/attempt #173

Reject '..' path segments in resolveFileProxy with 400 and enforce containment within diskPath root in resolveDiskProxy with 403. Add tests verifying path traversal prevention.

Fixes tscircuit#173
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.

Path traversal in disk file proxies: /files/download can read files outside the proxy root via .. segments

1 participant