fix(bio-links): restrict bio link URLs to http/https schemes and prevent arbitrary iframe embeds
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
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.
Written by the indexing model from the issue text.
Description
Problem Description
-
Stored XSS via
javascript:URIs:
Inapps/api/src/bio-links/dto/upsert-bio-links.dto.ts,BioLinkInputDtoonly validatesurlandredirectUrlwith@IsString(), without restricting the URL scheme tohttp:orhttps:.
As a result, dangerous payloads such asjavascript:...ordata:...can be saved to the database and rendered directly intohrefattributes orwindow.open(...)calls on public bio pages (PublicLinkCard.tsx,PublicProductCard.tsx,PublicSocialButton.tsx), executing arbitrary JavaScript in visitors' browsers when clicked. -
Arbitrary
<iframe>injection on public bio pages:
Inapps/web/components/bio-links/PublicMediaEmbed.tsx,parseMediaEmbedfalls 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 orjavascript:/data:URIs to be embedded in public/l/[slug]pages.
Expected Behavior
- All URL fields on Bio-Links DTOs (
url,redirectUrl, and any related social/product/media URLs) must validate that onlyhttp:andhttps:schemes are accepted. - Public bio components (
PublicLinkCard.tsx,PublicProductCard.tsx,PublicSocialButton.tsx) must sanitize/verify URLs before renderinghrefor callingwindow.open(...), rejecting non-HTTP(S) schemes. PublicMediaEmbed.tsxmust 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.tsxapps/web/components/bio-links/PublicProductCard.tsxapps/web/components/bio-links/PublicSocialButton.tsxapps/web/components/bio-links/PublicMediaEmbed.tsx(parseMediaEmbed)
Solution / Implementation Guide
-
Backend (
apps/api/src/bio-links/dto/):- Replace bare
@IsString()onurlandredirectUrlinBioLinkInputDto(and any sibling bio-links DTOs for products, social buttons, or media embeds) with@IsUrl({ protocols: ['http', 'https'], require_protocol: true }).
- Replace bare
-
Frontend (
apps/web/components/bio-links/):- Add a shared
getSafeHttpUrl(url?: string | null): string | nullhelper that parses withnew URL(...)and only returns the URL ifprotocol === 'http:' || protocol === 'https:'. - Use
getSafeHttpUrlbefore passing URLs tohreforwindow.open(...)inPublicLinkCard.tsx,PublicProductCard.tsx, andPublicSocialButton.tsx. - In
PublicMediaEmbed.tsx, remove the arbitraryembedUrl: cleanUrlfallback for<iframe src={embedUrl}>so only whitelisted provider embeds (YouTube, Spotify, Instagram) render an<iframe>.
- Add a shared
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 1
- Avg merge
- 6m
- Merged PRs (30d)
- 27
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sumamakhan761/tryinstance
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sumamakhan761/tryinstance#65 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
sumamakhan761/tryinstance#64 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
sumamakhan761/tryinstance#63 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sumamakhan761/tryinstance#62 ·
Maintainers usually reply within 1 day
-
backend good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sumamakhan761/tryinstance#60 ·
Maintainers usually reply within 1 day
All issues in sumamakhan761/tryinstance
Similar issues
-
prio:low scope:hud
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OliverRomhagen/vrigstad-joyride#953 ·
Maintainers usually reply within 1 day
-
review-followup
Difficulty 1/5 Under an hour Newbie friendliness 92/100
griffinwork40/agent-afk#5446 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
kacper-szewczyk/Ticknest#346 ·
Maintainers usually reply within 1 day
-
echarts geo: a GeoJSON URL that returns 200 with a body that is not JSON is fetched on each refreshOpenbug plugin/echarts/geo
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Yeachan-Heo/gajae-code#8230 ·
Maintainers usually reply within 1 day