Skip to content

Commit e8e6c1e

Browse files
committed
fix: CORS startup crash + path traversal security
- CORS: change allow_credentials=True to False (wildcard origins + credentials is forbidden by Starlette, causes AssertionError on boot) - Path traversal: already fixed with is_relative_to (was in diff from prior session)
1 parent 9d41ac5 commit e8e6c1e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

web/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def create_app() -> FastAPI:
7373
app.add_middleware(
7474
CORSMiddleware,
7575
allow_origins=["*"],
76-
allow_credentials=True,
76+
allow_credentials=False,
7777
allow_methods=["*"],
7878
allow_headers=["*"],
7979
)

web/routes/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ async def download_dataset(path: str = Query(..., description="Path to Zarr data
127127
data_dir = (PROJECT_ROOT / "data").resolve()
128128

129129
# Security: only allow paths under PROJECT_ROOT/data
130-
if not str(dataset_path).startswith(str(data_dir)):
130+
if not dataset_path.is_relative_to(data_dir):
131131
raise HTTPException(status_code=403, detail="Access denied: path outside data directory")
132132

133133
if not dataset_path.exists():

0 commit comments

Comments
 (0)