Changeset 258915 in webkit


Ignore:
Timestamp:
Mar 24, 2020 10:14:43 AM (4 years ago)
Author:
pvollan@apple.com
Message:

[Cocoa] Deny access to database mapping service
https://bugs.webkit.org/show_bug.cgi?id=209339
Source/WebKit:

<rdar://problem/56966010>

Reviewed by Brent Fulgham.

In order for the WebContent process to not have permantent access to the database mapping service,
this patch creates an extension for the service in the UI process, sends it to the WebContent
process, where it is consumed. Then, an API call is made which will map the database, and next the
WebContent process will revoke the extension. The WebContent process has then mapped the database,
and access to the database mapping service is no longer needed.

Tested by: fast/sandbox/ios/sandbox-mach-lookup.html

  • Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
  • Shared/WebProcessCreationParameters.cpp:

(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):

  • Shared/WebProcessCreationParameters.h:
  • UIProcess/Cocoa/WebProcessPoolCocoa.mm:

(WebKit::WebProcessPool::platformInitializeWebProcess):

  • WebProcess/cocoa/WebProcessCocoa.mm:

(WebKit::WebProcess::platformInitializeWebProcess):

  • WebProcess/com.apple.WebProcess.sb.in:

Source/WTF:

<rdar://problem/56966010>

Reviewed by Brent Fulgham.

Disable the use of UTTypeRecord swizzling, since this is not needed with the new approach
of denying the database mapping service in this patch.

  • wtf/PlatformUse.h:

LayoutTests:

