Skip to content

fix: validate identity.url scheme before rendering as external link - #644

Merged
ECWireless merged 2 commits into
mainfrom
fix/profile-url-href-validation
Sep 20, 2026
Merged

ECWireless merged 2 commits into
mainfrom
fix/profile-url-href-validation

Conversation

@rickstaa

@rickstaa rickstaa commented Apr 29, 2026

Copy link
Copy Markdown
Member

Closes #643

Summary

Sanitizes the ENS-supplied identity.url value before rendering it as an external link in the orchestrator profile header. Adds sanitizeExternalUrl to lib/utils.tsx and uses it for both href and the displayed text.

Why

identity.url is set by the orchestrator via their ENS url text record — fully user-controlled. Without validation, values like javascript:alert(...), data:text/html,..., or schemeless evil.com/path (which resolves as a relative link to explorer.livepeer.org) are rendered verbatim into the DOM. React 16+ warns on javascript: hrefs but does not reliably block them.

What changed

  • Add sanitizeExternalUrl(url) helper to lib/utils.tsx. It auto-prefixes https:// for schemeless input, parses via new URL(...), returns the canonical form on success, or null for anything that fails to parse or uses a non-http(s) protocol.
  • In components/Profile/index.tsx, compute safeIdentityUrl once at the top of the component and use it for the link's href, title, and the visible text. Suppress the entire link block when sanitization fails.
  • Twitter / GitHub blocks are untouched — those interpolate handles into hardcoded https://twitter.com/ / https://github.com/ URLs and are not the same risk.

Test plan

  • pnpm typecheck passes (via pre-commit hook).
  • pnpm lint and prettier --check pass.
  • Reviewer: visit a profile with a valid http(s) URL — link still works as before.
  • Reviewer: confirm a profile with a javascript: URL doesn't render the link block at all.

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings April 29, 2026 10:34
@rickstaa
rickstaa requested a review from ECWireless as a code owner April 29, 2026 10:34
@vercel

vercel Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
explorer-arbitrum-one Ready Ready Preview Sep 20, 2026 10:52pm UTC

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Addresses a security issue where an ENS-supplied identity.url could be rendered directly into an external link without validation.

Changes:

  • Added sanitizeExternalUrl utility to validate/normalize user-supplied URLs to safe http(s) absolute URLs.
  • Updated the profile page to use the sanitized URL (or skip rendering the link when invalid).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lib/utils.tsx Adds sanitizeExternalUrl for scheme normalization and protocol validation.
components/Profile/index.tsx Uses sanitizeExternalUrl(identity?.url) before rendering an external website link.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread components/Profile/index.tsx Outdated
Comment thread lib/utils.tsx Outdated
Comment thread lib/utils.tsx
Orchestrator profile URLs come from ENS text records — a user-controlled
field. As rendered, values like `javascript:alert(...)`, `data:...`, or
schemeless `evil.com/path` (treated as a relative URL) would all become
clickable from the profile page. React 16+ warns on `javascript:` hrefs
but doesn't reliably block them.

Add `sanitizeExternalUrl` in `lib/utils.tsx` that auto-prefixes
`https://` for schemeless input, parses via `new URL(...)`, and rejects
anything outside `http:` / `https:`. Use the sanitized value for both
`href` and the displayed text; suppress the entire link block when
sanitization fails.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ECWireless
ECWireless force-pushed the fix/profile-url-href-validation branch from 249bc08 to 5dddb15 Compare September 20, 2026 22:44
Copilot AI review requested due to automatic review settings September 20, 2026 22:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 20, 2026 22:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ECWireless
ECWireless merged commit 8c104a2 into main Sep 20, 2026
9 checks passed
@ECWireless
ECWireless deleted the fix/profile-url-href-validation branch September 20, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Triage

Development

Successfully merging this pull request may close these issues.

security: profile page renders unsanitized ENS-supplied URL

3 participants