Safeguard
Developer Tools•

Why does a passkey only work on one domain? RP ID explained

A passkey is scoped to a relying party ID, which is a domain. That is why fake sites cannot use it. How RP ID and subdomains work, and what to choose.

Safeguard Security Team
4 min read

Each passkey is bound to a relying party ID (RP ID), which is a domain name. The browser only lets a site use credentials whose RP ID matches its own domain or a parent of it. A lookalike domain has a different RP ID, so the passkey is never offered, which is how passkeys resist phishing.

What an RP ID is

The W3C WebAuthn spec says an RP ID is based on a host's domain name. It does not include a scheme or port, unlike an origin. The RP ID determines the credential's scope: the set of origins on which it can be used.

The rule is that the RP ID must equal the origin's effective domain, or be a registrable domain suffix of it. And the page must be served over https (the spec has a narrow exception for localhost in development).

How it plays out

Page originRP ID you may useResult
https://login.example.comlogin.example.comWorks on that host only
https://login.example.comexample.comWorks on example.com and its subdomains
https://login.example.comother.comRejected by the browser
http://example.comexample.comRejected, not https
https://examp1e.comexample.comRejected, not a suffix of that domain

The last case is the phishing defence. The user never has to notice the odd spelling. The authenticator receives the RP ID from the browser and will not produce an assertion for a credential created under a different one. The spec notes each credential is scoped to an RP ID, so other sites cannot even probe whether you have an account elsewhere.

Choosing an RP ID

  1. Use the registrable domain (for example example.com) if you want one passkey to work across several subdomains such as app.example.com and login.example.com.
  2. Use a specific host if subdomains belong to different teams or trust levels and you do not want credentials shared among them.
  3. Decide before launch. A credential created under one RP ID cannot move to another. Changing it later means every user registers again.
  4. Avoid shared suffixes you do not control. You cannot use a public suffix or a domain you do not own as your RP ID.

Server side checks

On both registration and sign in, your server must verify the rpIdHash in the authenticator data equals the SHA-256 of the RP ID you expect, and that the origin in the client data is one you expect. These are separate checks. The RP ID covers the domain scope, while the origin check covers the exact page, scheme and port.

What about native apps and other domains

If your mobile app needs to use the same passkeys as your website, the platform has to be told the app and the site belong together. The details differ by operating system, so check your platform documentation for the association files. The WebAuthn spec itself only fixes the RP ID rules above.

Pitfalls

  • Choosing the RP ID from the request Host header instead of fixed configuration. An attacker controlling the header could influence it.
  • Sharing a registrable domain with untrusted tenants, such as user content on subdomains. Any subdomain that can run script may be able to ask for credentials scoped to the parent.
  • Testing on localhost and shipping the same config.

Quick check

Can I change my RP ID later?

Not without users registering new credentials. Credentials are bound to the RP ID they were created with.

Is the RP ID the same as the origin?

No. The RP ID is a domain without scheme or port. The origin includes scheme, host and port, and you verify both.

Safeguard's SBOM and dependency scanning shows which WebAuthn libraries your apps use and whether any carry known advisories. Try the free scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.