fix(bio-links): restrict bio link URLs to http/https schemes and prevent arbitrary iframe embeds

オープン
#28 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
nextjs, react, typescript

調査の方向性

Start with the listed DTO and public bio components, then inspect sibling bio link DTOs and how parseMediaEmbed selects providers. Trace URL fields through validation and rendering, and check the existing tests for these paths. Done means bio link URLs accept only HTTP(S), and public media embeds render only for the approved providers.

索引モデルが issue の本文から書いたものです。

説明

backend bug ui web
Problem Description
  1. Stored XSS via javascript: URIs:
    In apps/api/src/bio-links/dto/upsert-bio-links.dto.ts, BioLinkInputDto only validates url and redirectUrl with @IsString(), without restricting the URL scheme to http: or https:.
    As a result, dangerous payloads such as javascript:... or data:... can be saved to the database and rendered directly into href attributes or window.open(...) calls on public bio pages (PublicLinkCard.tsx, PublicProductCard.tsx, PublicSocialButton.tsx), executing arbitrary JavaScript in visitors' browsers when clicked.

  2. Arbitrary <iframe> injection on public bio pages:
    In apps/web/components/bio-links/PublicMediaEmbed.tsx, parseMediaEmbed falls back to returning { type: ..., embedUrl: cleanUrl } for any URL that does not match YouTube, Spotify, or Instagram, and renders <iframe src={embedUrl}> directly. This allows arbitrary external URLs or javascript:/data: URIs to be embedded in public /l/[slug] pages.


Expected Behavior
  1. All URL fields on Bio-Links DTOs (url, redirectUrl, and any related social/product/media URLs) must validate that only http: and https: schemes are accepted.
  2. Public bio components (PublicLinkCard.tsx, PublicProductCard.tsx, PublicSocialButton.tsx) must sanitize/verify URLs before rendering href or calling window.open(...), rejecting non-HTTP(S) schemes.
  3. PublicMediaEmbed.tsx must only render <iframe> elements for approved embed providers/domains (YouTube, Spotify, Instagram) instead of falling back to arbitrary URLs.

Where to Look
  • apps/api/src/bio-links/dto/upsert-bio-links.dto.ts (BioLinkInputDto)
  • apps/web/components/bio-links/PublicLinkCard.tsx
  • apps/web/components/bio-links/PublicProductCard.tsx
  • apps/web/components/bio-links/PublicSocialButton.tsx
  • apps/web/components/bio-links/PublicMediaEmbed.tsx (parseMediaEmbed)

Solution / Implementation Guide
  1. Backend (apps/api/src/bio-links/dto/):

    • Replace bare @IsString() on url and redirectUrl in BioLinkInputDto (and any sibling bio-links DTOs for products, social buttons, or media embeds) with @IsUrl({ protocols: ['http', 'https'], require_protocol: true }).
  2. Frontend (apps/web/components/bio-links/):

    • Add a shared getSafeHttpUrl(url?: string | null): string | null helper that parses with new URL(...) and only returns the URL if protocol === 'http:' || protocol === 'https:'.
    • Use getSafeHttpUrl before passing URLs to href or window.open(...) in PublicLinkCard.tsx, PublicProductCard.tsx, and PublicSocialButton.tsx.
    • In PublicMediaEmbed.tsx, remove the arbitrary embedUrl: cleanUrl fallback for <iframe src={embedUrl}> so only whitelisted provider embeds (YouTube, Spotify, Instagram) render an <iframe>.
主要言語
TypeScript
スター
2
フォーク
1
平均マージ
6分
マージ済み PR(30日)
27

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sumamakhan761/tryinstance のほかの issue

sumamakhan761/tryinstance の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。