fix(bio-links): strip plaintext secrets and move gated link passcode verification to backend

Open
#27 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
47/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
nextjs, postgresql, typescript

Research direction

Read apps/api/src/bio-links/bio-links.service.ts and apps/api/src/bio-links/bio-links.controller.ts, then trace how apps/web/app/l/[slug]/page.tsx passes data to apps/web/components/bio-links/PublicLinkCard.tsx. Check the public endpoint response and the gated link flow. Done means public data excludes private tokens, passcodes, and unverified destinations, with the destination returned only after server-side verification.

Written by the indexing model from the issue text.

Description

backend bug frontend web
Problem Description
  1. Plaintext metaAccessToken leaked on public Bio-Links endpoint:
    In apps/api/src/bio-links/bio-links.service.ts (getPublicBioPage), the full bioPage record is returned directly from Prisma, including pixelConfig.metaAccessToken in plaintext.

  2. Gated link passcode and destination url exposed to client:
    getPublicBioPage also returns link.passcode (and link.url) for gated links (isGated: true).
    In apps/web/app/l/[slug]/page.tsx, this payload is passed into client components, serializing both pixelConfig.metaAccessToken and link.passcode into the public page's RSC/client payload.
    In apps/web/components/bio-links/PublicLinkCard.tsx, passcode validation is performed client-side (const expectedPasscode = (link.passcode || '').trim().toLowerCase()), allowing any visitor to inspect the network/RSC payload and bypass the gate or extract the secret token.


Expected Behavior
  1. GET /bio-links/public/:slug (getPublicBioPage) must never expose pixelConfig.metaAccessToken or any gated link's passcode (or unverified url) in the public response.
  2. Passcode-gated links must be verified server-side; the destination url should only be returned after the backend confirms the submitted passcode is valid.

Where to Look
  • apps/api/src/bio-links/bio-links.service.ts (getPublicBioPage)
  • apps/api/src/bio-links/bio-links.controller.ts
  • apps/web/app/l/[slug]/page.tsx
  • apps/web/components/bio-links/PublicLinkCard.tsx

Solution / Implementation Guide
  1. Backend (bio-links.service.ts & bio-links.controller.ts):

    • In getPublicBioPage(slug):
      • Sanitize pixelConfig so metaAccessToken (and any other private keys) is omitted from the returned object, keeping only public pixel IDs.
      • For links where isGated === true, omit passcode and mask/omit url (and fileUrl if applicable) in the public payload.
    • Add a public verification endpoint (e.g. POST /bio-links/public/:slug/unlock) accepting { linkId, passcode } (or email for email-gated links):
      • Validate the passcode server-side against the database record.
      • Return { unlocked: true, url } on match, or 401/403 with an error message on mismatch.
  2. Frontend (PublicLinkCard.tsx):

    • Remove the client-side link.passcode comparison.
    • On passcode submit, call the new POST /bio-links/public/:slug/unlock endpoint and use the returned url to open the link once unlocked.
Dominant language
TypeScript
Stars
2
Forks
1
Avg merge
6m
Merged PRs (30d)
27

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sumamakhan761/tryinstance

All issues in sumamakhan761/tryinstance

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.