Skip to content

[bug] updateCard does not verify that linkIds belong to the current user — IDOR vulnerability #159

@MehtabSandhu11

Description

@MehtabSandhu11

In apps/backend/src/routes/cards.ts, the PUT /:id endpoint accepts linkIds and creates CardLink records without verifying that the provided platformLinkId values belong to the authenticated user:

await app.prisma.cardLink.createMany({
  data: parsed.data.linkIds.map((linkId, index) => ({
    cardId: id,
    platformLinkId: linkId, // ← never verified this belongs to userId
    displayOrder: index,
  })),
});

An attacker who knows another user's platformLinkId UUID can add that user's links to their own card, effectively stealing their profile link data.

Proposed fix

Before creating CardLinks, verify all provided linkIds belong to the current user:

const validLinks = await app.prisma.platformLink.findMany({
  where: { id: { in: parsed.data.linkIds }, userId },
});
if (validLinks.length !== parsed.data.linkIds.length) {
  return reply.status(403).send({ error: 'One or more links do not belong to you' });
}

Files to touch

  • apps/backend/src/routes/cards.ts

GSSoC 2026 — Assignment Request

I would like to work on this issue as part of GirlScript Summer of Code 2026 (GSSoC'26). I have reviewed the codebase and understand the root cause and the fix required.

Could you please assign this issue to me?

GitHub: @MehtabSandhu11

Thank you!

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions