| ; Copyright (C) 2010-2020 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)) |
| (deny nvram*) |
| (allow system-audit file-read-metadata) |
| |
| (with-filter (require-not (uid 0)) |
| (deny system-privilege) |
| ;; Silence spurious logging due to rdar://20117923 and rdar://72366475 |
| (deny system-privilege (privilege-id PRIV_GLOBAL_PROC_INFO) (with no-report))) |
| |
| #include "Shared/Sandbox/preferences.sb" |
| |
| ;;; |
| ;;; The following rules were originally contained in 'system.sb'. We are duplicating them here so we can |
| ;;; remove unneeded sandbox extensions. |
| ;;; |
| |
| ;;; Allow registration of per-pid services. |
| (allow mach-register (local-name-prefix "")) |
| |
| ;;; Allow read access to standard system paths. |
| (allow file-read* |
| (require-all (file-mode #o0004) |
| (require-any (subpath "/Library/Filesystems/NetFSPlugins") |
| (subpath "/Library/Apple/System") |
| (subpath "/Library/Preferences/Logging") ; Logging Rethink |
| (subpath "/System") |
| #if __MAC_OS_X_VERSION_MIN_REQUIRED < 110000 |
| (subpath "/private/var/db/dyld") |
| #endif |
| (subpath "/private/var/db/timezone") |
| (subpath "/usr/lib") |
| (subpath "/usr/share")))) |
| |
| ;;; 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 mapping of system frameworks + dylibs |
| (allow file-map-executable |
| (subpath "/Library/Apple/System/Library/Frameworks") |
| (subpath "/Library/Apple/System/Library/PrivateFrameworks") |
| (subpath "/System/Library/Frameworks") |
| (subpath "/System/Library/PrivateFrameworks") |
| (subpath "/usr/lib") |
| (subpath "/usr/appleinternal/lib") ;; <rdar://problem/72317112> |
| ) |
| |
| (allow file-read-metadata |
| (literal "/etc") |
| (literal "/tmp") |
| (literal "/var") |
| (literal "/private/etc/localtime")) |
| |
| |
| ;;; Allow access to standard special files. |
| (allow file-read* |
| (literal "/dev/autofs_nowait") |
| (literal "/dev/random") |
| (literal "/dev/urandom") |
| (literal "/private/etc/master.passwd") |
| (literal "/private/etc/passwd")) |
| |
| (allow file-read* |
| file-write-data |
| (literal "/dev/null") |
| (literal "/dev/zero")) |
| |
| (allow file-read* |
| file-write-data |
| file-ioctl |
| (literal "/dev/dtracehelper")) |
| |
| ;;; Allow creation of core dumps. |
| (allow file-write-create |
| (require-all (prefix "/cores/") |
| (vnode-type REGULAR-FILE))) |
| |
| ;;; Allow IPC to standard system agents. |
| (allow ipc-posix-shm-read* |
| (ipc-posix-name "apple.shm.notification_center") |
| (ipc-posix-name-prefix "apple.cfprefs.")) |
| |
| ;;; |
| ;;; End rules originally copied from 'system.sb' |
| ;;; |
| |
| ;;; process-info* defaults to allow; deny it and then allow operations we actually need. |
| (deny process-info*) |
| (allow process-info-dirtycontrol (target self)) |
| (allow process-info-pidinfo) |
| (allow process-info-setcontrol (target self)) |
| (allow process-codesigning-status*) |
| |
| (deny sysctl*) |
| (allow sysctl-read |
| (sysctl-name |
| "hw.activecpu" ;; <rdar://problem/56795575> |
| "hw.availcpu" |
| "hw.byteorder" |
| "hw.busfrequency" |
| "hw.busfrequency_max" |
| "hw.cacheconfig" ;; <rdar://problem/78213563> |
| "hw.cachelinesize" ;; <rdar://problem/56795575> |
| "hw.cachesize" ;; <rdar://problem/78213563> |
| "hw.cpufrequency" |
| "hw.cpufrequency_max" |
| "hw.cpusubfamily" |
| "hw.cputhreadtype" |
| "hw.cputype" |
| "hw.l1dcachesize" ;; <rdar://problem/56795575> |
| "hw.l1icachesize" ;; <rdar://problem/56795575> |
| "hw.l2cachesize" ;; <rdar://problem/56795575> |
| "hw.l3cachesize" ;; <rdar://problem/56795575> |
| "hw.logicalcpu" ;; <rdar://problem/56795575> |
| "hw.logicalcpu_max" ;; <rdar://problem/56795575> |
| "hw.machine" |
| "hw.memsize" |
| "hw.model" |
| "hw.ncpu" |
| "hw.nperflevels" ;; <rdar://problem/76783596> |
| "hw.pagesize" ;; <rdar://problem/76783596> |
| "hw.pagesize_compat" ;; <rdar://problem/76783596> |
| "hw.physicalcpu" ;; <rdar://problem/58416475> |
| "hw.physicalcpu_max" ;; <rdar://problem/58416475> |
| "hw.tbfrequency" |
| "hw.tbfrequency_compat" |
| "hw.vectorunit" |
| "kern.bootargs" ;; <rdar://problem/47738015> |
| "kern.hostname" |
| "kern.hv_vmm_present" |
| "kern.maxfilesperproc" |
| "kern.memorystatus_level" |
| "kern.osproductversion" ;; <rdar://problem/51756739> |
| "kern.osrelease" |
| "kern.ostype" |
| "kern.osvariant_status" |
| "kern.osversion" |
| "kern.safeboot" |
| "kern.version" |
| "machdep.cpu.brand_string" |
| "security.mac.sandbox.sentinel" |
| "kern.tcsm_enable" |
| "kern.tcsm_available" |
| "vm.footprint_suspend") |
| (sysctl-name-prefix "net.routetable") |
| (sysctl-name-prefix "hw.optional.") ;; <rdar://problem/71462790> |
| (sysctl-name-prefix "hw.perflevel") ;; <rdar://problem/76783596> |
| ) |
| |
| (allow sysctl-write |
| (sysctl-name |
| "kern.tcsm_enable")) |
| |
| (deny mach-lookup (xpc-service-name-prefix "")) |
| (allow mach-lookup |
| (xpc-service-name "com.apple.PerformanceAnalysis.animationperfd") |
| (xpc-service-name "com.apple.accessibility.mediaaccessibilityd") |
| (xpc-service-name "com.apple.audio.SandboxHelper") |
| (xpc-service-name "com.apple.coremedia.videodecoder") |
| (xpc-service-name "com.apple.coremedia.videoencoder") |
| (xpc-service-name "com.apple.hiservices-xpcservice") |
| ) |
| |
| ;; 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))) |
| |
| (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 (allow-read-write-directory-and-issue-read-write-extensions path) |
| (if path |
| (begin |
| (allow file-read* file-write* (subpath path)) |
| (allow file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") (subpath path))) |
| (allow file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read-write") (subpath path)))))) |
| |
| ;; Remove when <rdar://problem/29646094> is fixed. |
| (define (HEX-pattern-match-generator pattern-descriptor) |
| (letrec ((pattern-string "")) |
| (for-each (lambda (repeat-count) |
| (if (zero? repeat-count) |
| (set! pattern-string (string-append pattern-string "-")) |
| (let appender ((count repeat-count)) |
| (if (> count 0) |
| (begin |
| (set! pattern-string (string-append pattern-string "[0-9A-F]")) |
| (appender (- count 1))))))) |
| pattern-descriptor) |
| pattern-string)) |
| |
| ;; return a regex pattern matching string for 8-4-4-4-12 UUIDs: |
| (define (uuid-HEX-pattern-match-string) |
| (HEX-pattern-match-generator '(8 0 4 0 4 0 4 0 12))) |
| |
| ;; global to hold the computed UUID matching pattern. |
| (define *uuid-pattern* "") |
| |
| (define (uuid-regex-string) |
| (if (zero? (string-length *uuid-pattern*)) |
| (set! *uuid-pattern* (uuid-HEX-pattern-match-string))) |
| *uuid-pattern*) |
| |
| ;; Read-only preferences and data |
| (allow file-read* |
| ;; Basic system paths |
| (subpath "/Library/Dictionaries") |
| (subpath "/Library/Fonts") |
| (subpath "/Library/Frameworks") |
| (subpath "/Library/Managed Preferences") |
| (subpath "/Library/Speech/Synthesizers") |
| (regex #"^/private/etc/(hosts|group|passwd)$") |
| |
| ;; System and user preferences |
| (home-literal "/.CFUserTextEncoding") |
| |
| ;; FIXME: This should be removed when <rdar://problem/8957845> is fixed. |
| (home-subpath "/Library/Fonts") |
| |
| (subpath "/Library/Audio/Plug-Ins/HAL") |
| |
| (home-subpath "/Library/Dictionaries")) |
| |
| (allow file-read-data |
| (literal "/usr/local/lib/log") ; <rdar://problem/36629495> |
| ;; Needed for AES3 support |
| (subpath "/Library/Audio/Plug-Ins/Components")) |
| |
| ;; Preferences support |
| (shared-preferences-read |
| "com.apple.Accessibility" |
| "com.apple.ATS" |
| "com.apple.CoreGraphics" |
| "com.apple.DownloadAssessment" |
| "com.apple.HIToolbox" |
| "com.apple.LaunchServices" |
| "com.apple.MultitouchSupport" ;; FIXME: Remove when <rdar://problem/13011633> is fixed. |
| "com.apple.ServicesMenu.Services" ;; Needed for NSAttributedString <rdar://problem/10844321> |
| "com.apple.ViewBridge" ;; Needed for Input elements. |
| "com.apple.WebFoundation" |
| "com.apple.avfoundation" |
| "com.apple.avfoundation.frecents" ;; <rdar://problem/33137029> |
| "com.apple.avfoundation.videoperformancehud" ;; <rdar://problem/31594568> |
| "com.apple.coremedia" |
| "com.apple.crypto" |
| "com.apple.driver.AppleBluetoothMultitouch.mouse" |
| "com.apple.driver.AppleBluetoothMultitouch.trackpad" |
| "com.apple.driver.AppleHIDMouse" |
| "com.apple.lookup.shared" |
| "com.apple.mediaaccessibility" ;; Needed for custom caption styles |
| "com.apple.networkConnect" |
| "com.apple.speech.voice.prefs" |
| "com.apple.systemsound" |
| "com.apple.universalaccess" |
| "edu.mit.Kerberos" |
| "pbs") ;; Needed for NSAttributedString <rdar://problem/10844321> |
| |
| (allow-reading-global-preferences) |
| |
| ; (Temporary) backward compatibility with non-CFPreferences readers. |
| (allow file-read* |
| (literal "/Library/Preferences/com.apple.ViewBridge.plist")) |
| |
| ; FIXME: This is needed for some security framework calls (that use non-CFPreferences readers) |
| (allow file-read-data |
| (literal "/Library/Preferences/com.apple.security.plist") |
| (home-subpath "/Library/Preferences/com.apple.security.plist")) |
| |
| ;; On-disk WebKit2 framework location, to account for debug installations outside of /System/Library/Frameworks, |
| ;; and to allow issuing extensions. |
| (allow-read-directory-and-issue-read-extensions (param "WEBKIT2_FRAMEWORK_DIR")) |
| |
| ;; Allow issuing extensions to system libraries that the Network process can already read. |
| ;; This is to avoid warnings attempting to create extensions for these resources. |
| (allow-read-directory-and-issue-read-extensions "/System/Library/PrivateFrameworks/WebInspectorUI.framework") |
| |
| ;; Sandbox extensions |
| (define (apply-read-and-issue-extension op path-filter) |
| (op file-read* path-filter) |
| (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") path-filter))) |
| (define (apply-write-and-issue-extension op path-filter) |
| (op file-write* path-filter) |
| (op file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read-write") path-filter))) |
| (define (read-only-and-issue-extensions path-filter) |
| (apply-read-and-issue-extension allow path-filter)) |
| (define (read-write-and-issue-extensions path-filter) |
| (apply-read-and-issue-extension allow path-filter) |
| (apply-write-and-issue-extension allow path-filter)) |
| (read-only-and-issue-extensions (extension "com.apple.app-sandbox.read")) |
| (read-write-and-issue-extensions (extension "com.apple.app-sandbox.read-write")) |
| (allow mach-lookup (extension "com.apple.app-sandbox.mach")) ;; FIXME: Should be removed when <rdar://problem/13066206> is fixed. |
| |
| (allow mach-lookup |
| #if PLATFORM(MAC) |
| (with report) (with telemetry) |
| #endif |
| (global-name "com.apple.audio.AudioComponentRegistrar") |
| (global-name "com.apple.awdd") |
| #if !ENABLE(CFPREFS_DIRECT_MODE) |
| (global-name "com.apple.cfprefsd.agent") |
| #endif |
| (global-name "com.apple.cookied") |
| (global-name "com.apple.diagnosticd") |
| (global-name "com.apple.iconservices") |
| (global-name "com.apple.iconservices.store") |
| (global-name "com.apple.system.logger") |
| ) |
| |
| ;; Various services required by AppKit and other frameworks |
| (allow mach-lookup |
| (global-name "com.apple.PowerManagement.control") |
| (global-name "com.apple.SystemConfiguration.configd") |
| (global-name "com.apple.analyticsd") |
| (global-name "com.apple.assertiond.processassertionconnection") |
| (global-name "com.apple.audio.SystemSoundServer-OSX") |
| (global-name "com.apple.audio.audiohald") |
| #if !ENABLE(CFPREFS_DIRECT_MODE) |
| (global-name "com.apple.cfprefsd.daemon") |
| #endif |
| (global-name "com.apple.coreservices.launchservicesd") |
| (global-name "com.apple.fonts") |
| (global-name "com.apple.mediaremoted.xpc") |
| (global-name "com.apple.logd") |
| (global-name "com.apple.logd.events") |
| (global-name "com.apple.lsd.mapdb") |
| (global-name "com.apple.lskdd") ;; <rdar://problem/49123855> |
| (global-name "com.apple.tccd") |
| (global-name "com.apple.tccd.system") |
| (global-name "com.apple.trustd.agent") |
| (global-name "com.apple.CARenderServer") ; Needed for [CAContext remoteContextWithOptions] |
| ) |
| |
| ;; <rdar://problem/47268166> |
| (allow mach-lookup (xpc-service-name "com.apple.MTLCompilerService")) |
| |
| (deny mach-lookup (with no-log) |
| (global-name "com.apple.CoreServices.coreservicesd") |
| (global-name "com.apple.DiskArbitration.diskarbitrationd") |
| (global-name "com.apple.ViewBridgeAuxiliary") |
| (global-name "com.apple.windowserver.active")) |
| |
| ;; Needed to support encrypted media playback <rdar://problem/40038478> |
| (allow mach-lookup |
| (global-name "com.apple.SecurityServer") |
| (global-name "com.apple.ocspd")) |
| |
| (allow file-read* (subpath "/private/var/db/mds/system")) ;; FIXME: This should be removed when <rdar://problem/9538414> is fixed. |
| (with-filter (uid 0) |
| (allow file-write* |
| (subpath "/private/var/db/mds/system")) ;; FIXME: This should be removed when <rdar://problem/9538414> is fixed. |
| ) |
| |
| (allow file-read* |
| (subpath "/private/var/db/mds") |
| (literal "/private/var/db/DetachedSignatures")) |
| |
| (allow ipc-posix-shm-read* ipc-posix-shm-write-data ipc-posix-shm-write-create |
| (ipc-posix-name "com.apple.AppleDatabaseChanged")) |
| |
| ;; CoreFoundation. We don't import com.apple.corefoundation.sb, because it allows unnecessary access to pasteboard. |
| (allow mach-lookup |
| (global-name-prefix "com.apple.distributed_notifications") |
| #if !HAVE(CSCHECKFIXDISABLE) |
| (global-name "com.apple.CoreServices.coreservicesd") |
| #endif |
| ) |
| |
| (allow file-read-data |
| (literal "/dev/autofs_nowait")) ; Used by CF to circumvent automount triggers |
| (allow ipc-posix-shm |
| (ipc-posix-name-prefix "CFPBS:")) ; <rdar://problem/13757475> |
| (allow system-fsctl (fsctl-command (_IO "h" 47))) |
| |
| ;; Networking |
| (allow network-outbound |
| ;; ObjC map_images needs to send logging data to syslog. <rdar://problem/39778918> |
| (literal "/private/var/run/syslog") |
| ) |
| |
| ;; CFNetwork |
| (allow file-read-data (path "/private/var/db/nsurlstoraged/dafsaData.bin")) |
| |
| #if PLATFORM(MAC) |
| ;; FIXME should be removed when <rdar://problem/9347205> + related radar in Safari is fixed |
| (allow mach-lookup |
| (global-name "com.apple.system.logger") |
| (global-name "com.apple.system.notification_center")) |
| #endif |
| |
| (deny file-write-create (vnode-type SYMLINK)) |
| |
| ;; Reserve a namespace for additional protected extended attributes. |
| (deny file-read-xattr file-write-xattr (xattr-prefix "com.apple.security.private.")) |
| |
| (deny file-read* file-write* (with no-log) |
| ;; FIXME: Should be removed after <rdar://problem/10463881> is fixed. |
| (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2") |
| (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2-journal")) |
| |
| ;; Deny access needed for unnecessary NSApplication initialization. |
| ;; FIXME: This can be removed once <rdar://problem/13011633> is fixed. |
| (deny file-read* (with no-log) |
| (subpath "/Library/InputManagers") |
| (home-subpath "/Library/InputManagers")) |
| (deny user-preference-read (with no-log) |
| (preference-domain "com.apple.speech.recognition.AppleSpeechRecognition.prefs")) |
| (deny mach-lookup (with no-log) |
| (global-name "com.apple.coreservices.appleevents") |
| (global-name "com.apple.pasteboard.1") |
| (global-name "com.apple.speech.recognitionserver")) |
| #if PLATFORM(MAC) |
| ;; Also part of unnecessary NSApplication initialization, but we can't block access to these yet, see <rdar://problem/13869765>. |
| (allow file-read* |
| (subpath "/Library/Components") |
| (subpath "/Library/Keyboard Layouts") |
| (subpath "/Library/Input Methods") |
| (home-subpath "/Library/Components") |
| (home-subpath "/Library/Keyboard Layouts") |
| (home-subpath "/Library/Input Methods")) |
| #endif |
| |
| ;; Data Detectors |
| (allow file-read* (subpath "/private/var/db/datadetectors/sys")) |
| |
| ;; Allow accesses to HID |
| (allow iokit-open |
| (iokit-user-client-class "IOHIDLibUserClient")) |
| |
| ;; Allow accesses to LocalAuthentication and RemoteService |
| (allow mach-lookup |
| (global-name "com.apple.CoreAuthentication.agent") |
| (global-name "com.apple.remoted")) |