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

Aperta
#27 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
47/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
nextjs, postgresql, typescript

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
TypeScript
Stelle
2
Fork
1
Merge medio
6m
PR unite (30g)
27

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sumamakhan761/tryinstance

Tutte le issue di sumamakhan761/tryinstance

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.