Skip to content

Harden mainnet origin and alternative-origin validation - #762

Open
zeropath-ai[bot] wants to merge 2 commits into
masterfrom
zvuln_fix_5fd8f327
Open

zeropath-ai[bot] wants to merge 2 commits into
masterfrom
zvuln_fix_5fd8f327

Conversation

@zeropath-ai

@zeropath-ai zeropath-ai Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

insertLoginForm() now treats any hostname whose suffix matches icp0.io, ic0.app, or icp.net as a trusted mainnet origin by using window.location.hostname.endsWith(domain). That accepts attacker-controlled lookalike domains such as evilicp.net. Because check_alternative_origin() only fetches /.well-known/ii-alternative-origins from the current origin and checks whether that origin lists itself, an attacker-controlled suffix-matching site can satisfy the check trivially, causing the code to auto-set derivationOrigin to https://<canister-id>.<matched-domain> and use the production II provider. In practice, a phishing site hosted on a suffix-matching domain can make users authenticate via Internet Identity while the app receives a delegation scoped as the target canister origin, letting the attacker use the victim's identity against that canister. Trusted mainnet detection needs an origin boundary check (exact host or .-delimited subdomain) and the alternative-origin proof should be tied to the target canister origin, not self-asserted by the current page.

@zeropath-ai
zeropath-ai Bot requested a review from a team as a code owner September 16, 2026 15:53
@zeropath-ai

zeropath-ai Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

No security or compliance issues detected. Reviewed everything up to 8f2ee94.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► tools/ui/src/auth/auth.ts
    Enable alternative origin check via canisterOrigin and adjust login form origin handling

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes correctly address both reported origin-validation vulnerabilities.

Pull request overview

Hardens Internet Identity origin validation against lookalike-domain attacks.

Changes:

  • Requires exact or dot-delimited mainnet domain matches.
  • Validates alternative origins against the target canister.
File summaries
File Description
tools/ui/src/auth/auth.ts Secures mainnet detection and alternative-origin verification.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants