Changeset 265087 in webkit


Ignore:
Timestamp:
Jul 30, 2020 9:36:29 AM (4 years ago)
Author:
pvollan@apple.com
Message:

Remember to check entitlement before communicating over XPC
https://bugs.webkit.org/show_bug.cgi?id=214825

Reviewed by Brent Fulgham.

Remember to check entitlement before communicating over XPC with another WebKit process. This needs to be done
to make sure that it really is a WebKit process on the other end.

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::m_messagePortChannelRegistry):

  • Shared/Cocoa/XPCEndpoint.mm:

(WebKit::XPCEndpoint::XPCEndpoint):

  • Shared/Cocoa/XPCEndpointClient.mm:

(WebKit::XPCEndpointClient::setEndpoint):

  • WebProcess/WebPage/Cocoa/WebPageCocoa.mm:

(WebKit::WebPage::platformDidReceiveLoadParameters):

  • WebProcess/cocoa/WebProcessCocoa.mm:

(WebKit::WebProcess::handleXPCEndpointMessages const):

Location:
trunk/Source/WebKit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r265085 r265087  
     12020-07-30  Per Arne Vollan  <pvollan@apple.com>
     2
     3        Remember to check entitlement before communicating over XPC
     4        https://bugs.webkit.org/show_bug.cgi?id=214825
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Remember to check entitlement before communicating over XPC with another WebKit process. This needs to be done
     9        to make sure that it really is a WebKit process on the other end.
     10
     11        * NetworkProcess/NetworkProcess.cpp:
     12        (WebKit::m_messagePortChannelRegistry):
     13        * Shared/Cocoa/XPCEndpoint.mm:
     14        (WebKit::XPCEndpoint::XPCEndpoint):
     15        * Shared/Cocoa/XPCEndpointClient.mm:
     16        (WebKit::XPCEndpointClient::setEndpoint):
     17        * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
     18        (WebKit::WebPage::platformDidReceiveLoadParameters):
     19        * WebProcess/cocoa/WebProcessCocoa.mm:
     20        (WebKit::WebProcess::handleXPCEndpointMessages const):
     21
    1222020-07-30  Kate Cheney  <katherine_cheney@apple.com>
    223
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r264846 r265087  
    166166    addSupplement<LegacyCustomProtocolManager>();
    167167#endif
    168 #if PLATFORM(COCOA)
     168#if HAVE(LSDATABASECONTEXT)
    169169    addSupplement<LaunchServicesDatabaseObserver>();
    170170#endif
  • trunk/Source/WebKit/Shared/Cocoa/XPCEndpoint.mm

    r264806 r265087  
    4242        if (type == XPC_TYPE_CONNECTION) {
    4343            OSObjectPtr<xpc_connection_t> connection = message;
    44             audit_token_t auditToken;
    45             xpc_connection_get_audit_token(connection.get(), &auditToken);
     44            auto pid = xpc_connection_get_pid(connection.get());
    4645
    47             if (!WTF::hasEntitlement(auditToken, "com.apple.private.webkit.use-xpc-endpoint")) {
    48                 // Uncomment before landing; this is commented out because the bots does not seem to update the entitlements on incremental builds.
    49                 // WTFLogAlways("Audit token does not have required entitlement");
    50                 // return;
     46            if (pid != getpid() && !WTF::hasEntitlement(connection.get(), "com.apple.private.webkit.use-xpc-endpoint")) {
     47                WTFLogAlways("Audit token does not have required entitlement com.apple.private.webkit.use-xpc-endpoint");
     48                return;
    5149            }
    5250            xpc_connection_set_target_queue(connection.get(), dispatch_get_main_queue());
  • trunk/Source/WebKit/Shared/Cocoa/XPCEndpointClient.mm

    r264199 r265087  
    5757            if (!connection)
    5858                return;
    59             audit_token_t auditToken;
    60             xpc_connection_get_audit_token(connection, &auditToken);
    61             if (!WTF::hasEntitlement(auditToken, "com.apple.private.webkit.use-xpc-endpoint")) {
    62                 // Uncomment before landing; this is commented out because the bots does not seem to update the entitlements on incremental builds.
    63                 // WTFLogAlways("Audit token does not have required entitlement");
    64                 // return;
     59
     60            auto pid = xpc_connection_get_pid(connection);
     61            if (pid != getpid() && !WTF::hasEntitlement(connection, "com.apple.private.webkit.use-xpc-endpoint")) {
     62                WTFLogAlways("Audit token does not have required entitlement com.apple.private.webkit.use-xpc-endpoint");
     63                return;
    6564            }
    6665            handleEvent(message);
  • trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm

    r264546 r265087  
    6565void WebPage::platformDidReceiveLoadParameters(const LoadParameters& parameters)
    6666{
     67#if HAVE(LSDATABASECONTEXT)
    6768    bool databaseUpdated = LaunchServicesDatabaseManager::singleton().waitForDatabaseUpdate(5_s);
    6869    ASSERT_UNUSED(databaseUpdated, databaseUpdated);
    6970    if (!databaseUpdated)
    7071        WTFLogAlways("Timed out waiting for Launch Services database update.");
     72#endif
    7173
    7274    m_dataDetectionContext = parameters.dataDetectionContext;
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r265081 r265087  
    189189            return;
    190190
     191#if HAVE(LSDATABASECONTEXT)
    191192        if (messageName == LaunchServicesDatabaseXPCConstants::xpcLaunchServicesDatabaseXPCEndpointMessageName) {
    192193            auto endpoint = xpc_dictionary_get_value(event, LaunchServicesDatabaseXPCConstants::xpcLaunchServicesDatabaseXPCEndpointNameKey);
     
    194195            return;
    195196        }
     197#endif
    196198    });
    197199
Note: See TracChangeset for help on using the changeset viewer.