; Copyright (C) 2021-2022 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) ;; We can remove the catch once we no longer need to support iOS 15 (or earlier)) (catch (lambda) (import "dyld-support.sb")) (import "util.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)))))) (define (system-network) (allow file-read* (literal "/Library/Preferences/com.apple.networkd.plist") (literal "/private/var/db/nsurlstoraged/dafsaData.bin")) (deny mach-lookup (with telemetry) (global-name "com.apple.SystemConfiguration.PPPController") (global-name "com.apple.SystemConfiguration.SCNetworkReachability") (global-name "com.apple.networkd") (global-name "com.apple.nsurlstorage-cache") (global-name "com.apple.symptomsd")) (allow mach-lookup (global-name "com.apple.trustd") (global-name "com.apple.trustd.agent") (global-name "com.apple.system.notification_center") (global-name "com.apple.logd") (global-name "com.apple.dnssd.service") (global-name "com.apple.nehelper") (global-name "com.apple.nesessionmanager") (global-name "com.apple.usymptomsd")) (allow network-outbound (control-name "com.apple.netsrc")) (deny system-socket (with telemetry) (socket-domain AF_ROUTE)) (allow system-socket (require-all (socket-domain AF_SYSTEM) (socket-protocol 2))) ; SYSPROTO_CONTROL (allow mach-lookup (global-name "com.apple.AppSSO.service-xpc")) (deny ipc-posix-shm-read-data (with telemetry) (ipc-posix-name "/com.apple.AppSSO.version"))) (allow file-read* file-write* (subpath "/private/var/mobile/Library/com.apple.webkit.adattributiond")) (allow file-read* file-map-executable (subpath "/usr/lib") (subpath "/System/Library/Frameworks") (subpath "/System/Library/PrivateFrameworks")) (with-filter (system-attribute apple-internal) (allow mach-lookup (global-name "com.apple.analyticsd") (global-name "com.apple.diagnosticd"))) (deny sysctl* (with telemetry)) (allow sysctl-read (sysctl-name "hw.activecpu" "hw.osenvironment" "hw.target" "hw.machine" "hw.memsize" "hw.ncpu" "hw.pagesize_compat" "kern.bootargs" "kern.hostname" "kern.maxfilesperproc" "kern.osproductversion" "kern.osrelease" "kern.ostype" "kern.osvariant_status" "kern.osversion" "kern.secure_kernel" "kern.version" "vm.footprint_suspend") (sysctl-name-prefix "kern.proc.pid.") ) (with-filter (system-attribute apple-internal) (allow sysctl-read sysctl-write (sysctl-name "vm.footprint_suspend" ) ) ) (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.containermanagerd" "com.apple.usymptomsd" "com.apple.cookied" "com.apple.distributed_notifications@Uv3" "com.apple.CoreServices.coreservicesd" "com.apple.lsd.mapdb" "com.apple.lsd.modifydb")) ;; (allow file-read* (literal "/private/var/preferences/com.apple.networkd.plist")) ;; Note this does not allow subpaths of "/" (allow file-read* file-test-existence (literal "/")) (allow file-read-data (literal "/System/Library/CoreServices/SystemVersion.plist") (literal "/usr/lib/log") (literal "/usr/local/lib/log")) ; ;; Security framework (allow mach-lookup (global-name "com.apple.SecurityServer") (global-name "com.apple.ocspd")) (allow file-read* (literal "/dev/urandom") (literal "/private/etc/master.passwd") (subpath "/private/var/preferences/Logging") (subpath "/Library/Keychains") (subpath "/private/var/db/mds") (literal "/Library/Preferences/com.apple.security.plist") (home-literal "/Library/Preferences/com.apple.security.plist")) ;;; Allow reading internal profiles on development builds (allow file-read* (require-all (file-mode #o0004) (subpath "/AppleInternal/Library/Preferences/Logging") (system-attribute apple-internal))) (allow file-read* (subpath "/usr/share")) (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")) (allow ipc-posix-shm-read* (ipc-posix-name "apple.shm.notification_center")) ;; Needed by os_log_create ;; 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")) #if ENABLE(SYSTEM_CONTENT_PATH_SANDBOX_RULES) #include (allow file-read* file-test-existence (apply subpath file-read-existence-secondary-paths)) (allow file-map-executable (apply subpath secondary-framework-and-dylib-paths)) #endif