




























(version 1)
(deny default (with partial-symbolication))
(allow system-audit file-read-metadata)







(allow mach-register (local-name-prefix ""))


(allow file-read*
    (require-all (file-mode #o0004)
    (require-any (subpath "/Library/Filesystems/NetFSPlugins")
    (subpath "/Library/Apple/System")
    (subpath "/Library/Preferences/Logging")

    (subpath "/System")
    (subpath "/private/var/db/dyld")
    (subpath "/private/var/db/timezone")
    (subpath "/usr/lib")
    (subpath "/usr/share"))))


(allow file-read*
    (require-all (file-mode #o0004)
    (subpath "/AppleInternal/Library/Preferences/Logging")
    (system-attribute apple-internal)))


(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/sanitizers"))

(allow file-read-metadata
    (literal "/etc")
    (literal "/tmp")
    (literal "/var")
    (literal "/private/etc/localtime"))



(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 file-write-create
    (require-all (prefix "/cores/")
        (vnode-type REGULAR-FILE)))


(allow ipc-posix-shm-read*
    (ipc-posix-name "apple.shm.notification_center")
    (ipc-posix-name-prefix "apple.cfprefs."))






(deny process-info*)
(allow process-info-pidinfo)
(allow process-info-setcontrol (target self))
(allow process-codesigning-status*)

(deny sysctl*)
(allow sysctl-read
    (sysctl-name
        "hw.byteorder"
        "hw.busfrequency_max"
        "hw.cputype"
        "hw.machine"
        "hw.memsize"
        "hw.model"
        "hw.ncpu"
        "hw.vectorunit"
        "kern.bootargs"

        "kern.hostname"
        "kern.maxfilesperproc"
        "kern.memorystatus_level"
        "kern.osproductversion"

        "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-regex #"^hw.(active|avail)cpu")
    (sysctl-name-regex #"^hw.(busfrequency|cachelinesize|cpufrequency(|_max)|pagesize|tbfrequency)(|_compat)")
    (sysctl-name-regex #"^hw.l.+cachesize")
    (sysctl-name-regex #"^hw.(logical|physical)cpu_max")
    (sysctl-name-regex #"^hw.optional\.")
    (sysctl-name-regex #"^kern.os(release|type|variant_status|version)")
    (sysctl-name-regex #"^net.routetable")
)

(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")
    (xpc-service-name "com.apple.print.normalizerd")
)


(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))))))


(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))


(define (uuid-HEX-pattern-match-string)
    (HEX-pattern-match-generator '(8 0 4 0 4 0 4 0 12)))


(define *uuid-pattern* "")

(define (uuid-regex-string)
    (if (zero? (string-length *uuid-pattern*))
        (set! *uuid-pattern* (uuid-HEX-pattern-match-string)))
    *uuid-pattern*)


(allow file-read*


    (subpath "/Library/Dictionaries")
    (subpath "/Library/Fonts")
    (subpath "/Library/Frameworks")
    (subpath "/Library/Managed Preferences")
    (subpath "/Library/Speech/Synthesizers")
    (regex #"^/private/etc/(hosts|group|passwd)$")



    (home-literal "/.CFUserTextEncoding")



    (home-subpath "/Library/Fonts")

    (subpath "/Library/Audio/Plug-Ins/HAL")

    (home-subpath "/Library/Dictionaries"))

(allow file-read-data
    (literal "/usr/local/lib/log")



    (subpath "/Library/Audio/Plug-Ins/Components"))


(allow user-preference-read
    (preference-domain
        "kCFPreferencesAnyApplication"
        "com.apple.Accessibility"
        "com.apple.ATS"
        "com.apple.CoreGraphics"
        "com.apple.DownloadAssessment"
        "com.apple.HIToolbox"
        "com.apple.LaunchServices"
        "com.apple.MultitouchSupport"

        "com.apple.ServicesMenu.Services"

        "com.apple.ViewBridge"

        "com.apple.WebFoundation"
        "com.apple.avfoundation"
        "com.apple.avfoundation.frecents"

        "com.apple.avfoundation.videoperformancehud"

        "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"

        "com.apple.networkConnect"
        "com.apple.speech.voice.prefs"
        "com.apple.systemsound"
        "com.apple.universalaccess"
        "edu.mit.Kerberos"
        "pbs"

))


(allow file-read*
    (literal "/Library/Preferences/com.apple.ViewBridge.plist"))


(allow file-read-data
    (literal "/Library/Preferences/com.apple.security.plist")
    (home-subpath "/Library/Preferences/com.apple.security.plist"))



(allow-read-directory-and-issue-read-extensions (param "WEBKIT2_FRAMEWORK_DIR"))



(allow-read-directory-and-issue-read-extensions "/System/Library/PrivateFrameworks/WebInspectorUI.framework")


(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"))


(allow mach-lookup

    (with report) (with telemetry)

    (global-name "com.apple.audio.AudioComponentRegistrar")
    (global-name "com.apple.awdd")
    (global-name "com.apple.cfprefsd.agent")
    (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")
)


(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")
       (global-name "com.apple.cfprefsd.daemon")
       (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")

       (global-name "com.apple.tccd")
       (global-name "com.apple.tccd.system")
       (global-name "com.apple.trustd.agent")

       (global-name "com.apple.CARenderServer")




)



(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"))



(allow mach-lookup
    (global-name "com.apple.SecurityServer")
    (global-name "com.apple.ocspd"))

(allow file-read* (subpath "/private/var/db/mds/system"))

(with-filter (uid 0)
    (allow file-write*
        (subpath "/private/var/db/mds/system"))

)

(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"))


(allow mach-lookup
    (global-name-regex #"^com.apple.distributed_notifications")



)

(allow file-read-data
    (literal "/dev/autofs_nowait"))

(allow ipc-posix-shm
    (ipc-posix-name-regex #"^CFPBS:"))

(allow system-fsctl (fsctl-command (_IO "h" 47)))


(allow network-outbound


       (literal "/private/var/run/syslog")
)


(allow file-read-data (path "/private/var/db/nsurlstoraged/dafsaData.bin"))



(allow mach-lookup
       (global-name "com.apple.system.logger")
       (global-name "com.apple.system.notification_center"))


(if (defined? 'vnode-type)
        (deny file-write-create (vnode-type SYMLINK)))


(deny file-read-xattr file-write-xattr (xattr-regex #"^com\.apple\.security\.private\."))

(deny file-read* file-write* (with no-log)


       (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2")
       (home-literal "/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2-journal"))



(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"))


(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"))



(allow file-read* (subpath "/private/var/db/datadetectors/sys"))


(allow iokit-open
    (iokit-user-client-class "IOHIDLibUserClient"))


(allow mach-lookup
    (global-name "com.apple.CoreAuthentication.agent.libxpc")
    (global-name "com.apple.remoted"))
