fix(security): sanitize project URL fields to prevent XSS via javascript: URIs#423
Merged
fix(security): sanitize project URL fields to prevent XSS via javascript: URIs#423
Conversation
…ipt: URIs Add URL protocol validation on both server and client to guard against XSS injection through project metadata sourced from the ProjectHub API. - API route: strip any URL field whose protocol is not http/https before returning data to the client (defense-in-depth) - ProjectsNew component: sanitizeUrl() helper gates every href derived from project data; unsafe URLs are suppressed entirely
Deploying website with
|
| Latest commit: |
c75f1d1
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1cd80fd3.website-aun.pages.dev |
| Branch Preview URL: | https://fix-security-xss-url-sanitiz.website-aun.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/projects): strips any URL field whose protocol is nothttp:orhttps:before returning data to the client — defense-in-depth at the server layerProjectsNewcomponent: adds asanitizeUrl()helper that validates protocol before use; allhrefattributes derived from project data (websiteUrl, githubUrl, twitterUrl, linkedinUrl, instagramUrl, facebookUrl, youtubeUrl, telegramUrl, mastodonUrl, blueskyUrl, tiktokUrl, signalUrl, upscrolledUrl) now go through this check — unsafe URLs are suppressed entirelyMotivation
Project metadata is sourced from the external ProjectHub API. If an admin account on the hub were compromised, an attacker could inject
javascript:ordata:URIs into URL fields, which would be rendered ashrefattributes on this site. React + MUI + CSP mitigate the risk in practice, but explicit protocol validation closes the gap with no reliance on downstream defences.Test plan
/projects— all project cards and "Visit Site" links render as before for legitimate URLspnpm build)