Skip to content

Commit ffcfa86

Browse files
Merge pull request microsoft#390 from microsoft/sfi-issue-fix
fix: SFI issue fix
2 parents dcd8f36 + 730f556 commit ffcfa86

File tree

3 files changed

+1016
-1146
lines changed

3 files changed

+1016
-1146
lines changed

src/frontend/frontend_server.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ async def get_config():
5050

5151
@app.get("/{full_path:path}")
5252
async def serve_app(full_path: str):
53-
# First check if file exists in build directory
54-
file_path = os.path.join(BUILD_DIR, full_path)
55-
if os.path.exists(file_path):
53+
# Remediation: normalize and check containment before serving
54+
file_path = os.path.normpath(os.path.join(BUILD_DIR, full_path))
55+
# Block traversal and dotfiles
56+
if not file_path.startswith(BUILD_DIR) or ".." in full_path or "/." in full_path or "\\." in full_path:
57+
return FileResponse(INDEX_HTML)
58+
if os.path.isfile(file_path):
5659
return FileResponse(file_path)
57-
# Otherwise serve index.html for client-side routing
5860
return FileResponse(INDEX_HTML)
5961

60-
6162
if __name__ == "__main__":
6263
uvicorn.run(app, host="127.0.0.1", port=3000)

0 commit comments

Comments
 (0)