Skip to content

Conversation

@nicolastemciuc
Copy link
Member

Note

This is a Level 3 feature based on the latest W3C Working Draft

Summary

This PR introduces support for verifying the top_origin parameter reported by the browser during WebAuthn registration and authentication ceremonies.

The topOrigin value identifies the top-level origin under which a WebAuthn ceremony is taking place, typically relevant when credentials are created or used within iframes or embedded contexts.

To support this, a new configuration option is added:

config.allowed_top_origins = ["https://app.example.com"]

If the top_origin reported by the browser is not included in allowed_top_origins, the operation will be rejected.

References

Related blogs

@nicolastemciuc nicolastemciuc force-pushed the temciuc--verify-top-origin branch from 11efc20 to d57f060 Compare October 21, 2025 16:00
@nicolastemciuc nicolastemciuc marked this pull request as ready for review October 21, 2025 16:38
@nicolastemciuc
Copy link
Member Author

The WebAuthn specification provides several examples of how the top origin can be validated:

Similar considerations apply when validating the topOrigin member of the client data. When topOrigin is present, the Relying Party MUST validate that its value is expected. This validation MAY be performed by exact string matching or any other method as needed by the Relying Party. For example:

  • A web application that does not wish to be embedded in a cross-origin iframe might require topOrigin to exactly equal origin.
  • A web application that wishes to be embedded in a cross-origin iframe on a small number of domains might require topOrigin to exactly equal some element of a list of allowed origins, for example the list ["https://example-partner1.org", "https://login.partner2-example.org"].
  • A web application that wishes to be embedded in a cross-origin iframe on a large number of domains might allow any value of topOrigin, or use a dynamic procedure to determine whether a given topOrigin value is allowed for a particular ceremony.

This PR doesn't yet allow configuring the allowed top origin dynamically or with unrestricted values. If we want to support those cases, we can address them in a follow-up PR.

Copy link
Contributor

@santiagorodriguez96 santiagorodriguez96 left a comment

Choose a reason for hiding this comment

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

Nice job!

Leave a couple of thoughts to discuss, but is looking good overall. Perhaps we have to test this with our demos to ensure is working correctly in a real life scenario 👀

@nicolastemciuc
Copy link
Member Author

Perhaps we have to test this with our demos to ensure is working correctly in a real life scenario

After testing locally with two demos, I discovered that we were incorrectly expecting crossOrigin to be a string instead of a boolean. I fixed this in 08f2b25.

@nicolastemciuc nicolastemciuc force-pushed the temciuc--verify-top-origin branch from d041277 to 687d6cf Compare October 23, 2025 17:09
@nicolastemciuc nicolastemciuc changed the title Verify top_origin during credential registration and authentication Verify topOrigin during credential registration and authentication Oct 23, 2025
@nicolastemciuc nicolastemciuc force-pushed the temciuc--verify-top-origin branch from 75ceb1f to e4f0877 Compare October 23, 2025 20:19
@nicolastemciuc nicolastemciuc merged commit 12a770a into master Oct 24, 2025
35 checks passed
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.

3 participants