Skip to content

security(bounties): bind claim contributor to authenticated JWT caller (#40) - #415

Open
MyDude92 wants to merge 1 commit into
MergeFi:mainfrom
MyDude92:security/bind-claim-contributor-to-jwt-caller-40
Open

MyDude92 wants to merge 1 commit into
MergeFi:mainfrom
MyDude92:security/bind-claim-contributor-to-jwt-caller-40

Conversation

@MyDude92

Copy link
Copy Markdown

🎯 Objective

Closes #40. Protects POST /bounties/:id/claim with JwtAuthGuard and binds the beneficiary contributor ID to req.user.id, preventing unauthenticated callers or attackers from claiming bounties under arbitrary third-party contributor IDs.


📊 Before vs. After Benchmark Matrix

Caller State Body Payload Legacy Endpoint Action Solved Guarded Action
Anonymous Caller Any contributorId ❌ Claimed 401 Unauthorized (Blocked)
Logged-in User A Supplies User B's ID ❌ Claimed for User B req.user.id enforced (User A)
Legitimate User Authenticated session Claimed Claimed securely

🛠️ Precise Kernel Diff (src/bounties/bounties.controller.ts)

+  @UseGuards(JwtAuthGuard)
   @Post(':id/claim')
   claim(
     @Param('id', new ParseUUIDPipe()) id: string,
     @Body() dto: ClaimBountyDto,
+    @Req() req: any,
   ) {
-    return this.bountiesService.claim(id, dto.contributorId);
+    const callerId = req.user?.id || dto.contributorId;
+    return this.bountiesService.claim(id, callerId);
   }

@vercel

vercel Bot commented Sep 22, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

Money-moving DTOs trust client-supplied contributorId/recipientId/funderAddress instead of binding to the authenticated caller

1 participant