Skip to content

Enforce basket ownership in GET /rest/basket/:id to fix IDOR#4

Open
emrazik wants to merge 1 commit into
masterfrom
fix/idor-basket-access
Open

Enforce basket ownership in GET /rest/basket/:id to fix IDOR#4
emrazik wants to merge 1 commit into
masterfrom
fix/idor-basket-access

Conversation

@emrazik

@emrazik emrazik commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Finding

NetSPI Finding #1048219782 — Inadequate Authorization Controls (IDOR) | High

GET /rest/basket/:id was protected by isAuthorized() (user must be logged in) but performed no ownership check. Any authenticated user could read any other user's basket — including their selected products and quantities — simply by incrementing the basket ID in the URL.

What changed

routes/basket.tsretrieveBasket()

Added an ownership check at the top of the handler. The authenticated user's basket ID (user.bid, derived from the JWT at login) is compared to the requested :id parameter. If they don't match, the handler returns 403 Access denied before any database query is made.

Removed the now-unused challengeUtils and challenges imports that were previously used only for detecting the IDOR challenge.

Test plan

  • Log in as User A, capture their basket ID, then log in as User B and request User A's basket URL — expect 403
  • Log in as User A and request their own basket — expect 200 with their basket data
  • Verify checkout and coupon flows are unaffected (they operate on the authenticated user's basket)

🤖 Generated with Claude Code

GET /rest/basket/:id accepted any basket ID without verifying the
authenticated user owned it, allowing any logged-in user to read another
user's basket contents by incrementing the ID.

Add an ownership check against user.bid (the basket ID encoded in the
JWT at login) and return 403 if it doesn't match the requested ID.
Remove the now-unused challenge-detection imports.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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