Changeset 289566 in webkit
- Timestamp:
- Feb 10, 2022, 12:13:19 PM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r289552 r289566 1 2022-02-10 Ben Nham <nham@apple.com> 2 3 Apply default sandbox to webpushd on Mac 4 https://bugs.webkit.org/show_bug.cgi?id=236342 5 6 Reviewed by Per Arne Vollan. 7 8 This applies a default sandbox profile that allows and logs all operations by webpushd on 9 the Mac. In future patches we'll tighten the sandbox based on the sandbox logs that we 10 receive. 11 12 To do this, I refactored the sandbox initialization logic in AuxiliaryProcess so that it can 13 be called without creating an AuxiliaryProcess instance. This probably should be refactored 14 further (e.g. since webpushd isn't an AuxiliaryProcess, but rather a system daemon). But I 15 wanted to keep the amount of refactoring low for now while we're still figuring things out. 16 17 We also do not currently support compiling and caching the sandbox profiles. We'll add that 18 support later. 19 20 * DerivedSources-input.xcfilelist: 21 * DerivedSources-output.xcfilelist: 22 * DerivedSources.make: 23 * PlatformMac.cmake: 24 * Shared/AuxiliaryProcess.cpp: 25 (WebKit::applySandboxProfileForDaemon): 26 * Shared/AuxiliaryProcess.h: 27 * Shared/mac/AuxiliaryProcessMac.mm: 28 (WebKit::getUserDirectorySuffix): 29 (WebKit::populateSandboxInitializationParameters): 30 (WebKit::AuxiliaryProcess::initializeSandbox): 31 (WebKit::AuxiliaryProcess::applySandboxProfileForDaemon): 32 * WebKit.xcodeproj/project.pbxproj: 33 * webpushd/WebPushDaemonMain.mm: 34 (WebKit::applySandbox): 35 (WebKit::WebPushDaemonMain): 36 * webpushd/mac/com.apple.WebKit.webpushd.sb.in: Added. 37 1 38 2022-02-10 Wenson Hsieh <wenson_hsieh@apple.com> 2 39 -
trunk/Source/WebKit/Configurations/WebKit.xcconfig
r289091 r289566 180 180 EXCLUDED_IOS_RESOURCE_FILE_NAMES[sdk=iphone*] = ; 181 181 182 EXCLUDED_MACOS_PLUGIN_FILE_NAMES[sdk=iphone*] = SecItemShim.dylib WebProcessShim.dylib *.pdf Resources/mac/* com.apple.WebKit.NetworkProcess.sb com.apple.WebKit.GPUProcess.sb com.apple.WebKit.WebAuthnProcess.sb com.apple.Web Process.sb;182 EXCLUDED_MACOS_PLUGIN_FILE_NAMES[sdk=iphone*] = SecItemShim.dylib WebProcessShim.dylib *.pdf Resources/mac/* com.apple.WebKit.NetworkProcess.sb com.apple.WebKit.GPUProcess.sb com.apple.WebKit.WebAuthnProcess.sb com.apple.WebKit.webpushd.sb com.apple.WebProcess.sb; 183 183 184 184 INSTALLHDRS_SCRIPT_PHASE = YES; -
trunk/Source/WebKit/DerivedSources-input.xcfilelist
r289525 r289566 249 249 $(PROJECT_DIR)/WebProcess/cocoa/VideoFullscreenManager.messages.in 250 250 $(PROJECT_DIR)/WebProcess/com.apple.WebProcess.sb.in 251 $(PROJECT_DIR)/webpushd/mac/com.apple.WebKit.webpushd.sb.in -
trunk/Source/WebKit/DerivedSources-output.xcfilelist
r289525 r289566 646 646 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/com.apple.WebKit.WebContent.sb 647 647 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/com.apple.WebKit.plugin-common.sb 648 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/com.apple.WebKit.webpushd.sb 648 649 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit/com.apple.WebProcess.sb 649 650 <<<<<<< HEAD -
trunk/Source/WebKit/DerivedSources.make
r289525 r289566 105 105 $(WebKit2)/UIProcess/mac \ 106 106 $(WebKit2)/UIProcess/ios \ 107 $(WebKit2)/webpushd/mac \ 107 108 $(WEBKITADDITIONS_HEADER_SEARCH_PATHS) \ 108 109 # … … 352 353 com.apple.WebKit.NetworkProcess.sb \ 353 354 com.apple.WebKit.GPUProcess.sb \ 354 com.apple.WebKit.WebAuthnProcess.sb 355 com.apple.WebKit.WebAuthnProcess.sb \ 356 com.apple.WebKit.webpushd.sb 355 357 356 358 SANDBOX_PROFILES_IOS = \ -
trunk/Source/WebKit/PlatformMac.cmake
r288345 r289566 839 839 list(APPEND WebKit_SB_FILES ${WebKit_RESOURCES_DIR}/com.apple.WebKit.WebAuthnProcess.sb) 840 840 endif () 841 if (ENABLE_BUILT_IN_NOTIFICATIONS) 842 add_custom_command(OUTPUT ${WebKit_RESOURCES_DIR}/com.apple.WebKit.webpushd.sb COMMAND 843 grep -o "^[^;]*" ${WEBKIT_DIR}/webpushd/mac/com.apple.WebKit.webpushd.sb.in | clang -E -P -w -include wtf/Platform.h -I ${WTF_FRAMEWORK_HEADERS_DIR} -I ${bmalloc_FRAMEWORK_HEADERS_DIR} -I ${WEBKIT_DIR} - > ${WebKit_RESOURCES_DIR}/com.apple.WebKit.webpushd.sb 844 VERBATIM) 845 list(APPEND WebKit_SB_FILES ${WebKit_RESOURCES_DIR}/com.apple.WebKit.webpushd.sb) 846 endif () 841 847 add_custom_target(WebKitSandboxProfiles ALL DEPENDS ${WebKit_SB_FILES}) 842 848 add_dependencies(WebKit WebKitSandboxProfiles) -
trunk/Source/WebKit/Shared/AuxiliaryProcess.cpp
r287556 r289566 278 278 #endif 279 279 280 #if !PLATFORM(MAC) 281 static void applySandboxProfileForDaemon(const String&, const String&) 282 { 283 } 284 #endif 285 280 286 #endif // !PLATFORM(COCOA) 281 287 -
trunk/Source/WebKit/Shared/AuxiliaryProcess.h
r287720 r289566 88 88 #endif 89 89 90 static void applySandboxProfileForDaemon(const String& profilePath, const String& userDirectorySuffix); 91 90 92 IPC::Connection* parentProcessConnection() const { return m_connection.get(); } 91 93 -
trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm
r286071 r289566 638 638 } 639 639 640 static void initializeSandboxParameters(const AuxiliaryProcessInitializationParameters& parameters, SandboxInitializationParameters& sandboxParameters) 641 { 642 // Verify user directory suffix. 643 if (sandboxParameters.userDirectorySuffix().isNull()) { 644 auto userDirectorySuffix = parameters.extraInitializationData.find("user-directory-suffix"); 645 if (userDirectorySuffix != parameters.extraInitializationData.end()) { 646 String suffix = userDirectorySuffix->value; 647 auto firstPathSeparator = suffix.find("/"); 648 if (firstPathSeparator != notFound) 649 suffix.truncate(firstPathSeparator); 650 sandboxParameters.setUserDirectorySuffix(suffix); 651 } else { 652 String clientIdentifier = codeSigningIdentifier(parameters.connectionIdentifier.xpcConnection.get()); 653 if (clientIdentifier.isNull()) 654 clientIdentifier = parameters.clientIdentifier; 655 sandboxParameters.setUserDirectorySuffix(makeString([[NSBundle mainBundle] bundleIdentifier], '+', clientIdentifier)); 656 } 657 } 640 static String getUserDirectorySuffix(const AuxiliaryProcessInitializationParameters& parameters) 641 { 642 auto userDirectorySuffix = parameters.extraInitializationData.find("user-directory-suffix"); 643 if (userDirectorySuffix != parameters.extraInitializationData.end()) { 644 String suffix = userDirectorySuffix->value; 645 auto firstPathSeparator = suffix.find("/"); 646 if (firstPathSeparator != notFound) 647 suffix.truncate(firstPathSeparator); 648 return suffix; 649 } 650 651 String clientIdentifier = codeSigningIdentifier(parameters.connectionIdentifier.xpcConnection.get()); 652 if (clientIdentifier.isNull()) 653 clientIdentifier = parameters.clientIdentifier; 654 return makeString([[NSBundle mainBundle] bundleIdentifier], '+', clientIdentifier); 655 } 656 657 static void populateSandboxInitializationParameters(SandboxInitializationParameters& sandboxParameters) 658 { 659 RELEASE_ASSERT(!sandboxParameters.userDirectorySuffix().isNull()); 658 660 659 661 String osSystemMarketingVersion = systemMarketingVersion(); … … 715 717 716 718 #if USE(CACHE_COMPILED_SANDBOX) 717 // This must be called before initializeSandboxParameters so that the path does not include the user directory suffix.719 // This must be called before populateSandboxInitializationParameters so that the path does not include the user directory suffix. 718 720 // We don't want the user directory suffix because we want all processes of the same type to use the same cache directory. 719 721 String dataVaultParentDirectory { sandboxDataVaultParentDirectory() }; … … 728 730 sandboxParameters.addParameter("ENABLE_SANDBOX_MESSAGE_FILTER", enableMessageFilter ? "YES" : "NO"); 729 731 730 initializeSandboxParameters(parameters, sandboxParameters); 732 if (sandboxParameters.userDirectorySuffix().isNull()) 733 sandboxParameters.setUserDirectorySuffix(getUserDirectorySuffix(parameters)); 734 735 populateSandboxInitializationParameters(sandboxParameters); 731 736 732 737 if (!applySandbox(parameters, sandboxParameters, dataVaultParentDirectory)) { … … 745 750 } 746 751 752 void AuxiliaryProcess::applySandboxProfileForDaemon(const String& profilePath, const String& userDirectorySuffix) 753 { 754 TraceScope traceScope(InitializeSandboxStart, InitializeSandboxEnd); 755 756 SandboxInitializationParameters parameters { }; 757 parameters.setOverrideSandboxProfilePath(profilePath); 758 parameters.setUserDirectorySuffix(userDirectorySuffix); 759 populateSandboxInitializationParameters(parameters); 760 761 String profileOrProfilePath; 762 bool isProfilePath; 763 getSandboxProfileOrProfilePath(parameters, profileOrProfilePath, isProfilePath); 764 RELEASE_ASSERT(!profileOrProfilePath.isEmpty()); 765 766 bool success = compileAndApplySandboxSlowCase(profileOrProfilePath, isProfilePath, parameters); 767 RELEASE_ASSERT(success); 768 } 769 747 770 #if USE(APPKIT) 748 771 void AuxiliaryProcess::stopNSAppRunLoop() -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r289525 r289566 2012 2012 EB36B16827A7B4500050E00D /* PushService.h in Headers */ = {isa = PBXBuildFile; fileRef = EB36B16627A7B4500050E00D /* PushService.h */; }; 2013 2013 EB36B16927A7B4500050E00D /* PushService.mm in Sources */ = {isa = PBXBuildFile; fileRef = EB36B16727A7B4500050E00D /* PushService.mm */; }; 2014 EB7D252B27B31B77009CB586 /* com.apple.WebKit.webpushd.sb in Resources */ = {isa = PBXBuildFile; fileRef = EB7D252A27B31B3F009CB586 /* com.apple.WebKit.webpushd.sb */; }; 2014 2015 EBA8D3AB27A5E31300CB7900 /* ApplePushServiceSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = EBA8D3AA27A5E31300CB7900 /* ApplePushServiceSPI.h */; }; 2015 2016 EBA8D3B227A5E33F00CB7900 /* ApplePushServiceConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = EBA8D3AC27A5E33E00CB7900 /* ApplePushServiceConnection.mm */; }; … … 6507 6508 EB36B16627A7B4500050E00D /* PushService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PushService.h; sourceTree = "<group>"; }; 6508 6509 EB36B16727A7B4500050E00D /* PushService.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PushService.mm; sourceTree = "<group>"; }; 6510 EB7D252927B316A6009CB586 /* com.apple.WebKit.webpushd.sb.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = com.apple.WebKit.webpushd.sb.in; sourceTree = "<group>"; }; 6511 EB7D252A27B31B3F009CB586 /* com.apple.WebKit.webpushd.sb */ = {isa = PBXFileReference; lastKnownFileType = file; name = com.apple.WebKit.webpushd.sb; path = DerivedSources/WebKit/com.apple.WebKit.webpushd.sb; sourceTree = BUILT_PRODUCTS_DIR; }; 6509 6512 EBA8D3AA27A5E31300CB7900 /* ApplePushServiceSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplePushServiceSPI.h; sourceTree = "<group>"; }; 6510 6513 EBA8D3AC27A5E33E00CB7900 /* ApplePushServiceConnection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ApplePushServiceConnection.mm; sourceTree = "<group>"; }; … … 10161 10164 isa = PBXGroup; 10162 10165 children = ( 10166 EB7D252827B316A6009CB586 /* mac */, 10163 10167 517B5F63275A8D5C002DC22D /* webpushtool */, 10164 10168 5160E954274B887100567388 /* AppBundleRequest.h */, … … 12095 12099 572EBBC32536AB84000552B3 /* com.apple.WebKit.WebAuthnProcess.sb */, 12096 12100 E30CFB9D2660663C0094D9C0 /* com.apple.WebKit.WebContent.sb */, 12101 EB7D252A27B31B3F009CB586 /* com.apple.WebKit.webpushd.sb */, 12097 12102 E1967E37150AB5E200C73169 /* com.apple.WebProcess.sb */, 12098 12103 1AB7D6171288B9D900CFD08C /* DownloadProxyMessageReceiver.cpp */, … … 12741 12746 ); 12742 12747 path = cache; 12748 sourceTree = "<group>"; 12749 }; 12750 EB7D252827B316A6009CB586 /* mac */ = { 12751 isa = PBXGroup; 12752 children = ( 12753 EB7D252927B316A6009CB586 /* com.apple.WebKit.webpushd.sb.in */, 12754 ); 12755 path = mac; 12743 12756 sourceTree = "<group>"; 12744 12757 }; … … 13432 13445 570AB8F320AE3BD700B8BE87 /* SecKeyProxyStore.h in Headers */, 13433 13446 514D9F5719119D35000063A7 /* ServicesController.h in Headers */, 13447 5164658027A9C77400E1F2BA /* ServiceWorkerNotificationHandler.h in Headers */, 13434 13448 1AFDE65A1954A42B00C48FFA /* SessionState.h in Headers */, 13435 13449 1A002D49196B345D00B9AD44 /* SessionStateCoding.h in Headers */, … … 14644 14658 E17AE2C316B9C63A001C42F1 /* com.apple.WebKit.NetworkProcess.sb in Resources */, 14645 14659 572EBBC42536AB84000552B3 /* com.apple.WebKit.WebAuthnProcess.sb in Resources */, 14660 EB7D252B27B31B77009CB586 /* com.apple.WebKit.webpushd.sb in Resources */, 14646 14661 E11D35AE16B63D1B006D23D7 /* com.apple.WebProcess.sb in Resources */, 14647 14662 6BE969C11E54D452008B7483 /* corePrediction_model in Resources */, -
trunk/Source/WebKit/webpushd/WebPushDaemonMain.mm
r289353 r289566 27 27 #import "WebPushDaemonMain.h" 28 28 29 #import "AuxiliaryProcess.h" 29 30 #import "DaemonConnection.h" 30 31 #import "DaemonDecoder.h" … … 72 73 namespace WebKit { 73 74 75 static void applySandbox() 76 { 77 #if PLATFORM(MAC) 78 NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebKit"]; 79 auto profilePath = makeString(String([bundle resourcePath]), "/com.apple.WebKit.webpushd.sb"); 80 AuxiliaryProcess::applySandboxProfileForDaemon(profilePath, "com.apple.webkit.webpushd"_s); 81 #endif 82 } 83 74 84 int WebPushDaemonMain(int argc, char** argv) 75 85 { 76 86 @autoreleasepool { 77 87 WTF::initializeMainThread(); 88 89 applySandbox(); 78 90 79 91 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED
Note:
See TracChangeset
for help on using the changeset viewer.