BUG: Upload routes missing authentication — requireAuth imported but never used #86
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
All upload routes in
services/mam-api/src/routes/upload.jsare completely unauthenticated —requireAuthis imported at the top of the file as dead code but never applied to any route handler.The file imports
requireAuth:But none of the route handlers use it:
The parent app mount in
index.jsalso doesn't add auth at the group level:Impact (when
AUTH_ENABLED=true):POST /upload/initresponses to discover upload IDs and keys/abortendpoint can delete in-progress asset rows if an attacker knows the uploadId/key/assetIdMitigations that make exploitation less trivial:
/initrequires knowing a validprojectId(UUID)projectIdSuggested fix: Add
requireAuthto each route or addrouter.use(requireAuth)at the top of the router. Since the XHR-based upload flow (_xhrPostinscreens-ingest.jsx) does not send auth headers, the frontend's_xhrPostwould also need to include theAuthorization: Bearerheader to match. (The existingwindow.ZAMPP_API.fetchhelper already handles this — it's just that the multipart XHR flow bypasses it.)upload.jsimports from non-existent../middleware/requireAuth.js— server crashes on startup if rebuilt #88