fix: use authenticated user ID for bin operations instead of client-supplied dj_id#178
Open
jakebromberg wants to merge 6 commits intomainfrom
Open
fix: use authenticated user ID for bin operations instead of client-supplied dj_id#178jakebromberg wants to merge 6 commits intomainfrom
jakebromberg wants to merge 6 commits intomainfrom
Conversation
…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>
7672983 to
efc36bc
Compare
added 5 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.
When AUTH_BYPASS=true and the token is not a valid JWT (e.g. integration tests pass a raw user ID string), the middleware now falls back to using the token value as req.auth.id instead of silently leaving req.auth undefined. This prevents 500 errors in bin endpoints that access req.auth!.id!. The integration test setup now passes the primary DJ's user ID as the Bearer token in bypass mode, so the middleware can populate req.auth.id with the correct value for database operations.
The AUTH_BYPASS code path in integration.setup.js was sending a raw user ID string as the Bearer token. The middleware's decodeJwt() silently failed on this non-JWT string, leaving req.auth undefined and causing 500 errors in bin endpoints that access req.auth.id. Always obtain a real JWT from the auth service instead, which decodeJwt() can parse to populate req.auth even when AUTH_BYPASS skips verification.
The integration setup was sending a non-JWT string as the Bearer token in AUTH_BYPASS mode. The middleware's decodeJwt() silently failed on this, leaving req.auth undefined and causing 500s in bin endpoints. Fix by always obtaining a real JWT from the auth service: - Remove the AUTH_BYPASS branch in integration.setup.js that set a fake token; always call get_access_token() instead - Add AUTH_USERNAME and AUTH_PASSWORD to the CI workflow env so the better-auth sign-in flow succeeds against the seeded test users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
addToBin,deleteFromBin,getBin) accepteddj_idfrom the client request body/query parameters, allowing any authenticated DJ to read or modify any other DJ's bin.req.auth!.id!(the verified JWT payload) instead of trusting client-supplied values. Thedj_idparameter validation checks are removed since the ID is no longer user-supplied.tests/unit/controllers/djs.bin-idor.test.tswith three tests verifying that whenreq.auth.id = 'user-A'and the request suppliesdj_id = 'user-B', the service layer receives'user-A'.Test plan
req.auth.idover client-supplieddj_idMade with Cursor