




























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







(allow mach-register
    (local-name
        "com.apple.axserver"
        "com.apple.tsm.portname"))


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

    (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
    (require-all
        (literal "/dev/dtracehelper")
        (require-any
            (csr CSR_ALLOW_APPLE_INTERNAL)
            (csr CSR_ALLOW_UNRESTRICTED_DTRACE)))
)


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

(define (IOAcceleratorMessageFilter)
    (apply-message-filter
        (allow (with telemetry) (with message "IOAccelerator")
            iokit-async-external-method
            iokit-external-method
        )
        (allow iokit-async-external-method
            (iokit-method-number
                0
                47
            )
        )
        (allow iokit-external-method
            (iokit-method-number
                0
                1
                2
                3
                4
                5
                6
                7
                8
                9
                10
                11
                12
                13
                15
                16
                17
                18
                22
                23
                24
                29
                30
                31
                40
                42
                48
                256
                257
                258
                259
                260
                261
                262
                267
                512
            )
        )
        (deny (with telemetry)
            iokit-external-trap
        )
    )
)

(define (IOSurfaceRootUserClientMessageFilter)
    (apply-message-filter
        (allow (with telemetry) (with message "IOSurfaceRootUserClient")
            iokit-async-external-method
            iokit-external-method
        )
        (allow iokit-async-external-method
            (iokit-method-number
                17
            )
        )
        (allow iokit-external-method
            (iokit-method-number
                0
                1
                2
                3
                9
                10
                11
                12
                13
                14
                15
                20
                23
                27
                31
                32
                34
                35
                44
            )
        )
        (deny (with telemetry)
            iokit-external-trap
        )
    )
)


(define (system-graphics)


    (allow user-preference-read
        (preference-domain "com.apple.opengl")
        (preference-domain "com.nvidia.OpenGL"))


    (allow mach-lookup
        (require-all
            (extension "com.apple.webkit.extension.mach")
            (global-name "com.apple.cvmsServ")
        )
    )
    (deny mach-lookup



        (require-all
            (require-not (extension "com.apple.webkit.extension.mach"))
            (global-name "com.apple.cvmsServ")
        )
    )

    (allow file-read*
        (prefix "/private/var/db/CVMS/cvmsCodeSignObj"))



    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-connection "IOAccelerator")
            )
            (with telemetry-backtrace)
            (IOAcceleratorMessageFilter)
        )


        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-connection "IOAccelerator")
            )
        )
    )
    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "IOAccelerationUserClient")
            )
            (with telemetry-backtrace)
            (apply-message-filter
                (deny (with telemetry)
                    iokit-async-external-method
                    iokit-external-trap
                    iokit-external-method
                )
            )
        )


        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "IOAccelerationUserClient")
            )
        )
    )
    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "IOSurfaceRootUserClient")
            )
            (with telemetry-backtrace)
            (IOSurfaceRootUserClientMessageFilter)
        )


        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "IOSurfaceRootUserClient")
            )
        )
    )



    (allow iokit-open
        (iokit-registry-entry-class "IOFramebufferSharedUserClient"))




    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "AppleIntelMEUserClient")
            )
            (with telemetry-backtrace)
            (apply-message-filter
                (allow (with telemetry) (with message "AppleIntelMEUserClient")
                    iokit-external-method
                )
                (allow iokit-external-method
                    (iokit-method-number
                        120
                    )
                )
                (deny (with telemetry)
                    iokit-async-external-method
                    iokit-external-trap
                )
            )
        )


        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "AppleIntelMEUserClient")
            )
        )
    )



    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "AppleSNBFBUserClient")
            )
            (with telemetry-backtrace)
            (apply-message-filter
                (allow (with telemetry) (with message "AppleSNBFBUserClient")
                    iokit-external-method
                )
                (allow iokit-external-method
                    (iokit-method-number
                        120
                    )
                )
                (deny (with telemetry)
                    iokit-async-external-method
                    iokit-external-trap
                )
            )
        )


        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "AppleSNBFBUserClient")
            )
        )
    )



    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "AGPMClient")
            )
            (with telemetry-backtrace)
            (apply-message-filter
                (deny (with telemetry)
                    iokit-async-external-method
                    iokit-external-trap
                    iokit-external-method
                )
            )
        )


        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "AGPMClient")
            )
        )
    )
    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "AppleGraphicsControlClient")
            )
            (with telemetry-backtrace)
            (apply-message-filter
                (allow (with telemetry) (with message "AppleGraphicsControlClient")
                    iokit-async-external-method
                    iokit-external-method
                )
                (allow iokit-external-method
                    (iokit-method-number
                        0
                        1
                        3
                        11
                    )
                )
                (deny (with telemetry)
                    iokit-external-trap
                )
            )
        )


        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "AppleGraphicsControlClient")
            )
        )
    )
    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "AppleGraphicsPolicyClient")
            )
            (with telemetry-backtrace)
            (apply-message-filter
                (deny (with telemetry)
                    iokit-async-external-method
                    iokit-external-trap
                    iokit-external-method
                )
            )
        )


        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "AppleGraphicsPolicyClient")
            )
        )
    )


    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "AppleMGPUPowerControlClient")
            )
            (with telemetry-backtrace)
            (apply-message-filter
                (allow (with telemetry) (with message "AppleMGPUPowerControlClient")
                    iokit-external-method
                )
                (allow iokit-external-method
                    (iokit-method-number
                        0
                        1
                        3
                    )
                )
                (deny (with telemetry)
                    iokit-async-external-method
                    iokit-external-trap
                )
            )
        )


        (allow iokit-open
            (require-all
                (extension "com.apple.webkit.extension.iokit")
                (iokit-registry-entry-class "AppleMGPUPowerControlClient")
            )
        )
    )


    (allow file-read*
        (subpath "/Library/GPUBundles"))
)