Reviewed by Brent Fulgham.

  • fast/sandbox/ios/sandbox-mach-lookup-expected.txt:
  • fast/sandbox/ios/sandbox-mach-lookup.html:
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r258913 r258915  
     12020-03-24  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [Cocoa] Deny access to database mapping service
     4        https://bugs.webkit.org/show_bug.cgi?id=209339
     5
     6        Reviewed by Brent Fulgham.
     7
     8        * fast/sandbox/ios/sandbox-mach-lookup-expected.txt:
     9        * fast/sandbox/ios/sandbox-mach-lookup.html:
     10
    1112020-03-24  Antoine Quint  <graouts@apple.com>
    212
  • trunk/LayoutTests/fast/sandbox/ios/sandbox-mach-lookup-expected.txt

    r258894 r258915  
    2626PASS internals.hasSandboxMachLookupAccessToGlobalName("com.apple.WebKit.WebContent", "com.apple.mobileassetd.v2") is false
    2727PASS internals.hasSandboxMachLookupAccessToGlobalName("com.apple.WebKit.WebContent", "com.apple.iconservices") is false
     28PASS internals.hasSandboxMachLookupAccessToGlobalName("com.apple.WebKit.WebContent", "com.apple.lsd.mapdb") is false
  • trunk/LayoutTests/fast/sandbox/ios/sandbox-mach-lookup.html

    r258894 r258915  
    2929    shouldBeFalse("internals.hasSandboxMachLookupAccessToGlobalName(\"com.apple.WebKit.WebContent\", \"com.apple.mobileassetd.v2\")");
    3030    shouldBeFalse("internals.hasSandboxMachLookupAccessToGlobalName(\"com.apple.WebKit.WebContent\", \"com.apple.iconservices\")");
     31    shouldBeFalse("internals.hasSandboxMachLookupAccessToGlobalName(\"com.apple.WebKit.WebContent\", \"com.apple.lsd.mapdb\")");
    3132}
    3233</script>
  • trunk/Source/WTF/ChangeLog

    r258894 r258915  
     12020-03-24  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [Cocoa] Deny access to database mapping service
     4        https://bugs.webkit.org/show_bug.cgi?id=209339
     5        <rdar://problem/56966010>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Disable the use of UTTypeRecord swizzling, since this is not needed with the new approach
     10        of denying the database mapping service in this patch.
     11
     12        * wtf/PlatformUse.h:
     13
    1142020-03-23  Commit Queue  <commit-queue@webkit.org>
    215
  • trunk/Source/WTF/wtf/PlatformUse.h

    r258894 r258915  
    322322#endif
    323323
    324 #if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000
    325 #define USE_UTTYPE_SWIZZLER 1
    326 #endif
     324#define USE_UTTYPE_SWIZZLER 0
  • trunk/Source/WebKit/ChangeLog

    r258914 r258915  
     12020-03-24  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [Cocoa] Deny access to database mapping service
     4        https://bugs.webkit.org/show_bug.cgi?id=209339
     5        <rdar://problem/56966010>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        In order for the WebContent process to not have permantent access to the database mapping service,
     10        this patch creates an extension for the service in the UI process, sends it to the WebContent
     11        process, where it is consumed. Then, an API call is made which will map the database, and next the
     12        WebContent process will revoke the extension. The WebContent process has then mapped the database,
     13        and access to the database mapping service is no longer needed.
     14
     15        Tested by: fast/sandbox/ios/sandbox-mach-lookup.html
     16
     17        * Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb:
     18        * Shared/WebProcessCreationParameters.cpp:
     19        (WebKit::WebProcessCreationParameters::encode const):
     20        (WebKit::WebProcessCreationParameters::decode):
     21        * Shared/WebProcessCreationParameters.h:
     22        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
     23        (WebKit::WebProcessPool::platformInitializeWebProcess):
     24        * WebProcess/cocoa/WebProcessCocoa.mm:
     25        (WebKit::WebProcess::platformInitializeWebProcess):
     26        * WebProcess/com.apple.WebProcess.sb.in:
     27
    1282020-03-24  Alex Christensen  <achristensen@webkit.org>
    229
  • trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb

    r258894 r258915  
    538538)
    539539
    540 (deny mach-lookup (with telemetry)
     540(deny mach-lookup (with telemetry-backtrace)
    541541    (global-name "com.apple.distributed_notifications@1v3"))
    542542
     
    544544       (ipc-posix-name-prefix "apple.cfprefs."))
    545545 
    546 (allow mach-lookup (with telemetry-backtrace)
     546(deny mach-lookup (with telemetry-backtrace)
    547547    (global-name "com.apple.lsd.mapdb"))
    548548
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp

    r258894 r258915  
    170170    encoder << neHelperExtensionHandle;
    171171    encoder << neSessionManagerExtensionHandle;
     172    encoder << mapDBExtensionHandle;
    172173    encoder << systemHasBattery;
    173174    encoder << mimeTypesMap;
     
    457458    parameters.neSessionManagerExtensionHandle = WTFMove(*neSessionManagerExtensionHandle);
    458459
     460    Optional<Optional<SandboxExtension::Handle>> mapDBExtensionHandle;
     461    decoder >> mapDBExtensionHandle;
     462    if (!mapDBExtensionHandle)
     463        return false;
     464    parameters.mapDBExtensionHandle = WTFMove(*mapDBExtensionHandle);
     465
    459466    Optional<bool> systemHasBattery;
    460467    decoder >> systemHasBattery;
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.h

    r258894 r258915  
    214214    Optional<SandboxExtension::Handle> neHelperExtensionHandle;
    215215    Optional<SandboxExtension::Handle> neSessionManagerExtensionHandle;
     216    Optional<SandboxExtension::Handle> mapDBExtensionHandle;
    216217    bool systemHasBattery { false };
    217218    Optional<HashMap<String, Vector<String>, ASCIICaseInsensitiveHash>> mimeTypesMap;
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r258894 r258915  
    381381        static const char* services[] = {
    382382            "com.apple.lsd.open",
    383             "com.apple.lsd.mapdb",
    384383            "com.apple.mobileassetd",
    385384            "com.apple.iconservices",
     
    436435        parameters.vectorOfUTTypeItem = createVectorOfUTTypeItem();
    437436#endif
     437
     438    SandboxExtension::Handle mapDBHandle;
     439    SandboxExtension::createHandleForMachLookup("com.apple.lsd.mapdb", WTF::nullopt, mapDBHandle, SandboxExtension::Flags::NoReport);
     440    parameters.mapDBExtensionHandle = WTFMove(mapDBHandle);
    438441#endif
    439442   
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r258894 r258915  
    105105#import "UserInterfaceIdiom.h"
    106106#import "WKAccessibilityWebPageObjectIOS.h"
     107#import <MobileCoreServices/MobileCoreServices.h>
    107108#import <UIKit/UIAccessibility.h>
    108109#import <WebCore/UTTypeRecordSwizzler.h>
     
    275276        SandboxExtension::consumePermanently(*parameters.neSessionManagerExtensionHandle);
    276277    NetworkExtensionContentFilter::setHasConsumedSandboxExtensions(parameters.neHelperExtensionHandle.hasValue() && parameters.neSessionManagerExtensionHandle.hasValue());
     278
     279    if (parameters.mapDBExtensionHandle) {
     280        auto extension = SandboxExtension::create(WTFMove(*parameters.mapDBExtensionHandle));
     281        bool ok = extension->consume();
     282        ASSERT_UNUSED(ok, ok);
     283        // Perform API calls which will communicate with the database mapping service, and map the database.
     284        auto uti = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, CFSTR("text/html"), 0));
     285        ok = extension->revoke();
     286        ASSERT_UNUSED(ok, ok);
     287    }
     288
    277289    setSystemHasBattery(parameters.systemHasBattery);
    278290
  • trunk/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in

    r258894 r258915  
    888888            "com.apple.cfprefsd.daemon"
    889889            "com.apple.tccd"
     890            "com.apple.lsd.mapdb"
    890891
    891892            ;;; FIXME(207716): The following should be removed when the GPU process is complete
Note: See TracChangeset for help on using the changeset viewer.