Diff
Modified: trunk/Source/WebKit/ChangeLog (283896 => 283897)
--- trunk/Source/WebKit/ChangeLog 2021-10-11 15:55:01 UTC (rev 283896)
+++ trunk/Source/WebKit/ChangeLog 2021-10-11 16:04:38 UTC (rev 283897)
@@ -1,3 +1,19 @@
+2021-10-11 Alex Christensen <[email protected]>
+
+ Add AdAttributionDaemon sandbox on iOS
+ https://bugs.webkit.org/show_bug.cgi?id=231308
+
+ Reviewed by Brent Fulgham.
+
+ This makes it so that AdAttributionDaemon has enough permission to access the network and its storage file and not much else.
+
+ * Configurations/AdAttributionDaemon.xcconfig:
+ * Resources/SandboxProfiles/ios/com.apple.WebKit.AdAttributionDaemon.sb: Added.
+ * Scripts/process-entitlements.sh:
+ * Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm:
+ (WebKit::enterSandbox):
+ * WebKit.xcodeproj/project.pbxproj:
+
2021-10-11 Per Arne Vollan <[email protected]>
[iOS] Sort syscall filters in the WebContent process' sandbox
Modified: trunk/Source/WebKit/Configurations/AdAttributionDaemon.xcconfig (283896 => 283897)
--- trunk/Source/WebKit/Configurations/AdAttributionDaemon.xcconfig 2021-10-11 15:55:01 UTC (rev 283896)
+++ trunk/Source/WebKit/Configurations/AdAttributionDaemon.xcconfig 2021-10-11 16:04:38 UTC (rev 283897)
@@ -28,5 +28,7 @@
OTHER_LDFLAGS = -framework WebKit;
FRAMEWORK_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR);
+WK_PROCESSED_XCENT_FILE=$(TEMP_FILE_DIR)/$(FULL_PRODUCT_NAME).entitlements
+
INSTALL_PATH[sdk=iphone*] = $(WEBKIT_FRAMEWORKS_DIR)/WebKit.framework/Daemons;
INSTALL_PATH[sdk=macosx*] = $(WEBKIT_FRAMEWORKS_DIR)/WebKit.framework/Versions/A/Daemons;
Added: trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.AdAttributionDaemon.sb (0 => 283897)
--- trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.AdAttributionDaemon.sb (rev 0)
+++ trunk/Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.AdAttributionDaemon.sb 2021-10-11 16:04:38 UTC (rev 283897)
@@ -0,0 +1,117 @@
+; Copyright (C) 2021 Apple Inc. All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without
+; modification, are permitted provided that the following conditions
+; are met:
+; 1. Redistributions of source code must retain the above copyright
+; notice, this list of conditions and the following disclaimer.
+; 2. Redistributions in binary form must reproduce the above copyright
+; notice, this list of conditions and the following disclaimer in the
+; documentation and/or other materials provided with the distribution.
+;
+; THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+; BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+; THE POSSIBILITY OF SUCH DAMAGE.
+
+(version 1)
+(deny default (with partial-symbolication))
+(allow system-audit file-read-metadata)
+
+(import "system.sb")
+
+(define (allow-read-write-directory-contents path)
+ (if path
+ (begin
+ (allow file-read* (subpath path))
+ (allow file-read* file-write*
+ (regex (string-append "^" (regex-quote path) "/")))
+ (allow file-write-create
+ file-write-data
+ (require-all (vnode-type DIRECTORY) (literal path))))))
+
+(define (allow-read-directory-and-issue-read-extensions path)
+ (if path
+ (begin
+ (allow file-read* (subpath path))
+ (allow file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") (subpath path))))))
+
+;; Utility functions for home directory relative path filters
+(define (home-regex home-relative-regex)
+ (regex (string-append "^" (regex-quote (param "HOME_DIR")) home-relative-regex)))
+
+(define (home-subpath home-relative-subpath)
+ (subpath (string-append (param "HOME_DIR") home-relative-subpath)))
+
+(define (home-literal home-relative-literal)
+ (literal (string-append (param "HOME_DIR") home-relative-literal)))
+
+(allow file-read* file-write* (home-subpath "/var/mobile/Library/com.apple.webkit.addattributiond/Version1"))
+
+(allow-read-write-directory-contents (param "DARWIN_USER_CACHE_DIR"))
+(allow-read-write-directory-contents (param "DARWIN_USER_TEMP_DIR"))
+
+(allow-read-directory-and-issue-read-extensions (param "FRAMEWORKS_DIR"))
+
+;; AWD
+(allow mach-lookup
+ (global-name
+ "com.apple.analyticsd"
+ "com.apple.awdd"))
+
+;; Various services required by CFNetwork and other frameworks
+(allow mach-lookup
+ (global-name
+ "com.apple.usymptomsd"
+ "com.apple.cookied"
+ "com.apple.distributed_notifications@Uv3"
+ "com.apple.CoreServices.coreservicesd"
+ "com.apple.lsd.mapdb"
+ "com.apple.lsd.modifydb"))
+
+;; Security framework
+(allow mach-lookup (global-name "com.apple.SecurityServer")
+(global-name "com.apple.ocspd"))
+(allow file-read*
+ (subpath "/Library/Keychains")
+ (subpath "/private/var/db/mds")
+ (literal "/Library/Preferences/com.apple.security.plist")
+ (home-literal "/Library/Preferences/com.apple.security.plist"))
+
+(allow file-read* (subpath "/usr/share/zoneinfo"))
+
+(allow file-read* (literal "/Library/Application Support/CrashReporter/SubmitDiagInfo.domains"))
+
+(allow ipc-posix-shm-read-data
+ (ipc-posix-name "com.apple.AppleDatabaseChanged"))
+(allow ipc-posix-shm-write-data
+ (ipc-posix-name "com.apple.AppleDatabaseChanged"))
+
+;; Read-only preferences and data
+(allow file-read*
+ ;; Basic system paths
+ (subpath "/Library/Managed Preferences")
+
+ ;; System and user preferences
+ (literal "/Library/Preferences/.GlobalPreferences.plist")
+ (home-literal "/Library/Preferences/.GlobalPreferences.plist")
+ (home-regex #"/Library/Preferences/ByHost/\.GlobalPreferences\."))
+
+(allow system-fsctl (fsctl-command (_IO "h" 47)))
+
+(system-network)
+(allow network-outbound
+ ;; Local mDNSResponder for DNS, arbitrary outbound TCP
+ (literal "/private/var/run/mDNSResponder")
+ (remote tcp))
+
+;; Needed for CFNetworkAgent, see 33386291
+(allow mach-lookup
+ (global-name "com.apple.cfnetwork.cfnetworkagent"))
Modified: trunk/Source/WebKit/Scripts/process-entitlements.sh (283896 => 283897)
--- trunk/Source/WebKit/Scripts/process-entitlements.sh 2021-10-11 15:55:01 UTC (rev 283896)
+++ trunk/Source/WebKit/Scripts/process-entitlements.sh 2021-10-11 16:04:38 UTC (rev 283897)
@@ -368,6 +368,12 @@
plistbuddy Add :seatbelt-profiles:0 string com.apple.WebKit.WebAuthn
}
+function ios_family_process_adattributiond_entitlements()
+{
+ plistbuddy Add :seatbelt-profiles array
+ plistbuddy Add :seatbelt-profiles:0 string com.apple.WebKit.AdAttributionDaemon
+}
+
function ios_family_process_network_entitlements()
{
plistbuddy Add :com.apple.private.webkit.adattributiondaemon bool YES
@@ -405,7 +411,9 @@
# Simulator entitlements should be added to Resources/ios/XPCService-ios-simulator.entitlements
if [[ "${WK_PLATFORM_NAME}" =~ .*simulator ]]
then
- cp "${CODE_SIGN_ENTITLEMENTS}" "${WK_PROCESSED_XCENT_FILE}"
+ if [[ "${PRODUCT_NAME}" != AdAttributionDaemon ]]; then
+ cp "${CODE_SIGN_ENTITLEMENTS}" "${WK_PROCESSED_XCENT_FILE}"
+ fi
elif [[ "${WK_PLATFORM_NAME}" == macosx ]]
then
[[ "${RC_XBS}" != YES ]] && plistbuddy Add :com.apple.security.get-task-allow bool YES
@@ -439,6 +447,8 @@
elif [[ "${PRODUCT_NAME}" == com.apple.WebKit.Plugin.64 ]]; then ios_family_process_plugin_entitlements
elif [[ "${PRODUCT_NAME}" == com.apple.WebKit.GPU ]]; then ios_family_process_gpu_entitlements
elif [[ "${PRODUCT_NAME}" == com.apple.WebKit.WebAuthn ]]; then ios_family_process_webauthn_entitlements
+ elif [[ "${PRODUCT_NAME}" == AdAttributionDaemon ]]; then
+ ios_family_process_adattributiond_entitlements
else echo "Unsupported/unknown product: ${PRODUCT_NAME}"
fi
else
Modified: trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm (283896 => 283897)
--- trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm 2021-10-11 15:55:01 UTC (rev 283896)
+++ trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm 2021-10-11 16:04:38 UTC (rev 283897)
@@ -125,7 +125,9 @@
static void enterSandbox()
{
+#if PLATFORM(MAC)
// FIXME: Enter a sandbox here. We should only need read/write access to our database and network access and nothing else.
+#endif
}
int PCMDaemonMain(int argc, const char** argv)
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (283896 => 283897)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-10-11 15:55:01 UTC (rev 283896)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-10-11 16:04:38 UTC (rev 283897)
@@ -4505,6 +4505,7 @@
5C1427141C23F8B000D41183 /* LegacyCustomProtocolManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyCustomProtocolManager.h; sourceTree = "<group>"; };
5C1427151C23F8B000D41183 /* LegacyCustomProtocolManager.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LegacyCustomProtocolManager.messages.in; sourceTree = "<group>"; };
5C14271B1C23F8CC00D41183 /* LegacyCustomProtocolManagerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyCustomProtocolManagerCocoa.mm; sourceTree = "<group>"; };
+ 5C1578E5270E0DBC00ED5280 /* com.apple.WebKit.AdAttributionDaemon.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.WebKit.AdAttributionDaemon.sb; sourceTree = "<group>"; };
5C19A51E1FD0B14600EEA323 /* URLSchemeTaskParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLSchemeTaskParameters.cpp; sourceTree = "<group>"; };
5C19A51F1FD0B14700EEA323 /* URLSchemeTaskParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLSchemeTaskParameters.h; sourceTree = "<group>"; };
5C1B38DF2667140700B1545B /* WebPageNetworkParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebPageNetworkParameters.h; sourceTree = "<group>"; };
@@ -9994,6 +9995,7 @@
A78CCDD6193AC9E3005ECC25 /* ios */ = {
isa = PBXGroup;
children = (
+ 5C1578E5270E0DBC00ED5280 /* com.apple.WebKit.AdAttributionDaemon.sb */,
2DB96052239886B900102791 /* com.apple.WebKit.GPU.sb */,
A78CCDD8193AC9E3005ECC25 /* com.apple.WebKit.Networking.sb */,
57EFC77D2550EB8500F9477D /* com.apple.WebKit.WebAuthn.sb */,
@@ -13505,6 +13507,7 @@
5CAF7A9C26F93A750003F19E /* Headers */,
5CAF7A9D26F93A750003F19E /* Sources */,
5CAF7A9F26F93A750003F19E /* Frameworks */,
+ 5C1578E6270E129400ED5280 /* Process AdAttributionDaemon Entitlements */,
);
buildRules = (
);
@@ -14011,6 +14014,7 @@
"$(SRCROOT)/Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb",
"$(SRCROOT)/Resources/SandboxProfiles/ios/com.apple.WebKit.GPU.sb",
"$(SRCROOT)/Resources/SandboxProfiles/ios/com.apple.WebKit.WebAuthn.sb",
+ "$(SRCROOT)/Resources/SandboxProfiles/ios/com.apple.WebKit.AdAttributionDaemon.sb",
);
name = "Copy iOS Sandbox Profiles for Manual Sandboxing";
outputPaths = (
@@ -14132,6 +14136,26 @@
shellPath = /bin/sh;
shellScript = "Scripts/process-entitlements.sh\n";
};
+ 5C1578E6270E129400ED5280 /* Process AdAttributionDaemon Entitlements */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ "$(SRCROOT)/Scripts/process-entitlements.sh",
+ );
+ name = "Process AdAttributionDaemon Entitlements";
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ "$(WK_PROCESSED_XCENT_FILE)",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "Scripts/process-entitlements.sh\n";
+ };
5DF408C5131DD46700130071 /* Check For Weak VTables and Externals */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;