(deny process-info*)



(allow process-info-pidinfo)

(allow process-info-setcontrol (target self))
(allow process-info-dirtycontrol (target self))



(allow process-codesigning-status*)


(deny sysctl*)
(allow sysctl-read
    (sysctl-name
        "hw.byteorder"
        "hw.busfrequency_max"
        "hw.cpufamily"

        "hw.cputype"
        "hw.cputhreadtype"
        "hw.logicalcpu"
        "hw.machine"
        "hw.memsize"
        "hw.model"
        "hw.ncpu"
        "hw.physicalcpu"

        "hw.vectorunit"
        "kern.bootargs"

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

        "kern.ostype"
        "kern.osversion"
        "kern.safeboot"
        "kern.version"
        "machdep.cpu.brand_string"
        "security.mac.sandbox.sentinel"
        "sysctl.name2oid"
        "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 iokit-get-properties)
(allow iokit-get-properties
    (iokit-property "AAPL,LCD-PowerState-ON")

    (iokit-property "AGCInfo")
    (iokit-property-regex #"^Accel(Caps|NativeDMARowByteAlignment)")
    (iokit-property-regex #"^(Accurate|Extended)MaxDigitizerPressureValue")
    (iokit-property-regex #"^(Activation|Animation)Thresholds")
    (iokit-property "ActuationSupported")
    (iokit-property "AllowDisplaySleep")
    (iokit-property "AlwaysNeedsVelocityCalculated")
    (iokit-property-regex #"Apple(GVAKeyDoesNotExist|IntelMEVABundleName)")
    (iokit-property-regex #"^AAPL,(DisplayPipe|OpenCLdisabled|IOGraphics_LER(|_RegTag_1|_RegTag_0|_Busy_2)|alias-policy|boot-display|display-alias|mux-switch-state|ndrv-dev|primary-display|slot-name)")
    (iokit-property-regex #"^ATY,(cbits|fb_(linebytes|offset|size)|intrev)")
    (iokit-property "ATY,DeviceName")

    (iokit-property "ATY,EFIDisplay")
    (iokit-property "ATY,FamilyName")

    (iokit-property "AVCSupported")
    (iokit-property "BacklightHandle")
    (iokit-property "BlockSize")
    (iokit-property-regex #"^CEA(ModeID|PixelRepetition)")
    (iokit-property "CFBundleIdentifier")
    (iokit-property "CFBundleIdentifierKernel")

    (iokit-property "CapsLockDelay")
    (iokit-property "CaseSensitive")
    (iokit-property "ConfigState")
    (iokit-property "DPLanes")
    (iokit-property "DPLinkBit")
    (iokit-property "DPLinkRate")
    (iokit-property "Description")
    (iokit-property "Development")
    (iokit-property-regex #"^Device( Characteristics|EqID)")
    (iokit-property "DisplayRouting")
    (iokit-property "Driver is Ready")
    (iokit-property "Ejectable")
    (iokit-property "EnableLPVP")
    (iokit-property "Encrypted")
    (iokit-property "Endianness")
    (iokit-property "Family ID")
    (iokit-property "ForceSupported")
    (iokit-property "Formats")
    (iokit-property "FramebufferEnabled")
    (iokit-property "FramebufferStarted")
    (iokit-property "GPUConfigurationVariable")
    (iokit-property "GPUDCCDisplayable")
    (iokit-property "GPUDebugNullClientMask")
    (iokit-property "GpuDebugPolicy")
    (iokit-property "GPURawCounterBundleName")
    (iokit-property "GPURawCounterPluginClassName")
    (iokit-property "HEVCSupported")
    (iokit-property "HIDPointerAccelerationType")
    (iokit-property "HwCtxCacheUpdate")
    (iokit-property-regex #"^IOAccel(DisplayPipeCapabilities|Index|Types|Revision)")
    (iokit-property-regex #"^IO(Class|MatchCategory|NameMatch)")
    (iokit-property-regex #"^IOAudioControl(ChannelID|ID|SubType|Usage|Value)")
    (iokit-property-regex #"^IOAudioDevice(CanBeDefaults|TransportType)")
    (iokit-property-regex #"^IOAudioEngine(ChannelNames|ClientDescription|CoreAudioPlugIn|(|Device)Description|Flavor|GlobalUniqueID|IsHidden|OutputChannelLayout|SampleOffset|State)")
    (iokit-property-regex #"^IOAudioEngineClock(Domain|IsStable)")
    (iokit-property "IOAudioEngineDisableClockBoundsCheck")
    (iokit-property-regex #"^IOAudioEngine(Input|Output)Sample(Latency|Offset)")
    (iokit-property-regex #"^IOAudioEngineNum(ActiveUserClients|SampleFramesPerBuffer)")
    (iokit-property "IOAudioSampleRate")
    (iokit-property "IOAudioStreamSampleFormatByteOrder")
    (iokit-property-regex #"^IOAV(.*)(De|En)code$")
    (iokit-property "IOBacklightHandlerID")
    (iokit-property "IOBusyInterest")
    (iokit-property "IOCFPlugInTypes")
    (iokit-property "IOChildIndex")
    (iokit-property-regex #"^IOClass(|NameOverride)")
    (iokit-property "IOConsoleUsers")
    (iokit-property "IODVDBundleName")
    (iokit-property "IODeviceMemory")
    (iokit-property "IODisplayParameters")
    (iokit-property-regex #"^IOFB(CLUTDefer|Config|CursorInfo|Dependent(ID|Index))")
    (iokit-property "IOFBCurrentPixelClock")
    (iokit-property-regex #"^IOFBCurrentPixelCount(|Real)")
    (iokit-property-regex #"^IOFB(DetailedTimings|Gamma(Count|HeaderSize|Width))")
    (iokit-property-regex #"^IOFB(Blue|Green|Red)GammaScale")
    (iokit-property-regex #"^IOFBI2CInterface(IDs|Info)")
    (iokit-property-regex #"^IOFB(HDMIDongleROM|Integrated|MemorySize|NeedsRefresh|ProbeOptions|ScalerInfo|TimingRange|Transform|UIScale|WaitCursor(Frames|Period))")
    (iokit-property "IOFramebufferOpenGLIndex")
    (iokit-property "IOGeneralInterest")
    (iokit-property "IOGLBundleName")
    (iokit-property-regex #"^IOGVA(BGRAEnc|Codec|EncoderRestricted|Scaler|VTCapabilities|HEVCDecodeCapabilities|HEVCEncodeCapabilities)")
    (iokit-property-regex #"^IOGVA(.*)(De|En)code$")
    (iokit-property "IOHibernateState")
    (iokit-property "IOI2CTransactionTypes")
    (iokit-property-regex #"^IOInterrupt(Controllers|Specifiers)")
    (iokit-property "IOKitDebug")
    (iokit-property "IOMatchCategory")
    (iokit-property "IOMediaIcon")
    (iokit-property "IONDRVFramebufferGeneration")
    (iokit-property "IONVRAMProperty")
    (iokit-property-regex #"^IOName(|Match(|ed))")
    (iokit-property "IOOCDBundleName")
    (iokit-property "IOPCITunnelled")
    (iokit-property "IOPCITunnelCompatible")
    (iokit-property "IOPMStrictTreeOrder")
    (iokit-property "IOParentMatch")
    (iokit-property-regex #"^IOPCI((Class|Primary|Property|)Match|Express(Capabilities|Link(Status|Capabilities))|MSIMode|Resourced|Tunnelled)")
    (iokit-property "IOPMIsPowerManaged")
    (iokit-property "IOPersonalityPublisher")
    (iokit-property-regex #"^IOPlatform(SerialNumber|UUID)")
    (iokit-property "IOPowerManagement")
    (iokit-property "IOProbeScore")
    (iokit-property "IOPropertyMatch")
    (iokit-property "IOProviderClass")
    (iokit-property-regex #"^IOReport(Lures|Legend(|Public))")
    (iokit-property "IOScreenRestoreState")
    (iokit-property "IOSourceVersion")
    (iokit-property-regex #"^IOVA(BundleName|Renderer(|Sub)ID)")
    (iokit-property-regex #"^InternalStatistics(|Accm)")
    (iokit-property-regex #"^MetalPlugin(Name|ClassName)")
    (iokit-property "MetalStatisticsName")
    (iokit-property "MTHIDDevice")
    (iokit-property "MT Built-In")
    (iokit-property "MaintainPowerInUILock")
    (iokit-property "Max Packet Size")
    (iokit-property "MinDigitizerPressureValue")
    (iokit-property "Multitouch Serial Number")
    (iokit-property-regex #"^Multitouch (Subdevice |)ID")
    (iokit-property "NVArch")
    (iokit-property-regex #"^NVC(AP|LASS)")
    (iokit-property-regex #"^NVDA,(Features|NVPresentment-version|accel-loaded|invalid-config|mm-version)")
    (iokit-property "NVDA,Enable-A2R10G10B10Format")
    (iokit-property-regex #"^NVDA(Type|initgl_created)")
    (iokit-property "NVRAMProperty")
    (iokit-property "NXSystemInfo")
    (iokit-property-regex #"^VRAM,(memvendorID|total(MB|size))")
    (iokit-property "NoAutoRoute")
    (iokit-property-regex #"^Num(Blocks|Streams)")
    (iokit-property-regex #"^PerformanceStatistics(|Accum)")
    (iokit-property "Protocol Characteristics")
    (iokit-property "Removable")
    (iokit-property-regex #"^ResetOn(Lock|Unlock)Ms")
    (iokit-property "SWIP_properties")
    (iokit-property "SafeEjectRequested")
    (iokit-property "SampleRates")
    (iokit-property "Serial Number")
    (iokit-property "StartupDisplay")
    (iokit-property "SurfaceList")
    (iokit-property-regex #"^Support(AudioAUUC|sSilentClick|TapToWake)")
    (iokit-property-regex #"^Sensor (Columns|Rows)")
    (iokit-property-regex #"^Sensor Region (Descriptor|Param|Rows)")
    (iokit-property-regex #"^Sensor Surface (Descriptor|Height|Width)")
    (iokit-property "SurfaceList")
    (iokit-property "TimeStampFiltering")
    (iokit-property "Transport")
    (iokit-property "USBADC")

    (iokit-property "UserClientEnabled")
    (iokit-property "VRAM,totalMB")
    (iokit-property "WANTS_FRAMES_IGNORED")
    (iokit-property-regex #"^acpi-(device|path)")
    (iokit-property "assigned-addresses")
    (iokit-property "attached-gpu-control-path")
    (iokit-property-regex #"^audio-(codec-info|device-mvalue|device-nvalue|selector)")
    (iokit-property "av-signal-type")
    (iokit-property "backlight-PWM-freq")
    (iokit-property "bcdVersion")
    (iokit-property-regex #"^(board|device|revision|subsystem|vendor)-id")
    (iokit-property "boot-gamma-restored")
    (iokit-property "built-in")
    (iokit-property "cail_properties")
    (iokit-property-regex #"^canvas-(height|width)")
    (iokit-property "class-code")
    (iokit-property "color-accuracy-index")
    (iokit-property "compatible")
    (iokit-property "connector-type")
    (iokit-property-regex #"^(device|revision|subsystem-vendor|touch-size)-id")
    (iokit-property "device_type")
    (iokit-property "display-bpc")
    (iokit-property "display-connect-flags")
    (iokit-property "display-link-component-bits")
    (iokit-property "display-pixel-component-bits")
    (iokit-property "display-type")
    (iokit-property "dpm")
    (iokit-property "errordb")

    (iokit-property "filevault-image")

    (iokit-property "graphic-options")
    (iokit-property "hda-gfx")
    (iokit-property-regex #"^id(Product|Vendor)")
    (iokit-property "iofb_version")
    (iokit-property "image-encrypted")
    (iokit-property "image-path")

    (iokit-property "locationID")

    (iokit-property "model")
    (iokit-property "mt-device-id")
    (iokit-property "name")
    (iokit-property "nv-stats")
    (iokit-property "od-server-name")

    (iokit-property-regex #"^parser-(options|type)")
    (iokit-property-regex #"^pci(-aspm-default|debug)")
    (iokit-property "port-number")
    (iokit-property "reg")
    (iokit-property "rm_board_number")
    (iokit-property-regex #"^(rom|vbios)-revision")
    (iokit-property "saved-config")
    (iokit-property "startup-timing")
    (iokit-property "touch-size-id")

    (iokit-property "ATY,cbits")
    (iokit-property "ATY,intrev")
    (iokit-property "AccelNativeDMARowByteAlignment")
    (iokit-property "CompactVRAM")
    (iokit-property "EnableBlitLib")
    (iokit-property "ForceDisableEDRAM")
    (iokit-property "GPUConfigurationVariable")
    (iokit-property "GpuDebugPolicy")
    (iokit-property "IOKitDebug")
    (iokit-property "IOPCIMatch")
    (iokit-property "IOOCDBundleName")
    (iokit-property "MetalStatisticsScriptName")
    (iokit-property "MetalCoalesce")
    (iokit-property "PanicOnGPUHang")
    (iokit-property "TelemetryDisable")
    (iokit-property "cail_properties")
    (iokit-property "dpm")

    (iokit-property "IOGVAH264EncodeCapabilities")





)


(if (equal? (param "CPU") "arm64")
    (allow iokit-get-properties
        (iokit-property "ADSSupported")
        (iokit-property "IOAVDHEVCDecodeCapabilities")
        (iokit-property "IOGLESBundleName")

        (iokit-property "MetalPluginClassName")

        (iokit-property "MetalPluginName")

        (iokit-property "IOSurfaceAcceleratorCapabilitiesDict")

        (iokit-property "acoustic-id")

    ))

(if (equal? (param "CPU") "arm64")
    (with-filter (iokit-registry-entry-class "IOService")
        (allow iokit-get-properties
            (iokit-property "IORegistryEntryPropertyKeys"))))

(if (equal? (param "CPU") "arm64")
    (with-filter (iokit-registry-entry-class "IOMobileFramebuffer")
        (allow iokit-get-properties
            (iokit-property "AppleTV"
                            "DisplayPipePlaneBaseAlignment"
                            "DisplayPipeStrideRequirements"
                            "dfr"
                            "external"
                            "hdcp-hoover-protocol"))))

(if (equal? (param "CPU") "arm64")
    (with-filter (iokit-registry-entry-class "IOPlatformDevice")
        (allow iokit-get-properties
            (iokit-property "soc-generation"))))

(if (equal? (param "CPU") "arm64")
    (with-filter (iokit-registry-entry-class "IOService")
        (allow iokit-get-properties
            (iokit-property "chip-id"
                            "display-rotation"
                            "display-scale"))))

(deny mach-lookup (xpc-service-name-prefix ""))


(allow mach-lookup
    (xpc-service-name "com.apple.audio.SandboxHelper")
    (xpc-service-name "com.apple.print.normalizerd")
)



(allow mach-lookup
    (xpc-service-name-regex #"\.apple-extension-service$")
)



(allow mach-lookup
    (global-name "com.apple.cfprefsd.agent")
    (global-name "com.apple.cfprefsd.daemon")
)




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



(with-filter (system-attribute apple-internal)
    (if (defined? 'mach-register)
        (allow mach-register
            (global-name-regex #"^_oglprof_attach_<[0-9]+>$")))
)

(if (positive? (string-length (param "DARWIN_USER_CACHE_DIR")))
    (allow-read-write-directory-and-issue-read-write-extensions (param "DARWIN_USER_CACHE_DIR")))

(if (positive? (string-length (param "DARWIN_USER_TEMP_DIR")))
    (allow-read-write-directory-and-issue-read-write-extensions (param "DARWIN_USER_TEMP_DIR")))



(allow iokit-open
    (iokit-user-client-class "AppleMultitouchDeviceUserClient")
    (iokit-user-client-class "IOHIDParamUserClient")
)
(if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
    (allow iokit-open
        (require-all
            (extension "com.apple.webkit.extension.iokit")
            (iokit-user-client-class "AppleUpstreamUserClient")
        )
        (with telemetry-backtrace)
        (apply-message-filter
            (allow (with telemetry) (with message "AppleUpstreamUserClient")
                iokit-external-method
            )
            (allow iokit-external-method
                (iokit-method-number
                    0
                    1
                    3
                    4
                    5
                )
            )
            (deny (with telemetry)
                iokit-async-external-method
                iokit-external-trap
            )
        )
    )


    (allow iokit-open
        (require-all
            (extension "com.apple.webkit.extension.iokit")
            (iokit-user-client-class "AppleUpstreamUserClient")
        )
    )
)

(if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
    (allow iokit-open
        (require-all
            (extension "com.apple.webkit.extension.iokit")
            (iokit-user-client-class "RootDomainUserClient")

        )
        (with telemetry-backtrace)
        (apply-message-filter
            (allow (with telemetry) (with message "RootDomainUserClient")
                iokit-external-method
            )
            (allow iokit-external-method
                (iokit-method-number
                    3
                )
            )
            (deny (with telemetry)
                iokit-async-external-method
                iokit-external-trap
            )
        )
    )


    (allow iokit-open
        (require-all
            (extension "com.apple.webkit.extension.iokit")
            (iokit-user-client-class "RootDomainUserClient")

        )
    )
)


(if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
    (allow iokit-open
        (require-all
            (extension "com.apple.webkit.extension.iokit")
            (iokit-user-client-class "AudioAUUC")
        )
        (with telemetry-backtrace)
        (apply-message-filter
            (allow (with telemetry) (with message "AudioAUUC")
                iokit-external-method
            )
            (allow iokit-external-method
                (iokit-method-number
                    0
                    1
                    3
                    4
                    5
                )
            )
            (deny (with telemetry)
                iokit-async-external-method
                iokit-external-trap
            )
        )
    )


    (allow iokit-open
        (require-all
            (extension "com.apple.webkit.extension.iokit")
            (iokit-user-client-class "AudioAUUC")
        )
    )
)

(if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
    (allow iokit-open
        (require-all
            (extension "com.apple.webkit.extension.iokit")
            (iokit-user-client-class "IOAudioControlUserClient")
        )
        (with telemetry-backtrace)
        (apply-message-filter
            (deny (with telemetry)
                iokit-async-external-method
                iokit-external-trap
                iokit-external-method
            )
        )
    )


    (allow iokit-open
        (require-all
            (extension "com.apple.webkit.extension.iokit")
            (iokit-user-client-class "IOAudioControlUserClient")
        )
    )
)

(if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
    (allow iokit-open
        (require-all
            (extension "com.apple.webkit.extension.iokit")
            (iokit-user-client-class "IOAudioEngineUserClient")
        )
        (with telemetry-backtrace)
        (apply-message-filter
            (deny (with telemetry)
                iokit-async-external-method
                iokit-external-trap
                iokit-external-method
            )
        )
    )


    (allow iokit-open
        (require-all
            (extension "com.apple.webkit.extension.iokit")
            (iokit-user-client-class "IOAudioEngineUserClient")
        )
    )
)


(when (equal? (param "CPU") "arm64")
    (allow iokit-open



        (require-all
            (extension "com.apple.webkit.extension.iokit")
            (iokit-user-client-class
                "AppleAVDUserClient"
                "IOMobileFramebufferUserClient"
                "IOSurfaceAcceleratorClient"

            )
        )
    )
)




(allow ipc-posix-shm-read-data
    (ipc-posix-name "FNetwork.defaultStorageSession")
    (ipc-posix-name-regex #"\.PrivateBrowsing-")
    (ipc-posix-name-regex #"^WebKit Test-"))



(allow ipc-posix-shm-read* ipc-posix-shm-write-data



    (ipc-posix-name-regex #"^AudioIO"))


(allow mach-lookup
    (global-name "com.apple.coreservices.launchservicesd")
)



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



(allow mach-lookup
    (require-all
        (extension "com.apple.webkit.extension.mach")
        (global-name
            "com.apple.mobileassetd"
            "com.apple.mobileassetd.v2"
)))
(allow mach-lookup



       (global-name "com.apple.logd")
       (global-name "com.apple.logd.events")

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




)


(allow mach-lookup
    (global-name "com.apple.PowerManagement.control")
    (global-name "com.apple.SystemConfiguration.configd")
    (global-name "com.apple.assertiond.processassertionconnection")
)
(allow mach-lookup
    (global-name "com.apple.fonts")
)





(allow mach-lookup

    (global-name "com.apple.lsd.mapdb")
)



(allow mach-lookup
    (require-all
        (extension "com.apple.webkit.extension.mach")
        (xpc-service-name "com.apple.MTLCompilerService")
    )
)

(allow mach-lookup (with report)



    (require-all
        (require-not (extension "com.apple.webkit.extension.mach"))
        (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* file-write* (subpath "/private/var/db/mds/system"))




(allow file-read*
       (subpath "/private/var/db/mds")
       (literal "/private/var/db/DetachedSignatures"))
(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:"))




(system-graphics)



(allow network-outbound






       (literal "/private/var/run/mDNSResponder")
       (remote tcp)
)



(with-filter (system-attribute apple-internal)
    (allow network-outbound
       (literal "/private/var/run/syslog")
    )
)


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



(if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "NO")
    (allow mach-lookup
        (global-name "com.apple.system.notification_center"))

    (allow mach-lookup
        (global-name "com.apple.system.notification_center")
        (apply-message-filter
            (deny mach-message-send (with telemetry))
            (deny mach-message-send (with no-report) (message-number 1023))
            (allow mach-message-send (with telemetry) (message-number
                1002
                1010
                1011
                1012
                1016
                1017
                1018
                1021
                1022
                1025
                1026
            ))
            (allow mach-message-send (message-number
                1028
                1029
                1030
                1031
                1032
            ))
        )
    )
)



(deny mach-lookup
    (global-name "com.apple.system.logger")
    (with no-report))
(with-filter (uid 0)
    (allow mach-lookup
        (global-name "com.apple.system.logger"))
)

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



(if (not (defined? 'sbpl-filter?))
  (define (sbpl-filter? x)
      (and (list? x)
           (eq? (car x) 'filter))))

(macro (with-filter form)
   (let* ((ps (cdr form))
          (extra-filter (car ps))
          (rules (cdr ps)))
    `(letrec
        ((collect
             (lambda (l filters non-filters)
                 (if (null? l)
                     (list filters non-filters)
                     (let*
                         ((x (car l))
                          (rest (cdr l)))
                         (if (sbpl-filter? x)
                             (collect rest (cons x filters) non-filters)
                             (collect rest filters (cons x non-filters)))))))
         (inject-filter
             (lambda args
                 (let* ((collected (collect args '() '()))
                        (filters (car collected))
                        (non-filters (cadr collected)))
                 (if (null? filters)
                     (cons ,extra-filter non-filters)
                     (cons (require-all (apply require-any filters) ,extra-filter) non-filters)))))
         (orig-allow allow)
         (orig-deny deny)
         (wrapper
             (lambda (action)
                 (lambda args (apply action (apply inject-filter args))))))
        (set! allow (wrapper orig-allow))
        (set! deny (wrapper orig-deny))
        ,@rules
        (set! deny orig-deny)
        (set! allow orig-allow))))

(define (home-library-preferences-regex home-library-preferences-relative-regex)
    (regex (string-append "^" (regex-quote (param "HOME_LIBRARY_PREFERENCES_DIR")) home-library-preferences-relative-regex)))

(define (home-library-preferences-literal home-library-preferences-relative-literal)
    (literal (string-append (param "HOME_LIBRARY_PREFERENCES_DIR") home-library-preferences-relative-literal)))

(define (shared-preferences-read . domains)
  (for-each (lambda (domain)
              (begin
                (if (defined? `user-preference-read)
                    (allow user-preference-read (preference-domain domain)))


                (allow file-read*
                       (literal (string-append "/Library/Preferences/" domain ".plist"))
                       (home-library-preferences-literal (string-append "/" domain ".plist"))
                       (home-library-preferences-regex (string-append #"/ByHost/" (regex-quote domain) #"\..*\.plist$")))))
            domains))


(with-filter (extension "com.apple.webkit.camera")
    (shared-preferences-read "com.apple.cmio")
    (shared-preferences-read "com.apple.coremedia")
    (allow file-read* (subpath "/Library/CoreMediaIO/Plug-Ins/DAL"))
    (allow mach-lookup (extension "com.apple.app-sandbox.mach"))
    (allow mach-lookup
        (global-name "com.apple.cmio.AppleCameraAssistant")
        (global-name "com.apple.cmio.registerassistantservice")
        (global-name "com.apple.cmio.registerassistantservice.system-extensions")


        (global-name "com.apple.cmio.VDCAssistant")
        (global-name "com.apple.cmio.AVCAssistant")
        (global-name "com.apple.cmio.IIDCVideoAssistant")


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


        (require-all
            (extension "com.apple.webkit.extension.mach")
            (global-name "com.apple.applecamerad")
        ))


    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
        (allow iokit-open
            (require-all
                (iokit-usb-interface-class kUSBVideoInterfaceClass)
                (iokit-user-client-class "IOUSBDeviceUserClientV2")
            )
            (with telemetry-backtrace)
            (apply-message-filter
                (allow (with telemetry)
                    iokit-external-method
                )
                (deny (with telemetry)
                    iokit-async-external-method
                    iokit-external-trap
                )
            )
        )


        (allow iokit-open
            (require-all
                (iokit-usb-interface-class kUSBVideoInterfaceClass)
                (iokit-user-client-class "IOUSBDeviceUserClientV2")
            )
        )
    )

    (if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
        (allow iokit-open
            (require-all
                (iokit-usb-interface-class kUSBVideoInterfaceClass)
                (iokit-user-client-class "IOUSBInterfaceUserClientV2")
            )
            (with telemetry-backtrace)
            (apply-message-filter
                (allow (with telemetry)
                    iokit-external-method
                )
                (deny (with telemetry)
                    iokit-async-external-method
                    iokit-external-trap
                )
            )
        )


        (allow iokit-open
            (require-all
                (iokit-usb-interface-class kUSBVideoInterfaceClass)
                (iokit-user-client-class "IOUSBInterfaceUserClientV2")
            )
        )
    )

    (allow device-camera))



(deny file-write*
    (home-subpath "/Library/Preferences/")
    (with no-log))

(deny mach-lookup (with no-log)
    (xpc-service-name "com.apple.audio.toolbox.reporting.service")
)
(allow mach-lookup
    (require-all
        (extension "com.apple.webkit.extension.mach")
        (global-name
            "com.apple.analyticsd"
            "com.apple.nehelper"

            "com.apple.nesessionmanager.content-filter"



            "com.apple.webinspector"
            "com.apple.cfprefsd.agent"
            "com.apple.cfprefsd.daemon"
            "com.apple.containermanagerd"
            "com.apple.coreservices.launchservicesd"
            "com.apple.diagnosticd"
            "com.apple.iconservices"
            "com.apple.iconservices.store"
            "com.apple.tccd"



            "com.apple.accessibility.mediaaccessibilityd"
            "com.apple.audio.AudioComponentRegistrar" "com.apple.audio.audiohald" "com.apple.coremedia.endpoint.xpc" "com.apple.coremedia.endpointstream.xpc"
            "com.apple.coremedia.endpointplaybacksession.xpc" "com.apple.coremedia.endpointremotecontrolsession.xpc" "com.apple.coremedia.routediscoverer.xpc"
            "com.apple.coremedia.routingcontext.xpc" "com.apple.coremedia.volumecontroller.xpc" "com.apple.lskdd" "com.apple.mediaremoted.xpc" "com.apple.trustd.agent"


        )
    )
)

(allow mach-lookup
    (require-all
        (extension "com.apple.webkit.extension.mach")
        (xpc-service-name


            "com.apple.audio.SandboxHelper"
            "com.apple.coremedia.videodecoder"
            "com.apple.coremedia.videoencoder"


        )
    )
)


(allow system-fsctl
    (fsctl-command (_IO "h" 47)))
(when (defined? 'syscall-unix)
    (deny syscall-unix (with send-signal SIGKILL))
    (allow syscall-unix
        (syscall-number SYS_abort_with_payload)
        (syscall-number SYS_exit)
        (syscall-number SYS_read)
        (syscall-number SYS_write)
        (syscall-number SYS_open)
        (syscall-number SYS_close)
        (syscall-number SYS_unlink)
        (syscall-number SYS_chmod)
        (syscall-number SYS_chmod_extended)
        (syscall-number SYS_getuid)
        (syscall-number SYS_geteuid)
        (syscall-number SYS_recvfrom)
        (syscall-number SYS_getpeername)
        (syscall-number SYS_access)
        (syscall-number SYS_dup)
        (syscall-number SYS_pipe)
        (syscall-number SYS_getegid)
        (syscall-number SYS_getgid)
        (syscall-number SYS_sigprocmask)
        (syscall-number SYS_sigaltstack)
        (syscall-number SYS_ioctl)
        (syscall-number SYS_readlink)
        (syscall-number SYS_umask)
        (syscall-number SYS_msync)
        (syscall-number SYS_munmap)
        (syscall-number SYS_mprotect)
        (syscall-number SYS_madvise)
        (syscall-number SYS_fcntl)
        (syscall-number SYS_select)
        (syscall-number SYS_fsync)
        (syscall-number SYS_setpriority)
        (syscall-number SYS_socket)
        (syscall-number SYS_connect)
        (syscall-number SYS_setsockopt)
        (syscall-number SYS_gettimeofday)
        (syscall-number SYS_getrusage)
        (syscall-number SYS_getsockopt)
        (syscall-number SYS_writev)
        (syscall-number SYS_fchmod)
        (syscall-number SYS_rename)
        (syscall-number SYS_flock)
        (syscall-number SYS_sendto)
        (syscall-number SYS_shutdown)
        (syscall-number SYS_socketpair)
        (syscall-number SYS_mkdir)
        (syscall-number SYS_rmdir)
        (syscall-number SYS_pread)
        (syscall-number SYS_pwrite)
        (syscall-number SYS_csops)
        (syscall-number SYS_csops_audittoken)
        (syscall-number SYS_kdebug_trace64)
        (syscall-number SYS_kdebug_trace)
        (syscall-number SYS_sigaction)
        (syscall-number SYS_sigreturn)
        (syscall-number SYS_pathconf)
        (syscall-number SYS_getrlimit)
        (syscall-number SYS_setrlimit)
        (syscall-number SYS_mmap)
        (syscall-number SYS_lseek)
        (syscall-number SYS_ftruncate)
        (syscall-number SYS_sysctl)
        (syscall-number SYS_mlock)
        (syscall-number SYS_munlock)
        (syscall-number SYS_getattrlist)
        (syscall-number SYS_getxattr)
        (syscall-number SYS_fgetxattr)
        (syscall-number SYS_listxattr)
        (syscall-number SYS_shm_open)
        (syscall-number SYS_sem_wait)
        (syscall-number SYS_sem_post)
        (syscall-number SYS_sysctlbyname)
        (syscall-number SYS_psynch_mutexwait)
        (syscall-number SYS_psynch_mutexdrop)
        (syscall-number SYS_psynch_cvbroad)
        (syscall-number SYS_psynch_cvsignal)
        (syscall-number SYS_psynch_cvwait)
        (syscall-number SYS_psynch_rw_wrlock)
        (syscall-number SYS_psynch_rw_unlock)
        (syscall-number SYS_psynch_cvclrprepost)
        (syscall-number SYS_process_policy)
        (syscall-number SYS_issetugid)
        (syscall-number SYS___pthread_kill)
        (syscall-number SYS___pthread_markcancel)
        (syscall-number SYS___pthread_sigmask)
        (syscall-number SYS___disable_threadsignal)
        (syscall-number SYS___semwait_signal)
        (syscall-number SYS___semwait_signal_nocancel)
        (syscall-number SYS_proc_info)
        (syscall-number SYS_stat64)
        (syscall-number SYS_fstat64)
        (syscall-number SYS_lstat64)
        (syscall-number SYS_getdirentries64)
        (syscall-number SYS_statfs64)
        (syscall-number SYS_fstatfs64)
        (syscall-number SYS_getfsstat64)
        (syscall-number SYS_getaudit_addr)
        (syscall-number SYS_bsdthread_create)
        (syscall-number SYS_bsdthread_terminate)
        (syscall-number SYS_workq_kernreturn)
        (syscall-number SYS_thread_selfid)
        (syscall-number SYS_kevent)
        (syscall-number SYS_kevent_qos)
        (syscall-number SYS_kevent_id)
        (syscall-number SYS___mac_syscall)
        (syscall-number SYS_read_nocancel)
        (syscall-number SYS_write_nocancel)
        (syscall-number SYS_open_nocancel)
        (syscall-number SYS_close_nocancel)
        (syscall-number SYS_sendmsg_nocancel)
        (syscall-number SYS_recvfrom_nocancel)
        (syscall-number SYS_fcntl_nocancel)
        (syscall-number SYS_select_nocancel)
        (syscall-number SYS_connect_nocancel)
        (syscall-number SYS_sendto_nocancel)
        (syscall-number SYS_fsgetpath)
        (syscall-number SYS_fileport_makeport)
        (syscall-number SYS_guarded_open_np)
        (syscall-number SYS_guarded_close_np)
        (syscall-number SYS_guarded_write_np)
        (syscall-number SYS_change_fdguard_np)
        (syscall-number SYS_proc_rlimit_control)
        (syscall-number SYS_connectx)
        (syscall-number SYS_getattrlistbulk)
        (syscall-number SYS_openat)
        (syscall-number SYS_openat_nocancel)
        (syscall-number SYS_fstatat64)
        (syscall-number SYS_mkdirat)
        (syscall-number SYS_bsdthread_ctl)
        (syscall-number SYS_csrctl)
        (syscall-number SYS_guarded_pwrite_np)
        (syscall-number SYS_getentropy)
        (syscall-number SYS_necp_open)
        (syscall-number SYS_necp_client_action)
        (syscall-number SYS_ulock_wait)
        (syscall-number SYS_ulock_wake)
        (syscall-number SYS_work_interval_ctl)
        (syscall-number SYS_kdebug_typefilter)
        (syscall-number SYS_gettid)

        (syscall-number SYS_memorystatus_control)

        (syscall-number SYS_kdebug_trace_string)

        (syscall-number SYS_psynch_rw_rdlock)

        (syscall-number SYS_terminate_with_payload)

        (syscall-number SYS_quotactl)

        (syscall-number SYS_stat64_extended)

        (syscall-number SYS_lstat_extended)
        (syscall-number SYS_lstat64_extended)
        (syscall-number SYS_fgetattrlist)

        (syscall-number SYS_kqueue)

        (syscall-number SYS_kqueue_workloop_ctl)

        (syscall-number SYS_faccessat)

        (syscall-number SYS_fsetxattr)





        (syscall-number SYS_fstat64_extended)

        (syscall-number SYS_gethostuuid)
        (syscall-number SYS_setattrlist)

        (syscall-number SYS_open_dprotected_np)

    )

    (if (equal? (param "CPU") "arm64")
        (allow syscall-unix
            (syscall-number SYS_fileport_makefd)
            (syscall-number SYS_guarded_open_dprotected_np)

            (syscall-number SYS_mremap_encrypted)
        )
    )





)
(if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
    (allow iokit-open
        (with telemetry-backtrace)
        (require-all
            (require-not (extension "com.apple.webkit.extension.iokit"))
            (iokit-registry-entry-class
                "IOSurfaceRootUserClient"
            )
        )
        (IOSurfaceRootUserClientMessageFilter)
    )


    (allow iokit-open
        (require-all
            (require-not (extension "com.apple.webkit.extension.iokit"))
            (iokit-registry-entry-class
                "IOSurfaceRootUserClient"
            )
        )
    )
)

(when (equal? (param "CPU") "arm64")
    (allow iokit-open (with report)



        (require-all
            (require-not (extension "com.apple.webkit.extension.iokit"))
            (iokit-user-client-class
                "AppleAVDUserClient"
                "IOSurfaceAcceleratorClient"
            )
        )
    )
)

(if (equal? (param "ENABLE_SANDBOX_MESSAGE_FILTER") "YES")
    (allow iokit-open
        (with telemetry-backtrace)
        (require-all
            (require-not (extension "com.apple.webkit.extension.iokit"))
            (iokit-connection
                "IOAccelerator"
            )
        )
        (IOAcceleratorMessageFilter)
    )


    (allow iokit-open
        (require-all
            (require-not (extension "com.apple.webkit.extension.iokit"))
            (iokit-connection
                "IOAccelerator"
            )
        )
    )
)

(deny iokit-open



    (require-all
        (require-not (extension "com.apple.webkit.extension.iokit"))
        (iokit-user-client-class
            "AudioAUUC"
            "IOAudioControlUserClient"
            "IOAudioEngineUserClient"
        )
    )
)

(deny iokit-open



    (require-all
        (require-not (extension "com.apple.webkit.extension.iokit"))
        (iokit-registry-entry-class
            "AGPMClient"
            "AppleGraphicsControlClient"
            "AppleGraphicsPolicyClient"
            "AppleIntelMEUserClient"
            "AppleMGPUPowerControlClient"
            "AppleSNBFBUserClient"
            "IOAccelerationUserClient"
        )
    )
)

(deny iokit-open



    (require-all
        (require-not (extension "com.apple.webkit.extension.iokit"))
        (iokit-user-client-class
            "RootDomainUserClient"
        )
    )
)
