Repository navigation
🛡️ Sentinel: [HIGH] Prevent path traversal in SPA catch-all route - #2
Conversation
Validate that files requested via the SPA fallback route /{full_path:path} stay within DIST_DIR using Path.resolve() and Path.relative_to(). Prevent reading arbitrary server files via URL-encoded path traversal sequences like /%2e%2e/server.py. Add unit test test_server.py to verify path traversal attempts return HTTP 403.
Co-authored-by: jpaquay <17704539+jpaquay@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Validate that files requested via the SPA fallback route /{full_path:path} stay within DIST_DIR using Path.resolve() and Path.relative_to(). Prevent reading arbitrary server files via URL-encoded path traversal sequences like /%2e%2e/server.py. Add unit test test_server.py to verify path traversal attempts return HTTP 403 and clean up unused global declarations in server.py.
Co-authored-by: jpaquay <17704539+jpaquay@users.noreply.github.com>
Validate that files requested via the SPA fallback route /{full_path:path} stay within DIST_DIR using Path.resolve() and Path.relative_to(). Prevent reading arbitrary server files via URL-encoded path traversal sequences like /%2e%2e/server.py. Add unit test test_server.py and requirements.txt to ensure CI installs required dependencies for pytest.
Co-authored-by: jpaquay <17704539+jpaquay@users.noreply.github.com>
Validate that files requested via the SPA fallback route /{full_path:path} stay within DIST_DIR using Path.resolve() and Path.relative_to(). Prevent reading arbitrary server files via URL-encoded path traversal sequences like /%2e%2e/server.py. Add requirements.txt and test_server.py to test API endpoints and path traversal handling across CI environments.
Co-authored-by: jpaquay <17704539+jpaquay@users.noreply.github.com>
🚨 Severity: HIGH
💡 Vulnerability: Path Traversal via URL-encoded characters in FastAPI SPA catch-all route (
/{full_path:path}).🎯 Impact: An attacker could read arbitrary files on the host filesystem outside
dist/(e.g.server.pyor configuration files) via URL-encoded sequences like/%2e%2e/server.py.🔧 Fix: Resolved requested paths against
DIST_DIR.resolve()and validated using.relative_to(DIST_DIR.resolve()), raisingHTTP 403 Access Deniedif the target path is outsidedist/.✅ Verification: Added
test_server.pywithtest_serve_spa_path_traversal_blockedwhich verifies thatGET /%2e%2e/server.pyyields403 Forbidden.PR created automatically by Jules for task 1273223627130387572 started by @jpaquay