Bug 181950 - Move Document::domainIsRegisterable to SecurityOrigin::isMatchingRegistrableDomainSuffix
Summary: Move Document::domainIsRegisterable to SecurityOrigin::isMatchingRegistrableD...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jiewen Tan
URL:
Keywords: InRadar
Depends on:
Blocks: 181943
  Show dependency treegraph
 
Reported: 2018-01-22 14:10 PST by Jiewen Tan
Modified: 2019-05-01 15:08 PDT (History)
13 users (show)

See Also:


Attachments
Patch (9.28 KB, patch)
2019-05-01 02:22 PDT, Jiewen Tan
no flags Details | Formatted Diff | Diff
Patch (10.61 KB, patch)
2019-05-01 12:33 PDT, Jiewen Tan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jiewen Tan 2018-01-22 14:10:42 PST
This enhancement is needed for WebAuthN to work with RP ID: https://www.w3.org/TR/webauthn/#createCredential. Specifically, Step 5-7.

Here are the requests:
1. SecurityOrigin/URL needs to tell if an origin is a valid domain: https://url.spec.whatwg.org/#valid-domain.
2. SecurityOrigin/URL needs to tell if an origin is a registrable domain suffix of another origin: https://html.spec.whatwg.org/multipage/origin.html#is-a-registrable-domain-suffix-of-or-is-equal-to.
Comment 1 Radar WebKit Bug Importer 2018-08-15 17:09:02 PDT
<rdar://problem/43357371>
Comment 2 Jiewen Tan 2019-05-01 02:22:50 PDT
Created attachment 368655 [details]
Patch
Comment 3 Brent Fulgham 2019-05-01 09:35:20 PDT
Comment on attachment 368655 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=368655&action=review

> Source/WebCore/dom/Document.cpp:-4874
> -        return true;

I'm not sure if the call to 'isMatchingRegistrableDomainSuffix' handles this case or not. We seem to ASSERT that host() and protocol() are case-insensitively equal, but we don't actually do the test as far as I can tell.

> Source/WebCore/dom/Document.cpp:-4894
> -        potentialPublicSuffix.remove(0, 1);

Your new code doesn't seem to have this call protection before passing 'domainSuffix' to 'isPublicSuffix'. As far as I can tell, whatever code paths might have brought a domain with a leading '.' into this code, could still happen and we are no longer protecting our call to 'isPublicSuffix'. I think we should keep this.
Comment 4 Jiewen Tan 2019-05-01 12:02:27 PDT
Comment on attachment 368655 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=368655&action=review

>> Source/WebCore/dom/Document.cpp:-4874
>> -        return true;
> 
> I'm not sure if the call to 'isMatchingRegistrableDomainSuffix' handles this case or not. We seem to ASSERT that host() and protocol() are case-insensitively equal, but we don't actually do the test as far as I can tell.

At the constructor of OriginAccessEntry, it will convert the newDomain to lowercase. And the SecurityOrigin itself should store every data in lowercase. That means the regular string comparison actually does this job.

>> Source/WebCore/dom/Document.cpp:-4894
>> -        potentialPublicSuffix.remove(0, 1);
> 
> Your new code doesn't seem to have this call protection before passing 'domainSuffix' to 'isPublicSuffix'. As far as I can tell, whatever code paths might have brought a domain with a leading '.' into this code, could still happen and we are no longer protecting our call to 'isPublicSuffix'. I think we should keep this.

If anything has a leading dot, then it shouldn't pass accessEntry.matchesOrigin().
Comment 5 Jiewen Tan 2019-05-01 12:26:49 PDT
Comment on attachment 368655 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=368655&action=review

> Source/WebCore/page/SecurityOrigin.cpp:445
> +

From the spec, we should return true as long as it is an exact match even if both domains are public suffix.
Comment 6 Jiewen Tan 2019-05-01 12:33:42 PDT
Created attachment 368692 [details]
Patch
Comment 7 Brent Fulgham 2019-05-01 12:59:26 PDT
Comment on attachment 368692 [details]
Patch

r=me (Wait for EWS, please)
Comment 8 Jiewen Tan 2019-05-01 13:11:02 PDT
(In reply to Brent Fulgham from comment #7)
> Comment on attachment 368692 [details]
> Patch
> 
> r=me (Wait for EWS, please)

Thanks, Brent.
Comment 9 WebKit Commit Bot 2019-05-01 15:08:05 PDT
Comment on attachment 368692 [details]
Patch

Clearing flags on attachment: 368692

Committed r244853: <https://trac.webkit.org/changeset/244853>
Comment 10 WebKit Commit Bot 2019-05-01 15:08:07 PDT
All reviewed patches have been landed.  Closing bug.