;;; Copyright (c) 2017 Apple Inc. All Rights reserved. ;;; ;;; WARNING: The sandbox rules in this file currently constitute ;;; Apple System Private Interface and are subject to change at any time and ;;; without notice. ;;; (version 1) ;; Deny by default (deny default) (deny file-map-executable process-info* nvram*) (deny dynamic-code-generation) (deny mach-priv-host-port) (import "system.sb") (import "com.apple.corefoundation.sb") (corefoundation) ;;; Homedir-relative path filters (define (home-regex home-relative-regex) (regex (string-append "^" (regex-quote (param "HOME")) home-relative-regex))) ;;; Override the (param ...) function to variable-quote results to avoid ;;; unexpected ${...} patterns inside parameters. (define (var-quote-if-string obj) (if (and obj (string? obj)) (variable-quote obj) obj)) (let ((orig-param param)) (set! param (lambda(key) (var-quote-if-string (orig-param key))))) (define (home-subpath home-relative-subpath) (subpath (string-append (param "HOME") home-relative-subpath))) (define (home-prefix home-relative-prefix) (prefix (string-append (param "HOME") home-relative-prefix))) (define (home-literal home-relative-literal) (literal (string-append (param "HOME") home-relative-literal))) ; adapted from Sandbox_profiles/util.sb (define (allow-create-directory . filters) (allow file-read-metadata (apply require-any filters)) (allow file-read-metadata file-write-create (require-all (vnode-type DIRECTORY) (apply require-any filters)))) ;; Allow getting info about dataaccessd's process (allow process-info* (target self)) ;; Allow getting PID of processes, used as a key for a dictionary of XPC clients (allow process-info-pidinfo) ;; For resolving symlinks, realpath(3), and equivalents. (allow file-read-metadata) ;; For validating the entitlements of clients. (allow process-info-codesignature) ;; For setting DA's priority (allow system-sched (target self)) ;; To post Darwin notifications (allow distributed-notification-post) ;; Preference domains (allow user-preference-read user-preference-write (preference-domain "com.apple.DataAccess.BehaviorOptions") (preference-domain "com.apple.dataaccess.dataaccessd") (preference-domain "com.apple.dataaccess.babysitter") (preference-domain "com.apple.iCal") ) (allow user-preference-read (preference-domain "com.apple.security") (preference-domain "kCFPreferencesAnyApplication")) ;; For auth stuff (allow file-read* (subpath "/Library/Keychains") (home-subpath "/Library/Keychains")) (allow file-write* (home-prefix "/Library/Keychains/login.keychain")) ;; Global preferences (allow file-read* (home-literal "/Library/Preferences/.GlobalPreferences.plist") (home-literal "/Library/Preferences/com.apple.security.plist")) ;; Launch Services (allow file-read* (home-literal "/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist") (regex "^/private/var/folders/.*/com\.apple\.LaunchServices-.*\.csstore$") ) ;; Read/write access to a temporary directory. (allow file-read* file-write* (subpath (param "TMPDIR")) (subpath (param "DARWIN_CACHE_DIR")) (mount-relative-regex #"^/.TemporaryItems(/|$)")) ;; Loading AppleInternal libraries (allow file-read* (subpath "/AppleInternal/Library/Frameworks")) (allow file-map-executable (subpath "/AppleInternal/Library/Frameworks")) ;; Read/write access to calendar directory (allow file-read* file-write* (home-subpath "/Library/Calendars") ) ;; Read/write access to calendar attachments (allow file-read* file-write* (home-subpath "/Library/Group Containers/group.com.apple.calendar")) ;; Read/write access to calendar databases and attachments on persona volumes (allow file-read* file-write* (subpath "/Volumes/${ANY_UUID}/Library/Group Containers/group.com.apple.calendar")) ;; support consuming com.apple.app-sandbox.read and com.apple.app-sandbox.read-write extensions from clients (e.g. attachments) (allow file-read* (extension "com.apple.app-sandbox.read")) (allow file-read* file-write* (extension "com.apple.app-sandbox.read-write")) ;; Read/write access to DataAccess directory (e.g., for AccountInformation.plist) (allow file-read* file-write* (home-subpath "/Library/DataAccess")) ;; Read/write access to DA logging directory (allow-create-directory (home-subpath "/Library/Logs") (home-subpath "/Library/Logs/CrashReporter") (home-subpath "/Library/Logs/CrashReporter/DataAccess")) (allow file-read* file-write* (home-subpath "/Library/Logs/CrashReporter/DataAccess")) ;; Read/write access to com.apple.networkextension.uuidcache.plist (allow file-read* file-write* (literal "/Library/Preferences/com.apple.networkextension.uuidcache.plist")) ;; For Contacts (import "contacts.sb") (contacts-client (param "HOME") (param "TMPDIR")) ;; Read/write cache access (let ((cache-path-filter (home-subpath "/Library/Caches/com.apple.dataaccess.dataaccessd"))) (allow file-read* file-write* cache-path-filter) (allow file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read" "com.apple.app-sandbox.read-write") cache-path-filter))) ;; Mach lookups (for XPC to other processes) (allow mach-lookup (global-name "com.apple.CalendarAgent") (global-name "com.apple.calaccessd.xpc") (global-name "com.apple.tccd") (global-name "com.apple.tccd.system") (global-name "com.apple.windowserver.active") (global-name "com.apple.chronoservices") (global-name "com.apple.nehelper") (global-name "com.apple.accountsd.accountmanager") (global-name "com.apple.apsd") (global-name "com.apple.ak.anisette.xpc") (global-name "com.apple.AppSSO.service-xpc") (global-name "com.apple.dnssd.service") (global-name "com.apple.securityd.xpc") (global-name "com.apple.SecurityServer") (global-name "com.apple.system.opendirectoryd.api") (global-name "com.apple.remindd") (global-name "com.apple.spotlight.IndexAgent") (global-name "com.apple.containermanagerd") (global-name "com.apple.lsd.mapdb") (global-name "com.apple.lsd.modifydb") (global-name "com.apple.cfnetwork.cfnetworkagent") (global-name "com.apple.mobile.usermanagerd.xpc") (global-name "com.apple.mobile.keybagd.UserManager.xpc") (global-name "com.apple.mobile.keybagd.xpc") (global-name "com.apple.duetactivityscheduler")) ;; Used in -[DADAgentManager init] (allow iokit-open (iokit-user-client-class "RootDomainUserClient")) ;; For CFNetwork/AOSKit (allow ipc-posix-shm-read* ipc-posix-shm-write* (ipc-posix-name "com.apple.AppleDatabaseChanged")) ;; Connect to servers (system-network) (allow network-outbound) (allow system-socket)