Skip to content

fix: use authenticated user ID for bin operations instead of client-supplied dj_id#178

Open
jakebromberg wants to merge 3 commits intomainfrom
fix/5-bin-idor
Open

fix: use authenticated user ID for bin operations instead of client-supplied dj_id#178
jakebromberg wants to merge 3 commits intomainfrom
fix/5-bin-idor

Conversation

@jakebromberg
Copy link
Member

Summary

  • Security fix (IDOR): All three bin endpoints (addToBin, deleteFromBin, getBin) accepted dj_id from the client request body/query parameters, allowing any authenticated DJ to read or modify any other DJ's bin.
  • Fix: Each endpoint now derives the DJ ID from req.auth!.id! (the verified JWT payload) instead of trusting client-supplied values. The dj_id parameter validation checks are removed since the ID is no longer user-supplied.
  • Tests: Added tests/unit/controllers/djs.bin-idor.test.ts with three tests verifying that when req.auth.id = 'user-A' and the request supplies dj_id = 'user-B', the service layer receives 'user-A'.

Test plan

  • Unit tests confirm all three bin endpoints use req.auth.id over client-supplied dj_id
  • Full unit test suite passes (123 tests, 0 failures)
  • Integration test with running backend to confirm bin operations still work end-to-end

Made with Cursor

…upplied dj_id

All bin endpoints accepted dj_id from the request body/query, enabling
any authenticated DJ to read/modify any other DJ's bin (IDOR).

Co-authored-by: Cursor <cursoragent@cursor.com>
Jake Bromberg added 2 commits February 27, 2026 09:46
Bin endpoints now derive dj_id from req.auth.id instead of accepting
it from the client. Remove dj_id from request bodies and query params
in integration tests, and remove tests for missing dj_id validation
since it is no longer a client-supplied parameter.

Also update requirePermissions middleware to decode (without verifying)
the JWT in AUTH_BYPASS mode so that req.auth.id is still populated for
controllers that depend on it.
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.

1 participant