⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 293261 in webkit


Ignore:
Timestamp:
Apr 22, 2022, 4:02:57 PM (4 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r291589. rdar://problem/90511155

LayoutTests/imported/w3c:
BroadcastChannel instances in distinct opaque origins can communicate
https://bugs.webkit.org/show_bug.cgi?id=238090
<rdar://problem/90511155>

Reviewed by Alex Christensen.

Import web-platform-tests test coverage.

  • web-platform-tests/webmessaging/broadcastchannel/opaque-origin-expected.txt: Added.
  • web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html: Added.
  • web-platform-tests/webmessaging/broadcastchannel/w3c-import.log:

Source/WebCore:
BroadcastChannel instances in distinct opaque origins can communicate
https://bugs.webkit.org/show_bug.cgi?id=238090
<rdar://problem/90511155>

Reviewed by Alex Christensen.

The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel,
which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty
SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from
unique SecurityOrigins, they would compare as equal.

To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar
to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData
objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins
would not be equal but the same unique SecurityOrigin would be. I then used this new
PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of
ClientOrigin. This allows communication between several BroadcastChannels from the same
unique origin, while preventing communication between distinct opaque origins.

When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve
the Network Process at all since the destination can only be in the same WebProcess.

Test: imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html

  • Headers.cmake:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/BroadcastChannel.cpp: (WebCore::shouldPartitionOrigin): (WebCore::BroadcastChannel::MainThreadBridge::registerChannel): (WebCore::BroadcastChannel::MainThreadBridge::unregisterChannel): (WebCore::BroadcastChannel::MainThreadBridge::postMessage):
  • dom/BroadcastChannelRegistry.h:
  • loader/EmptyClients.cpp:
  • page/PartitionedSecurityOrigin.h: Added. (WebCore::PartitionedSecurityOrigin::PartitionedSecurityOrigin): (WebCore::PartitionedSecurityOrigin::isHashTableDeletedValue const): (WebCore::PartitionedSecurityOrigin::isHashTableEmptyValue const): (WebCore::operator==): (WTF::add): (WTF::PartitionedSecurityOriginHash::hash): (WTF::PartitionedSecurityOriginHash::equal): (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::emptyValue): (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::constructEmptyValue): (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::isEmptyValue): (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::peek): (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::take):

Source/WebKit:
BroadcastChannel instances in distinct opaque origins can communicate
https://bugs.webkit.org/show_bug.cgi?id=238090
<rdar://problem/90511155>

Reviewed by Alex Christensen.

The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel,
which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty
SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from
unique SecurityOrigins, they would compare as equal.

To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar
to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData
objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins
would not be equal but the same unique SecurityOrigin would be. I then used this new
PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of
ClientOrigin. This allows communication between several BroadcastChannels from the same
unique origin, while preventing communication between distinct opaque origins.

When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve
the Network Process at all since the destination can only be in the same WebProcess.

  • WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp: (WebKit::toClientOrigin): (WebKit::WebBroadcastChannelRegistry::registerChannel): (WebKit::WebBroadcastChannelRegistry::unregisterChannel): (WebKit::WebBroadcastChannelRegistry::postMessage): (WebKit::WebBroadcastChannelRegistry::postMessageLocally): (WebKit::WebBroadcastChannelRegistry::postMessageToRemote): (WebKit::WebBroadcastChannelRegistry::networkProcessCrashed):
  • WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h:

Source/WebKitLegacy:
Dust off Mac CMake build
https://bugs.webkit.org/show_bug.cgi?id=238121

Reviewed by Yusuke Suzuki.

  • PlatformMac.cmake:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291589 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-613.2.7.1-branch
Files:
4 added
20 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-613.2.7.1-branch/LayoutTests/imported/w3c/ChangeLog

    r293139 r293261  
     12022-04-22  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r291589. rdar://problem/90511155
     4
     5    LayoutTests/imported/w3c:
     6    BroadcastChannel instances in distinct opaque origins can communicate
     7    https://bugs.webkit.org/show_bug.cgi?id=238090
     8    <rdar://problem/90511155>
     9   
     10    Reviewed by Alex Christensen.
     11   
     12    Import web-platform-tests test coverage.
     13   
     14    * web-platform-tests/webmessaging/broadcastchannel/opaque-origin-expected.txt: Added.
     15    * web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html: Added.
     16    * web-platform-tests/webmessaging/broadcastchannel/w3c-import.log:
     17   
     18    Source/WebCore:
     19    BroadcastChannel instances in distinct opaque origins can communicate
     20    https://bugs.webkit.org/show_bug.cgi?id=238090
     21    <rdar://problem/90511155>
     22   
     23    Reviewed by Alex Christensen.
     24   
     25    The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel,
     26    which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty
     27    SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from
     28    unique SecurityOrigins, they would compare as equal.
     29   
     30    To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar
     31    to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData
     32    objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins
     33    would not be equal but the same unique SecurityOrigin would be. I then used this new
     34    PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of
     35    ClientOrigin. This allows communication between several BroadcastChannels from the same
     36    unique origin, while preventing communication between distinct opaque origins.
     37   
     38    When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve
     39    the Network Process at all since the destination can only be in the same WebProcess.
     40   
     41    Test: imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html
     42   
     43    * Headers.cmake:
     44    * WebCore.xcodeproj/project.pbxproj:
     45    * dom/BroadcastChannel.cpp:
     46    (WebCore::shouldPartitionOrigin):
     47    (WebCore::BroadcastChannel::MainThreadBridge::registerChannel):
     48    (WebCore::BroadcastChannel::MainThreadBridge::unregisterChannel):
     49    (WebCore::BroadcastChannel::MainThreadBridge::postMessage):
     50    * dom/BroadcastChannelRegistry.h:
     51    * loader/EmptyClients.cpp:
     52    * page/PartitionedSecurityOrigin.h: Added.
     53    (WebCore::PartitionedSecurityOrigin::PartitionedSecurityOrigin):
     54    (WebCore::PartitionedSecurityOrigin::isHashTableDeletedValue const):
     55    (WebCore::PartitionedSecurityOrigin::isHashTableEmptyValue const):
     56    (WebCore::operator==):
     57    (WTF::add):
     58    (WTF::PartitionedSecurityOriginHash::hash):
     59    (WTF::PartitionedSecurityOriginHash::equal):
     60    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::emptyValue):
     61    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::constructEmptyValue):
     62    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::isEmptyValue):
     63    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::peek):
     64    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::take):
     65   
     66    Source/WebKit:
     67    BroadcastChannel instances in distinct opaque origins can communicate
     68    https://bugs.webkit.org/show_bug.cgi?id=238090
     69    <rdar://problem/90511155>
     70   
     71    Reviewed by Alex Christensen.
     72   
     73    The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel,
     74    which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty
     75    SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from
     76    unique SecurityOrigins, they would compare as equal.
     77   
     78    To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar
     79    to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData
     80    objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins
     81    would not be equal but the same unique SecurityOrigin would be. I then used this new
     82    PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of
     83    ClientOrigin. This allows communication between several BroadcastChannels from the same
     84    unique origin, while preventing communication between distinct opaque origins.
     85   
     86    When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve
     87    the Network Process at all since the destination can only be in the same WebProcess.
     88   
     89    * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp:
     90    (WebKit::toClientOrigin):
     91    (WebKit::WebBroadcastChannelRegistry::registerChannel):
     92    (WebKit::WebBroadcastChannelRegistry::unregisterChannel):
     93    (WebKit::WebBroadcastChannelRegistry::postMessage):
     94    (WebKit::WebBroadcastChannelRegistry::postMessageLocally):
     95    (WebKit::WebBroadcastChannelRegistry::postMessageToRemote):
     96    (WebKit::WebBroadcastChannelRegistry::networkProcessCrashed):
     97    * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h:
     98   
     99    Source/WebKitLegacy:
     100    Dust off Mac CMake build
     101    https://bugs.webkit.org/show_bug.cgi?id=238121
     102   
     103    Reviewed by Yusuke Suzuki.
     104   
     105    * PlatformMac.cmake:
     106   
     107    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291589 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     108
     109    2022-03-21  Chris Dumez  <cdumez@apple.com>
     110
     111            BroadcastChannel instances in distinct opaque origins can communicate
     112            https://bugs.webkit.org/show_bug.cgi?id=238090
     113            <rdar://problem/90511155>
     114
     115            Reviewed by Alex Christensen.
     116
     117            Import web-platform-tests test coverage.
     118
     119            * web-platform-tests/webmessaging/broadcastchannel/opaque-origin-expected.txt: Added.
     120            * web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html: Added.
     121            * web-platform-tests/webmessaging/broadcastchannel/w3c-import.log:
     122
    11232022-04-18  Kocsen Chung  <kocsen_chung@apple.com>
    2124
  • branches/safari-613.2.7.1-branch/LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/w3c-import.log

    r293139 r293261  
    2020/LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/detached-iframe.html
    2121/LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/interface.any.js
     22/LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html
    2223/LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/ordering.html
    2324/LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/origin.window.js
  • branches/safari-613.2.7.1-branch/Source/WebCore/ChangeLog

    r293250 r293261  
     12022-04-22  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r291589. rdar://problem/90511155
     4
     5    LayoutTests/imported/w3c:
     6    BroadcastChannel instances in distinct opaque origins can communicate
     7    https://bugs.webkit.org/show_bug.cgi?id=238090
     8    <rdar://problem/90511155>
     9   
     10    Reviewed by Alex Christensen.
     11   
     12    Import web-platform-tests test coverage.
     13   
     14    * web-platform-tests/webmessaging/broadcastchannel/opaque-origin-expected.txt: Added.
     15    * web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html: Added.
     16    * web-platform-tests/webmessaging/broadcastchannel/w3c-import.log:
     17   
     18    Source/WebCore:
     19    BroadcastChannel instances in distinct opaque origins can communicate
     20    https://bugs.webkit.org/show_bug.cgi?id=238090
     21    <rdar://problem/90511155>
     22   
     23    Reviewed by Alex Christensen.
     24   
     25    The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel,
     26    which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty
     27    SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from
     28    unique SecurityOrigins, they would compare as equal.
     29   
     30    To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar
     31    to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData
     32    objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins
     33    would not be equal but the same unique SecurityOrigin would be. I then used this new
     34    PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of
     35    ClientOrigin. This allows communication between several BroadcastChannels from the same
     36    unique origin, while preventing communication between distinct opaque origins.
     37   
     38    When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve
     39    the Network Process at all since the destination can only be in the same WebProcess.
     40   
     41    Test: imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html
     42   
     43    * Headers.cmake:
     44    * WebCore.xcodeproj/project.pbxproj:
     45    * dom/BroadcastChannel.cpp:
     46    (WebCore::shouldPartitionOrigin):
     47    (WebCore::BroadcastChannel::MainThreadBridge::registerChannel):
     48    (WebCore::BroadcastChannel::MainThreadBridge::unregisterChannel):
     49    (WebCore::BroadcastChannel::MainThreadBridge::postMessage):
     50    * dom/BroadcastChannelRegistry.h:
     51    * loader/EmptyClients.cpp:
     52    * page/PartitionedSecurityOrigin.h: Added.
     53    (WebCore::PartitionedSecurityOrigin::PartitionedSecurityOrigin):
     54    (WebCore::PartitionedSecurityOrigin::isHashTableDeletedValue const):
     55    (WebCore::PartitionedSecurityOrigin::isHashTableEmptyValue const):
     56    (WebCore::operator==):
     57    (WTF::add):
     58    (WTF::PartitionedSecurityOriginHash::hash):
     59    (WTF::PartitionedSecurityOriginHash::equal):
     60    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::emptyValue):
     61    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::constructEmptyValue):
     62    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::isEmptyValue):
     63    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::peek):
     64    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::take):
     65   
     66    Source/WebKit:
     67    BroadcastChannel instances in distinct opaque origins can communicate
     68    https://bugs.webkit.org/show_bug.cgi?id=238090
     69    <rdar://problem/90511155>
     70   
     71    Reviewed by Alex Christensen.
     72   
     73    The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel,
     74    which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty
     75    SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from
     76    unique SecurityOrigins, they would compare as equal.
     77   
     78    To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar
     79    to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData
     80    objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins
     81    would not be equal but the same unique SecurityOrigin would be. I then used this new
     82    PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of
     83    ClientOrigin. This allows communication between several BroadcastChannels from the same
     84    unique origin, while preventing communication between distinct opaque origins.
     85   
     86    When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve
     87    the Network Process at all since the destination can only be in the same WebProcess.
     88   
     89    * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp:
     90    (WebKit::toClientOrigin):
     91    (WebKit::WebBroadcastChannelRegistry::registerChannel):
     92    (WebKit::WebBroadcastChannelRegistry::unregisterChannel):
     93    (WebKit::WebBroadcastChannelRegistry::postMessage):
     94    (WebKit::WebBroadcastChannelRegistry::postMessageLocally):
     95    (WebKit::WebBroadcastChannelRegistry::postMessageToRemote):
     96    (WebKit::WebBroadcastChannelRegistry::networkProcessCrashed):
     97    * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h:
     98   
     99    Source/WebKitLegacy:
     100    Dust off Mac CMake build
     101    https://bugs.webkit.org/show_bug.cgi?id=238121
     102   
     103    Reviewed by Yusuke Suzuki.
     104   
     105    * PlatformMac.cmake:
     106   
     107    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291589 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     108
     109    2022-03-21  Chris Dumez  <cdumez@apple.com>
     110
     111            BroadcastChannel instances in distinct opaque origins can communicate
     112            https://bugs.webkit.org/show_bug.cgi?id=238090
     113            <rdar://problem/90511155>
     114
     115            Reviewed by Alex Christensen.
     116
     117            The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel,
     118            which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty
     119            SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from
     120            unique SecurityOrigins, they would compare as equal.
     121
     122            To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar
     123            to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData
     124            objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins
     125            would not be equal but the same unique SecurityOrigin would be. I then used this new
     126            PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of
     127            ClientOrigin. This allows communication between several BroadcastChannels from the same
     128            unique origin, while preventing communication between distinct opaque origins.
     129
     130            When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve
     131            the Network Process at all since the destination can only be in the same WebProcess.
     132
     133            Test: imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html
     134
     135            * Headers.cmake:
     136            * WebCore.xcodeproj/project.pbxproj:
     137            * dom/BroadcastChannel.cpp:
     138            (WebCore::shouldPartitionOrigin):
     139            (WebCore::BroadcastChannel::MainThreadBridge::registerChannel):
     140            (WebCore::BroadcastChannel::MainThreadBridge::unregisterChannel):
     141            (WebCore::BroadcastChannel::MainThreadBridge::postMessage):
     142            * dom/BroadcastChannelRegistry.h:
     143            * loader/EmptyClients.cpp:
     144            * page/PartitionedSecurityOrigin.h: Added.
     145            (WebCore::PartitionedSecurityOrigin::PartitionedSecurityOrigin):
     146            (WebCore::PartitionedSecurityOrigin::isHashTableDeletedValue const):
     147            (WebCore::PartitionedSecurityOrigin::isHashTableEmptyValue const):
     148            (WebCore::operator==):
     149            (WTF::add):
     150            (WTF::PartitionedSecurityOriginHash::hash):
     151            (WTF::PartitionedSecurityOriginHash::equal):
     152            (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::emptyValue):
     153            (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::constructEmptyValue):
     154            (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::isEmptyValue):
     155            (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::peek):
     156            (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::take):
     157
    11582022-04-22  Russell Epstein  <repstein@apple.com>
    2159
  • branches/safari-613.2.7.1-branch/Source/WebCore/Headers.cmake

    r293139 r293261  
    11261126    page/PageOverlayController.h
    11271127    page/PagePasteboardContext.h
     1128    page/PartitionedSecurityOrigin.h
    11281129    page/PerformanceLogging.h
    11291130    page/PerformanceLoggingClient.h
  • branches/safari-613.2.7.1-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r293139 r293261  
    13471347                468344E01EDDFAAA00B7795B /* DOMRectList.h in Headers */ = {isa = PBXBuildFile; fileRef = 468344DE1EDDFA5F00B7795B /* DOMRectList.h */; settings = {ATTRIBUTES = (Private, ); }; };
    13481348                4688EE3C26DD2610002AF5C4 /* CrossOriginMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 4688EE3A26DD260C002AF5C4 /* CrossOriginMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1349                46893B8427E8D74C002CC13D /* PartitionedSecurityOrigin.h in Headers */ = {isa = PBXBuildFile; fileRef = 46893B8327E8D716002CC13D /* PartitionedSecurityOrigin.h */; settings = {ATTRIBUTES = (Private, ); }; };
    13491350                469CCCFE269D021C006E0314 /* BroadcastChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 469CCCFC269D0202006E0314 /* BroadcastChannel.h */; settings = {ATTRIBUTES = (Private, ); }; };
    13501351                469D77B82701625100142FA6 /* NavigationRequester.h in Headers */ = {isa = PBXBuildFile; fileRef = 469D77B62701625000142FA6 /* NavigationRequester.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    92169217                468344DE1EDDFA5F00B7795B /* DOMRectList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMRectList.h; sourceTree = "<group>"; };
    92179218                4688EE3A26DD260C002AF5C4 /* CrossOriginMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CrossOriginMode.h; sourceTree = "<group>"; };
     9219                46893B8327E8D716002CC13D /* PartitionedSecurityOrigin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PartitionedSecurityOrigin.h; sourceTree = "<group>"; };
    92189220                468B8BDE25CC849300F67822 /* JSBaseAudioContextCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSBaseAudioContextCustom.cpp; sourceTree = "<group>"; };
    92199221                469CCCFA269D0202006E0314 /* BroadcastChannel.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BroadcastChannel.cpp; sourceTree = "<group>"; };
     
    2408524087                                371E65CD13661EED00BEEDB0 /* PageSerializer.cpp */,
    2408624088                                371E65CB13661EDC00BEEDB0 /* PageSerializer.h */,
     24089                                46893B8327E8D716002CC13D /* PartitionedSecurityOrigin.h */,
    2408724090                                BC4A53282560563B0028C592 /* PDFImageCachingPolicy.h */,
    2408824091                                7C72471E2516758800C363CD /* Performance+NavigationTiming.idl */,
     
    3637336376                                5C4A0FDA25C3449A00D9EE97 /* ParsedRequestRange.h in Headers */,
    3637436377                                536D5A23193E8E0C00CE4CAB /* ParsingUtilities.h in Headers */,
     36378                                46893B8427E8D74C002CC13D /* PartitionedSecurityOrigin.h in Headers */,
    3637536379                                F55B3DCA1251F12D003EF269 /* PasswordInputType.h in Headers */,
    3637636380                                4B2708C70AF19EE40065127F /* Pasteboard.h in Headers */,
  • branches/safari-613.2.7.1-branch/Source/WebCore/dom/BroadcastChannel.cpp

    r293139 r293261  
    3131#include "MessageEvent.h"
    3232#include "Page.h"
     33#include "PartitionedSecurityOrigin.h"
    3334#include "SecurityOrigin.h"
    3435#include "SerializedScriptValue.h"
     
    8788    const BroadcastChannelIdentifier m_identifier;
    8889    const String m_name; // Main thread only.
    89     ClientOrigin m_origin; // Main thread only.
     90    std::optional<PartitionedSecurityOrigin> m_origin; // Main thread only.
    9091};
    9192
     
    121122{
    122123    ensureOnMainThread([this, contextIdentifier = m_broadcastChannel->scriptExecutionContext()->identifier()](auto& document) {
    123         m_origin = { shouldPartitionOrigin(document) ? document.topOrigin().data() : document.securityOrigin().data(), document.securityOrigin().data() };
     124        m_origin = PartitionedSecurityOrigin { shouldPartitionOrigin(document) ? document.topOrigin() : document.securityOrigin(), document.securityOrigin() };
    124125        if (auto* page = document.page())
    125             page->broadcastChannelRegistry().registerChannel(m_origin, m_name, m_identifier);
     126            page->broadcastChannelRegistry().registerChannel(*m_origin, m_name, m_identifier);
    126127        channelToContextIdentifier().add(m_identifier, contextIdentifier);
    127128    });
     
    132133    ensureOnMainThread([this](auto& document) {
    133134        if (auto* page = document.page())
    134             page->broadcastChannelRegistry().unregisterChannel(m_origin, m_name, m_identifier);
     135            page->broadcastChannelRegistry().unregisterChannel(*m_origin, m_name, m_identifier);
    135136        channelToContextIdentifier().remove(m_identifier);
    136137    });
     
    145146
    146147        auto blobHandles = message->blobHandles();
    147         page->broadcastChannelRegistry().postMessage(m_origin, m_name, m_identifier, WTFMove(message), [blobHandles = WTFMove(blobHandles)] {
     148        page->broadcastChannelRegistry().postMessage(*m_origin, m_name, m_identifier, WTFMove(message), [blobHandles = WTFMove(blobHandles)] {
    148149            // Keeps Blob data inside messageData alive until the message has been delivered.
    149150        });
  • branches/safari-613.2.7.1-branch/Source/WebCore/dom/BroadcastChannelRegistry.h

    r293139 r293261  
    3232namespace WebCore {
    3333
     34struct PartitionedSecurityOrigin;
    3435class SerializedScriptValue;
    35 struct ClientOrigin;
    3636
    3737class BroadcastChannelRegistry : public RefCounted<BroadcastChannelRegistry> {
    3838public:
    3939    virtual ~BroadcastChannelRegistry() { }
    40     virtual void registerChannel(const ClientOrigin&, const String& name, BroadcastChannelIdentifier) = 0;
    41     virtual void unregisterChannel(const ClientOrigin&, const String& name, BroadcastChannelIdentifier) = 0;
    42     virtual void postMessage(const ClientOrigin&, const String& name, BroadcastChannelIdentifier source, Ref<SerializedScriptValue>&&, CompletionHandler<void()>&&) = 0;
     40    virtual void registerChannel(const PartitionedSecurityOrigin&, const String& name, BroadcastChannelIdentifier) = 0;
     41    virtual void unregisterChannel(const PartitionedSecurityOrigin&, const String& name, BroadcastChannelIdentifier) = 0;
     42    virtual void postMessage(const PartitionedSecurityOrigin&, const String& name, BroadcastChannelIdentifier source, Ref<SerializedScriptValue>&&, CompletionHandler<void()>&&) = 0;
    4343};
    4444
  • branches/safari-613.2.7.1-branch/Source/WebCore/loader/EmptyClients.cpp

    r293139 r293261  
    11841184    EmptyBroadcastChannelRegistry() = default;
    11851185
    1186     void registerChannel(const ClientOrigin&, const String&, BroadcastChannelIdentifier) final { }
    1187     void unregisterChannel(const ClientOrigin&, const String&, BroadcastChannelIdentifier) final { }
    1188     void postMessage(const ClientOrigin&, const String&, BroadcastChannelIdentifier, Ref<SerializedScriptValue>&&, CompletionHandler<void()>&&) final { }
     1186    void registerChannel(const PartitionedSecurityOrigin&, const String&, BroadcastChannelIdentifier) final { }
     1187    void unregisterChannel(const PartitionedSecurityOrigin&, const String&, BroadcastChannelIdentifier) final { }
     1188    void postMessage(const PartitionedSecurityOrigin&, const String&, BroadcastChannelIdentifier, Ref<SerializedScriptValue>&&, CompletionHandler<void()>&&) final { }
    11891189};
    11901190
  • branches/safari-613.2.7.1-branch/Source/WebCore/page/SecurityOrigin.h

    r286821 r293261  
    307307}
    308308
     309inline void add(Hasher& hasher, const SecurityOrigin& origin)
     310{
     311    add(hasher, origin.protocol(), origin.host(), origin.port());
     312}
     313
    309314} // namespace WebCore
  • branches/safari-613.2.7.1-branch/Source/WebKit/ChangeLog

    r293248 r293261  
     12022-04-22  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r291589. rdar://problem/90511155
     4
     5    LayoutTests/imported/w3c:
     6    BroadcastChannel instances in distinct opaque origins can communicate
     7    https://bugs.webkit.org/show_bug.cgi?id=238090
     8    <rdar://problem/90511155>
     9   
     10    Reviewed by Alex Christensen.
     11   
     12    Import web-platform-tests test coverage.
     13   
     14    * web-platform-tests/webmessaging/broadcastchannel/opaque-origin-expected.txt: Added.
     15    * web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html: Added.
     16    * web-platform-tests/webmessaging/broadcastchannel/w3c-import.log:
     17   
     18    Source/WebCore:
     19    BroadcastChannel instances in distinct opaque origins can communicate
     20    https://bugs.webkit.org/show_bug.cgi?id=238090
     21    <rdar://problem/90511155>
     22   
     23    Reviewed by Alex Christensen.
     24   
     25    The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel,
     26    which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty
     27    SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from
     28    unique SecurityOrigins, they would compare as equal.
     29   
     30    To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar
     31    to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData
     32    objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins
     33    would not be equal but the same unique SecurityOrigin would be. I then used this new
     34    PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of
     35    ClientOrigin. This allows communication between several BroadcastChannels from the same
     36    unique origin, while preventing communication between distinct opaque origins.
     37   
     38    When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve
     39    the Network Process at all since the destination can only be in the same WebProcess.
     40   
     41    Test: imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html
     42   
     43    * Headers.cmake:
     44    * WebCore.xcodeproj/project.pbxproj:
     45    * dom/BroadcastChannel.cpp:
     46    (WebCore::shouldPartitionOrigin):
     47    (WebCore::BroadcastChannel::MainThreadBridge::registerChannel):
     48    (WebCore::BroadcastChannel::MainThreadBridge::unregisterChannel):
     49    (WebCore::BroadcastChannel::MainThreadBridge::postMessage):
     50    * dom/BroadcastChannelRegistry.h:
     51    * loader/EmptyClients.cpp:
     52    * page/PartitionedSecurityOrigin.h: Added.
     53    (WebCore::PartitionedSecurityOrigin::PartitionedSecurityOrigin):
     54    (WebCore::PartitionedSecurityOrigin::isHashTableDeletedValue const):
     55    (WebCore::PartitionedSecurityOrigin::isHashTableEmptyValue const):
     56    (WebCore::operator==):
     57    (WTF::add):
     58    (WTF::PartitionedSecurityOriginHash::hash):
     59    (WTF::PartitionedSecurityOriginHash::equal):
     60    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::emptyValue):
     61    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::constructEmptyValue):
     62    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::isEmptyValue):
     63    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::peek):
     64    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::take):
     65   
     66    Source/WebKit:
     67    BroadcastChannel instances in distinct opaque origins can communicate
     68    https://bugs.webkit.org/show_bug.cgi?id=238090
     69    <rdar://problem/90511155>
     70   
     71    Reviewed by Alex Christensen.
     72   
     73    The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel,
     74    which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty
     75    SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from
     76    unique SecurityOrigins, they would compare as equal.
     77   
     78    To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar
     79    to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData
     80    objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins
     81    would not be equal but the same unique SecurityOrigin would be. I then used this new
     82    PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of
     83    ClientOrigin. This allows communication between several BroadcastChannels from the same
     84    unique origin, while preventing communication between distinct opaque origins.
     85   
     86    When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve
     87    the Network Process at all since the destination can only be in the same WebProcess.
     88   
     89    * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp:
     90    (WebKit::toClientOrigin):
     91    (WebKit::WebBroadcastChannelRegistry::registerChannel):
     92    (WebKit::WebBroadcastChannelRegistry::unregisterChannel):
     93    (WebKit::WebBroadcastChannelRegistry::postMessage):
     94    (WebKit::WebBroadcastChannelRegistry::postMessageLocally):
     95    (WebKit::WebBroadcastChannelRegistry::postMessageToRemote):
     96    (WebKit::WebBroadcastChannelRegistry::networkProcessCrashed):
     97    * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h:
     98   
     99    Source/WebKitLegacy:
     100    Dust off Mac CMake build
     101    https://bugs.webkit.org/show_bug.cgi?id=238121
     102   
     103    Reviewed by Yusuke Suzuki.
     104   
     105    * PlatformMac.cmake:
     106   
     107    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291589 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     108
     109    2022-03-21  Chris Dumez  <cdumez@apple.com>
     110
     111            BroadcastChannel instances in distinct opaque origins can communicate
     112            https://bugs.webkit.org/show_bug.cgi?id=238090
     113            <rdar://problem/90511155>
     114
     115            Reviewed by Alex Christensen.
     116
     117            The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel,
     118            which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty
     119            SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from
     120            unique SecurityOrigins, they would compare as equal.
     121
     122            To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar
     123            to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData
     124            objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins
     125            would not be equal but the same unique SecurityOrigin would be. I then used this new
     126            PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of
     127            ClientOrigin. This allows communication between several BroadcastChannels from the same
     128            unique origin, while preventing communication between distinct opaque origins.
     129
     130            When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve
     131            the Network Process at all since the destination can only be in the same WebProcess.
     132
     133            * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp:
     134            (WebKit::toClientOrigin):
     135            (WebKit::WebBroadcastChannelRegistry::registerChannel):
     136            (WebKit::WebBroadcastChannelRegistry::unregisterChannel):
     137            (WebKit::WebBroadcastChannelRegistry::postMessage):
     138            (WebKit::WebBroadcastChannelRegistry::postMessageLocally):
     139            (WebKit::WebBroadcastChannelRegistry::postMessageToRemote):
     140            (WebKit::WebBroadcastChannelRegistry::networkProcessCrashed):
     141            * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h:
     142
    11432022-04-22  Russell Epstein  <repstein@apple.com>
    2144
  • branches/safari-613.2.7.1-branch/Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.cpp

    r293139 r293261  
    2727#include "NetworkBroadcastChannelRegistry.h"
    2828
     29#include "NetworkProcessProxyMessages.h"
    2930#include "WebBroadcastChannelRegistryMessages.h"
    3031#include <WebCore/MessageWithMessagePorts.h>
     
    3334namespace WebKit {
    3435
    35 NetworkBroadcastChannelRegistry::NetworkBroadcastChannelRegistry() = default;
     36#define REGISTRY_MESSAGE_CHECK(assertion) REGISTRY_MESSAGE_CHECK_COMPLETION(assertion, (void)0)
     37#define REGISTRY_MESSAGE_CHECK_COMPLETION(assertion, completion) do { \
     38    ASSERT(assertion); \
     39    if (UNLIKELY(!(assertion))) { \
     40        if (auto webProcessIdentifier = m_networkProcess->webProcessIdentifierForConnection(connection)) \
     41            m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::TerminateWebProcess(webProcessIdentifier), 0); \
     42        { completion; } \
     43        return; \
     44    } \
     45} while (0)
     46
     47static bool isValidClientOrigin(const WebCore::ClientOrigin& clientOrigin)
     48{
     49    return !clientOrigin.topOrigin.isEmpty() && !clientOrigin.clientOrigin.isEmpty();
     50}
     51
     52NetworkBroadcastChannelRegistry::NetworkBroadcastChannelRegistry(NetworkProcess& networkProcess)
     53    : m_networkProcess(networkProcess)
     54{
     55}
    3656
    3757void NetworkBroadcastChannelRegistry::registerChannel(IPC::Connection& connection, const WebCore::ClientOrigin& origin, const String& name)
    3858{
     59    REGISTRY_MESSAGE_CHECK(isValidClientOrigin(origin));
     60
    3961    auto& channelsForOrigin = m_broadcastChannels.ensure(origin, [] { return NameToConnectionIdentifiersMap { }; }).iterator->value;
    4062    auto& connectionIdentifiersForName = channelsForOrigin.ensure(name, [] { return Vector<IPC::Connection::UniqueID> { }; }).iterator->value;
     
    4567void NetworkBroadcastChannelRegistry::unregisterChannel(IPC::Connection& connection, const WebCore::ClientOrigin& origin, const String& name)
    4668{
     69    REGISTRY_MESSAGE_CHECK(isValidClientOrigin(origin));
     70
    4771    auto channelsForOriginIterator = m_broadcastChannels.find(origin);
    4872    ASSERT(channelsForOriginIterator != m_broadcastChannels.end());
     
    6084void NetworkBroadcastChannelRegistry::postMessage(IPC::Connection& connection, const WebCore::ClientOrigin& origin, const String& name, WebCore::MessageWithMessagePorts&& message, CompletionHandler<void()>&& completionHandler)
    6185{
     86    REGISTRY_MESSAGE_CHECK_COMPLETION(isValidClientOrigin(origin), completionHandler());
     87
    6288    auto channelsForOriginIterator = m_broadcastChannels.find(origin);
    6389    ASSERT(channelsForOriginIterator != m_broadcastChannels.end());
     
    102128}
    103129
     130#undef REGISTRY_MESSAGE_CHECK
     131#undef REGISTRY_MESSAGE_CHECK_COMPLETION
     132
    104133} // namespace WebKit
  • branches/safari-613.2.7.1-branch/Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.h

    r293139 r293261  
    3737namespace WebKit {
    3838
     39class NetworkProcess;
     40
    3941class NetworkBroadcastChannelRegistry {
    4042    WTF_MAKE_FAST_ALLOCATED;
    4143public:
    42     NetworkBroadcastChannelRegistry();
     44    explicit NetworkBroadcastChannelRegistry(NetworkProcess&);
    4345
    4446    void removeConnection(IPC::Connection&);
     
    5153
    5254private:
     55    Ref<NetworkProcess> m_networkProcess;
    5356    using NameToConnectionIdentifiersMap = HashMap<String, Vector<IPC::Connection::UniqueID>>;
    5457    HashMap<WebCore::ClientOrigin, NameToConnectionIdentifiersMap> m_broadcastChannels;
  • branches/safari-613.2.7.1-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r293139 r293261  
    26062606}
    26072607
     2608WebCore::ProcessIdentifier NetworkProcess::webProcessIdentifierForConnection(IPC::Connection& connection) const
     2609{
     2610    for (auto& [processIdentifier, webConnection] : m_webProcessConnections) {
     2611        if (&webConnection->connection() == &connection)
     2612            return processIdentifier;
     2613    }
     2614    return { };
     2615}
     2616
    26082617NetworkConnectionToWebProcess* NetworkProcess::webProcessConnection(ProcessIdentifier identifier) const
    26092618{
  • branches/safari-613.2.7.1-branch/Source/WebKit/NetworkProcess/NetworkProcess.h

    r293139 r293261  
    336336
    337337    NetworkConnectionToWebProcess* webProcessConnection(WebCore::ProcessIdentifier) const;
     338    WebCore::ProcessIdentifier webProcessIdentifierForConnection(IPC::Connection&) const;
    338339    WebCore::MessagePortChannelRegistry& messagePortChannelRegistry() { return m_messagePortChannelRegistry; }
    339340
  • branches/safari-613.2.7.1-branch/Source/WebKit/NetworkProcess/NetworkSession.cpp

    r293139 r293261  
    126126    , m_privateClickMeasurement(managerOrProxy(*this, networkProcess, parameters))
    127127    , m_privateClickMeasurementDebugModeEnabled(parameters.enablePrivateClickMeasurementDebugMode)
    128     , m_broadcastChannelRegistry(makeUniqueRef<NetworkBroadcastChannelRegistry>())
     128    , m_broadcastChannelRegistry(makeUniqueRef<NetworkBroadcastChannelRegistry>(networkProcess))
    129129    , m_testSpeedMultiplier(parameters.testSpeedMultiplier)
    130130    , m_allowsServerPreconnect(parameters.allowsServerPreconnect)
  • branches/safari-613.2.7.1-branch/Source/WebKit/WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp

    r293139 r293261  
    4141}
    4242
    43 void WebBroadcastChannelRegistry::registerChannel(const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
     43// Unique origins are only stored in process in m_channelsPerOrigin and never sent to the NetworkProcess as a ClientOrigin.
     44// The identity of unique origins wouldn't be preserved when serializing them as a SecurityOriginData (via ClientOrigin).
     45// Since BroadcastChannels from a unique origin can only communicate with other BroadcastChannels from the same unique origin,
     46// the destination channels have to be within the same WebProcess anyway.
     47static std::optional<WebCore::ClientOrigin> toClientOrigin(const WebCore::PartitionedSecurityOrigin& origin)
     48{
     49    if (origin.topOrigin->isUnique() || origin.clientOrigin->isUnique())
     50        return std::nullopt;
     51    return WebCore::ClientOrigin { origin.topOrigin->data(), origin.clientOrigin->data() };
     52}
     53
     54void WebBroadcastChannelRegistry::registerChannel(const WebCore::PartitionedSecurityOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
    4455{
    4556    auto& channelsForOrigin = m_channelsPerOrigin.ensure(origin, [] { return HashMap<String, Vector<WebCore::BroadcastChannelIdentifier>> { }; }).iterator->value;
     
    4758    channelsForName.append(identifier);
    4859
    49     if (channelsForName.size() == 1)
    50         networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::RegisterChannel { origin, name }, 0);
     60    if (channelsForName.size() == 1) {
     61        if (auto clientOrigin = toClientOrigin(origin))
     62            networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::RegisterChannel { *clientOrigin, name }, 0);
     63    }
    5164}
    5265
    53 void WebBroadcastChannelRegistry::unregisterChannel(const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
     66void WebBroadcastChannelRegistry::unregisterChannel(const WebCore::PartitionedSecurityOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
    5467{
    5568    auto channelsPerOriginIterator = m_channelsPerOrigin.find(origin);
     
    6982
    7083    channelsForOrigin.remove(channelsForOriginIterator);
    71     networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::UnregisterChannel { origin, name }, 0);
     84    if (auto clientOrigin = toClientOrigin(origin))
     85        networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::UnregisterChannel { *clientOrigin, name }, 0);
    7286
    7387    if (channelsForOrigin.isEmpty())
     
    7589}
    7690
    77 void WebBroadcastChannelRegistry::postMessage(const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&& message, CompletionHandler<void()>&& completionHandler)
     91void WebBroadcastChannelRegistry::postMessage(const WebCore::PartitionedSecurityOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&& message, CompletionHandler<void()>&& completionHandler)
    7892{
    7993    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    8094    postMessageLocally(origin, name, source, message.copyRef(), callbackAggregator.copyRef());
    81     networkProcessConnection().sendWithAsyncReply(Messages::NetworkBroadcastChannelRegistry::PostMessage { origin, name, WebCore::MessageWithMessagePorts { WTFMove(message), { } } }, [callbackAggregator] { }, 0);
     95    if (auto clientOrigin = toClientOrigin(origin))
     96        networkProcessConnection().sendWithAsyncReply(Messages::NetworkBroadcastChannelRegistry::PostMessage { *clientOrigin, name, WebCore::MessageWithMessagePorts { WTFMove(message), { } } }, [callbackAggregator] { }, 0);
    8297}
    8398
    84 void WebBroadcastChannelRegistry::postMessageLocally(const WebCore::ClientOrigin& origin, const String& name, std::optional<WebCore::BroadcastChannelIdentifier> sourceInProcess, Ref<WebCore::SerializedScriptValue>&& message, Ref<WTF::CallbackAggregator>&& callbackAggregator)
     99void WebBroadcastChannelRegistry::postMessageLocally(const WebCore::PartitionedSecurityOrigin& origin, const String& name, std::optional<WebCore::BroadcastChannelIdentifier> sourceInProcess, Ref<WebCore::SerializedScriptValue>&& message, Ref<WTF::CallbackAggregator>&& callbackAggregator)
    85100{
    86101    auto channelsPerOriginIterator = m_channelsPerOrigin.find(origin);
     
    101116}
    102117
    103 void WebBroadcastChannelRegistry::postMessageToRemote(const WebCore::ClientOrigin& origin, const String& name, WebCore::MessageWithMessagePorts&& message, CompletionHandler<void()>&& completionHandler)
     118void WebBroadcastChannelRegistry::postMessageToRemote(const WebCore::ClientOrigin& clientOrigin, const String& name, WebCore::MessageWithMessagePorts&& message, CompletionHandler<void()>&& completionHandler)
    104119{
    105120    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     121    WebCore::PartitionedSecurityOrigin origin { clientOrigin.topOrigin.securityOrigin(), clientOrigin.clientOrigin.securityOrigin() };
    106122    postMessageLocally(origin, name, std::nullopt, *message.message, callbackAggregator.copyRef());
    107123}
     
    110126{
    111127    for (auto& [origin, channelsForOrigin] : m_channelsPerOrigin) {
     128        auto clientOrigin = toClientOrigin(origin);
     129        if (!clientOrigin)
     130            continue;
    112131        for (auto& name : channelsForOrigin.keys())
    113             networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::RegisterChannel { origin, name }, 0);
     132            networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::RegisterChannel { *clientOrigin, name }, 0);
    114133    }
    115134}
  • branches/safari-613.2.7.1-branch/Source/WebKit/WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h

    r293139 r293261  
    2929#include <WebCore/BroadcastChannelRegistry.h>
    3030#include <WebCore/ClientOrigin.h>
     31#include <WebCore/PartitionedSecurityOrigin.h>
     32#include <WebCore/SecurityOrigin.h>
    3133#include <wtf/HashMap.h>
    3234#include <wtf/Vector.h>
     
    4951    }
    5052
    51     void registerChannel(const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;
    52     void unregisterChannel(const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;
    53     void postMessage(const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&&, CompletionHandler<void()>&&) final;
     53    void registerChannel(const WebCore::PartitionedSecurityOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;
     54    void unregisterChannel(const WebCore::PartitionedSecurityOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;
     55    void postMessage(const WebCore::PartitionedSecurityOrigin&, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&&, CompletionHandler<void()>&&) final;
    5456
    5557    void networkProcessCrashed();
     
    6163
    6264    void postMessageToRemote(const WebCore::ClientOrigin&, const String& name, WebCore::MessageWithMessagePorts&&, CompletionHandler<void()>&&);
    63     void postMessageLocally(const WebCore::ClientOrigin&, const String& name, std::optional<WebCore::BroadcastChannelIdentifier> sourceInProcess, Ref<WebCore::SerializedScriptValue>&&, Ref<WTF::CallbackAggregator>&&);
     65    void postMessageLocally(const WebCore::PartitionedSecurityOrigin&, const String& name, std::optional<WebCore::BroadcastChannelIdentifier> sourceInProcess, Ref<WebCore::SerializedScriptValue>&&, Ref<WTF::CallbackAggregator>&&);
    6466
    65     HashMap<WebCore::ClientOrigin, HashMap<String, Vector<WebCore::BroadcastChannelIdentifier>>> m_channelsPerOrigin;
     67    HashMap<WebCore::PartitionedSecurityOrigin, HashMap<String, Vector<WebCore::BroadcastChannelIdentifier>>> m_channelsPerOrigin;
    6668};
    6769
  • branches/safari-613.2.7.1-branch/Source/WebKitLegacy/ChangeLog

    r293139 r293261  
    1 2022-01-24  Alan Coon  <alancoon@apple.com>
    2 
    3         Cherry-pick r288389. rdar://problem/85405320
    4 
    5     Disable CFURLCache in WebKit2
    6     https://bugs.webkit.org/show_bug.cgi?id=234988
    7     <rdar://problem/87619196>
     12022-04-22  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r291589. rdar://problem/90511155
     4
     5    LayoutTests/imported/w3c:
     6    BroadcastChannel instances in distinct opaque origins can communicate
     7    https://bugs.webkit.org/show_bug.cgi?id=238090
     8    <rdar://problem/90511155>
    89   
    9     Reviewed by Geoffrey Garen.
     10    Reviewed by Alex Christensen.
     11   
     12    Import web-platform-tests test coverage.
     13   
     14    * web-platform-tests/webmessaging/broadcastchannel/opaque-origin-expected.txt: Added.
     15    * web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html: Added.
     16    * web-platform-tests/webmessaging/broadcastchannel/w3c-import.log:
     17   
     18    Source/WebCore:
     19    BroadcastChannel instances in distinct opaque origins can communicate
     20    https://bugs.webkit.org/show_bug.cgi?id=238090
     21    <rdar://problem/90511155>
     22   
     23    Reviewed by Alex Christensen.
     24   
     25    The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel,
     26    which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty
     27    SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from
     28    unique SecurityOrigins, they would compare as equal.
     29   
     30    To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar
     31    to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData
     32    objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins
     33    would not be equal but the same unique SecurityOrigin would be. I then used this new
     34    PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of
     35    ClientOrigin. This allows communication between several BroadcastChannels from the same
     36    unique origin, while preventing communication between distinct opaque origins.
     37   
     38    When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve
     39    the Network Process at all since the destination can only be in the same WebProcess.
     40   
     41    Test: imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html
     42   
     43    * Headers.cmake:
     44    * WebCore.xcodeproj/project.pbxproj:
     45    * dom/BroadcastChannel.cpp:
     46    (WebCore::shouldPartitionOrigin):
     47    (WebCore::BroadcastChannel::MainThreadBridge::registerChannel):
     48    (WebCore::BroadcastChannel::MainThreadBridge::unregisterChannel):
     49    (WebCore::BroadcastChannel::MainThreadBridge::postMessage):
     50    * dom/BroadcastChannelRegistry.h:
     51    * loader/EmptyClients.cpp:
     52    * page/PartitionedSecurityOrigin.h: Added.
     53    (WebCore::PartitionedSecurityOrigin::PartitionedSecurityOrigin):
     54    (WebCore::PartitionedSecurityOrigin::isHashTableDeletedValue const):
     55    (WebCore::PartitionedSecurityOrigin::isHashTableEmptyValue const):
     56    (WebCore::operator==):
     57    (WTF::add):
     58    (WTF::PartitionedSecurityOriginHash::hash):
     59    (WTF::PartitionedSecurityOriginHash::equal):
     60    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::emptyValue):
     61    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::constructEmptyValue):
     62    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::isEmptyValue):
     63    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::peek):
     64    (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::take):
     65   
     66    Source/WebKit:
     67    BroadcastChannel instances in distinct opaque origins can communicate
     68    https://bugs.webkit.org/show_bug.cgi?id=238090
     69    <rdar://problem/90511155>
     70   
     71    Reviewed by Alex Christensen.
     72   
     73    The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel,
     74    which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty
     75    SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from
     76    unique SecurityOrigins, they would compare as equal.
     77   
     78    To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar
     79    to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData
     80    objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins
     81    would not be equal but the same unique SecurityOrigin would be. I then used this new
     82    PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of
     83    ClientOrigin. This allows communication between several BroadcastChannels from the same
     84    unique origin, while preventing communication between distinct opaque origins.
     85   
     86    When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve
     87    the Network Process at all since the destination can only be in the same WebProcess.
     88   
     89    * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp:
     90    (WebKit::toClientOrigin):
     91    (WebKit::WebBroadcastChannelRegistry::registerChannel):
     92    (WebKit::WebBroadcastChannelRegistry::unregisterChannel):
     93    (WebKit::WebBroadcastChannelRegistry::postMessage):
     94    (WebKit::WebBroadcastChannelRegistry::postMessageLocally):
     95    (WebKit::WebBroadcastChannelRegistry::postMessageToRemote):
     96    (WebKit::WebBroadcastChannelRegistry::networkProcessCrashed):
     97    * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h:
     98   
     99    Source/WebKitLegacy:
     100    Dust off Mac CMake build
     101    https://bugs.webkit.org/show_bug.cgi?id=238121
     102   
     103    Reviewed by Yusuke Suzuki.
     104   
     105    * PlatformMac.cmake:
     106   
     107    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291589 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     108
     109    2022-01-24  Alan Coon  <alancoon@apple.com>
     110
     111            Cherry-pick r288389. rdar://problem/85405320
     112
     113        Disable CFURLCache in WebKit2
     114        https://bugs.webkit.org/show_bug.cgi?id=234988
     115        <rdar://problem/87619196>
     116
     117        Reviewed by Geoffrey Garen.
     1182022-03-21  Chris Dumez  <cdumez@apple.com>
     119
     120        BroadcastChannel instances in distinct opaque origins can communicate
     121        https://bugs.webkit.org/show_bug.cgi?id=238090
     122        <rdar://problem/90511155>
     123
     124        Reviewed by Alex Christensen.
     125
     126        * WebCoreSupport/WebBroadcastChannelRegistry.cpp:
     127        (WebBroadcastChannelRegistry::registerChannel):
     128        (WebBroadcastChannelRegistry::unregisterChannel):
     129        (WebBroadcastChannelRegistry::postMessage):
     130        * WebCoreSupport/WebBroadcastChannelRegistry.h:
     131
    10132   
    11133    Source/WebCore:
  • branches/safari-613.2.7.1-branch/Source/WebKitLegacy/WebCoreSupport/WebBroadcastChannelRegistry.cpp

    r293139 r293261  
    4545}
    4646
    47 void WebBroadcastChannelRegistry::registerChannel(const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
     47void WebBroadcastChannelRegistry::registerChannel(const WebCore::PartitionedSecurityOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
    4848{
    4949    ASSERT(isMainThread());
     
    5454}
    5555
    56 void WebBroadcastChannelRegistry::unregisterChannel(const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
     56void WebBroadcastChannelRegistry::unregisterChannel(const WebCore::PartitionedSecurityOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
    5757{
    5858    ASSERT(isMainThread());
     
    6767}
    6868
    69 void WebBroadcastChannelRegistry::postMessage(const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&& message, CompletionHandler<void()>&& completionHandler)
     69void WebBroadcastChannelRegistry::postMessage(const WebCore::PartitionedSecurityOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&& message, CompletionHandler<void()>&& completionHandler)
    7070{
    7171    ASSERT(isMainThread());
  • branches/safari-613.2.7.1-branch/Source/WebKitLegacy/WebCoreSupport/WebBroadcastChannelRegistry.h

    r293139 r293261  
    2525
    2626#include <WebCore/BroadcastChannelRegistry.h>
    27 #include <WebCore/ClientOrigin.h>
     27#include <WebCore/PartitionedSecurityOrigin.h>
    2828#include <wtf/Forward.h>
    2929#include <wtf/WeakPtr.h>
     
    3535    static Ref<WebBroadcastChannelRegistry> getOrCreate(bool privateSession);
    3636
    37     void registerChannel(const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;
    38     void unregisterChannel(const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;
    39     void postMessage(const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&&, CompletionHandler<void()>&&) final;
     37    void registerChannel(const WebCore::PartitionedSecurityOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;
     38    void unregisterChannel(const WebCore::PartitionedSecurityOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;
     39    void postMessage(const WebCore::PartitionedSecurityOrigin&, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&&, CompletionHandler<void()>&&) final;
    4040
    4141private:
     
    4343
    4444    using NameToChannelIdentifiersMap = HashMap<String, Vector<WebCore::BroadcastChannelIdentifier>>;
    45     HashMap<WebCore::ClientOrigin, NameToChannelIdentifiersMap> m_channels;
     45    HashMap<WebCore::PartitionedSecurityOrigin, NameToChannelIdentifiersMap> m_channels;
    4646};
Note: See TracChangeset for help on using the changeset viewer.