Description
app/api/orgs/[orgId]/members/route.ts documents that it should be JWT-gated but uses the unauthenticated Actor-Wallet-Address header as a stand-in for identity, so any caller can spoof an owner address and add members. This is a server-side authorization (RBAC) bug on a privileged org-management endpoint.
Requirements and Context
- Replace header trust with
tryAuthenticateRequest from app/lib/auth.ts; derive the actor wallet from the verified JWT sub.
- Keep the owner-only AuthZ rule for
POST and add it to GET (members list should require org membership).
- Return
401 for missing/invalid token, 403 for non-owner, using the shared error envelope.
- Must be secure, tested, and documented
- Should be efficient and easy to review
Suggested Execution
- Fork the repo and create a branch
git checkout -b bug/org-members-jwt-authz
- Implement changes
app/api/orgs/[orgId]/members/route.ts
- Reuse
app/lib/auth.ts and app/lib/org-db.ts
- Test and commit
npm test -- app/api/orgs
- Cover edge cases: spoofed header, valid non-owner JWT, valid owner JWT
- Include test output and notes in the PR
Example commit message
fix: require verified JWT for org members endpoint
Acceptance Criteria
Guidelines
- Minimum 90% test coverage including spoofing attempts
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
app/api/orgs/[orgId]/members/route.tsdocuments that it should be JWT-gated but uses the unauthenticatedActor-Wallet-Addressheader as a stand-in for identity, so any caller can spoof an owner address and add members. This is a server-side authorization (RBAC) bug on a privileged org-management endpoint.Requirements and Context
tryAuthenticateRequestfromapp/lib/auth.ts; derive the actor wallet from the verified JWTsub.POSTand add it toGET(members list should require org membership).401for missing/invalid token,403for non-owner, using the shared error envelope.Suggested Execution
app/api/orgs/[orgId]/members/route.tsapp/lib/auth.tsandapp/lib/org-db.tsnpm test -- app/api/orgsExample commit message
Acceptance Criteria
Actor-Wallet-Addressno longer grants accesssubfor member addGuidelines