Fix _checkOrigin() to require domain boundary check#123
Open
ScottHelme wants to merge 1 commit intolbuchs:masterfrom
Open
Fix _checkOrigin() to require domain boundary check#123ScottHelme wants to merge 1 commit intolbuchs:masterfrom
ScottHelme wants to merge 1 commit intolbuchs:masterfrom
Conversation
The suffix regex accepted lookalike domains (e.g. evil-example.com for RP ID example.com). Replace with exact match or dot-boundary subdomain check per W3C WebAuthn Level 2 spec §7.1 Step 5 / §7.2 Step 9.
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
Fixes
_checkOrigin()to enforce a domain boundary when validating the origin against the RP ID, as required by the W3C WebAuthn Level 2 spec (§7.1 Step 5 / §7.2 Step 9).Problem
The existing regex
preg_match('/' . preg_quote($rpId) . '$/i', $host)matches any hostname ending with the RP ID string. For RP IDexample.com, lookalike domains likeevil-example.comandevilexample.comincorrectly pass validation.Fix
Replace the suffix regex with an exact match check (
strcasecmp) and a dot-boundary subdomain check (str_ends_withwith a.prefix). This acceptsexample.comandwww.example.comwhile rejectingevil-example.comandevilexample.com.Closes #122