Skip to content

fix(users): authorize stellar-address updates by caller ID (#39) - #49

Open
ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix/39-users-stellar-address-authorization
Open

fix(users): authorize stellar-address updates by caller ID (#39)#49
ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix/39-users-stellar-address-authorization

Conversation

@ghzhost

@ghzhost ghzhost commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Fixes #39.

Problem

PATCH /users/:id/stellar-address had JwtAuthGuard applied but lacked authorization validation. Any authenticated user could supply another user's :id in the URL param and overwrite their stellarAddress, creating an IDOR vulnerability where bounty payouts could be redirected to an attacker's wallet.

Changes

  1. Defined AuthenticatedRequest interface typing req.user ({ userId, username }).
  2. In UsersController.setStellarAddress, injected @Req() req: AuthenticatedRequest and added an authorization guard verifying req.user?.userId === id. If mismatch, throws 403 ForbiddenException.
  3. Added unit tests in src/users/users.controller.spec.ts covering:
    • Valid update when caller's userId matches the :id param.
    • 403 rejection when caller's userId differs from the target :id param.

Validation

  • npm run test passes unit tests.
  • npm run lint and Prettier format pass cleanly.
  • npm run build succeeds with zero errors.

- Validate that authenticated user (req.user.userId) matches the URL :id param
- Throw 403 ForbiddenException when caller attempts to update another user's stellar address
- Add unit tests for UsersController verifying authorized updates and 403 rejections
@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize 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.

UsersController.setStellarAddress is authenticated but not authorized: any logged-in user can overwrite another user's payout address

1 participant