Bug 209761 - Experimental: Enforce SameSite=strict for domains classified as bounce trackers
Summary: Experimental: Enforce SameSite=strict for domains classified as bounce trackers
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: John Wilander
URL:
Keywords: InRadar
Depends on:
Blocks: 210362
  Show dependency treegraph
 
Reported: 2020-03-30 13:19 PDT by John Wilander
Modified: 2020-04-10 15:28 PDT (History)
6 users (show)

See Also:


Attachments
Patch (75.42 KB, patch)
2020-03-30 13:46 PDT, John Wilander
no flags Details | Formatted Diff | Diff
Patch (78.40 KB, patch)
2020-03-30 17:36 PDT, John Wilander
no flags Details | Formatted Diff | Diff
Patch for landing (78.44 KB, patch)
2020-03-30 18:47 PDT, John Wilander
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Wilander 2020-03-30 13:19:45 PDT
Domains that are classified as bounce trackers and hit a certain threshold of unique top frame redirects should have their cookies rewritten as SameSite=strict.
Comment 1 John Wilander 2020-03-30 13:19:56 PDT
<rdar://problem/59394943>
Comment 2 John Wilander 2020-03-30 13:46:44 PDT
Created attachment 394957 [details]
Patch
Comment 3 John Wilander 2020-03-30 15:05:56 PDT
Ugh. The tests are failing on mac-wk2 because that bot is on a version of macOS which lacks the CFNetwork APIs. I'll update the expectations file accordingly before landing.
Comment 4 Kate Cheney 2020-03-30 15:20:47 PDT
Comment on attachment 394957 [details]
Patch

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

> Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:1653
> +        return;

Probably need to call the completionHandler here in case of a database I/O error.

> Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:1718
>          ASSERT_NOT_REACHED();

Nice catch!

> Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2068
> +    result = ensureResourceStatisticsForRegistrableDomain(redirectDomain);

This is not necessary, it is done already in ResourceLoadStatisticsDatabaseStore::ensureAndMakeDomainList.

> Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2280
> +

Nice! :)

> Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:455
> +                RELEASE_LOG_INFO_IF(debugLoggingEnabled(), ITPDebug, "Did set %" PUBLIC_LOG_STRING " as making a top frame redirect to %" PUBLIC_LOG_STRING ".", sourceDomain.string().utf8().data(), targetDomain.string().utf8().data());

Did you mean to add logging even if the if-statement is false?

> LayoutTests/http/tests/resourceLoadStatistics/enforce-samesite-strict-based-on-top-frame-unique-redirects-to-database.html:33
> +            finishJSTest();

setEnableFeature(false, finishJSTest)?

> LayoutTests/http/tests/resourceLoadStatistics/enforce-samesite-strict-based-on-top-frame-unique-redirects-to-database.html:49
> +            finishJSTest();

Ditto.

> LayoutTests/http/tests/resourceLoadStatistics/enforce-samesite-strict-based-on-top-frame-unique-redirects-to.html:49
> +            finishJSTest();

Ditto

> LayoutTests/http/tests/resourceLoadStatistics/enforce-samesite-strict-based-on-top-frame-unique-redirects-to.html:74
> +            finishJSTest();

Ditto.
Comment 5 John Wilander 2020-03-30 17:13:31 PDT
(In reply to katherine_cheney from comment #4)
> Comment on attachment 394957 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=394957&action=review
> 
> > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:1653
> > +        return;
> 
> Probably need to call the completionHandler here in case of a database I/O
> error.

Good catch! Will fix.

> > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:1718
> >          ASSERT_NOT_REACHED();
> 
> Nice catch!

Yeah, I was working my way thorough existing functionality to design mine and came across this copy pasta.

> > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2068
> > +    result = ensureResourceStatisticsForRegistrableDomain(redirectDomain);
> 
> This is not necessary, it is done already in
> ResourceLoadStatisticsDatabaseStore::ensureAndMakeDomainList.

I kind of suspected that since we hadn't seen issues in testing. I'll just remove the comment then.

> > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:2280
> > +
> 
> Nice! :)

Yes, I find this part especially nice.

> > Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:455
> > +                RELEASE_LOG_INFO_IF(debugLoggingEnabled(), ITPDebug, "Did set %" PUBLIC_LOG_STRING " as making a top frame redirect to %" PUBLIC_LOG_STRING ".", sourceDomain.string().utf8().data(), targetDomain.string().utf8().data());
> 
> Did you mean to add logging even if the if-statement is false?

Yes, since the two if statements are only false if the entry already exists and I wanted the log to show the event for any developer looking.

> > LayoutTests/http/tests/resourceLoadStatistics/enforce-samesite-strict-based-on-top-frame-unique-redirects-to-database.html:33
> > +            finishJSTest();
> 
> setEnableFeature(false, finishJSTest)?

Good catch!

> > LayoutTests/http/tests/resourceLoadStatistics/enforce-samesite-strict-based-on-top-frame-unique-redirects-to-database.html:49
> > +            finishJSTest();
> 
> Ditto.
> 
> > LayoutTests/http/tests/resourceLoadStatistics/enforce-samesite-strict-based-on-top-frame-unique-redirects-to.html:49
> > +            finishJSTest();
> 
> Ditto
> 
> > LayoutTests/http/tests/resourceLoadStatistics/enforce-samesite-strict-based-on-top-frame-unique-redirects-to.html:74
> > +            finishJSTest();
> 
> Ditto.

Thanks for the review! I'll fix all the relevant things. (And thanks for the help on the DB query stuff.)
Comment 6 John Wilander 2020-03-30 17:36:41 PDT
Created attachment 394993 [details]
Patch
Comment 7 Brent Fulgham 2020-03-30 18:11:08 PDT
Comment on attachment 394993 [details]
Patch

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

> Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:1740
> +        RELEASE_LOG_ERROR_IF_ALLOWED(m_sessionID, "%p - ResourceLoadStatisticsDatabaseStore::clearUserInteraction failed to bind, error message: %{private}s", this, m_database.lastErrorMsg());

Oops! :-)
Comment 8 John Wilander 2020-03-30 18:41:53 PDT
Thanks, Brent! I'll put it on the queue given that the ios-wk2 bot was happy with the previous patch.
Comment 9 EWS 2020-03-30 18:42:57 PDT
ChangeLog entry in Source/WebCore/ChangeLog contains OOPS!.
Comment 10 John Wilander 2020-03-30 18:47:49 PDT
Created attachment 395001 [details]
Patch for landing
Comment 11 EWS 2020-03-30 19:45:44 PDT
Committed r259275: <https://trac.webkit.org/changeset/259275>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 395001 [details].