Hello,
I have encountered several challenges related to System Integrity Protection (SIP) state detection and code signing requirements. I would like to seek clarification and guidance on the proper approach to programmatically determine the SIP state.
Here are the issues I’ve encountered:
-
XPC Code Signing Check APIs:
- APIs like
setCodeSigningRequirement
andsetConnectionCodeSigningRequirement
do not work when SIP disabled and that's ok given what SIP is.
- APIs like
-
LaunchCodeRequirement API:
- When using
Process.launchRequirement
, theLaunchCodeRequirement
API does not function anymore when SIP disabled. - The
IsSIPProtected
requirement behaves in a way that is not clearly documented -- it appears to only apply to pre-installed Apple apps.
- When using
-
Legacy APIs:
- Older APIs like
SecCodeCheckValidity
are likely to be non-functional, though I haven’t had the chance to validate this yet.
- Older APIs like
-
Private API Concerns:
- So to mitigate those limitations I prefer my app to not even try to connect to untrusted XPC or launch untrusted Processes when SIP is disabled. The only way to determine SIP state I could find is a low-level C function
csr_get_active_config
. However, this function is not declared in any publicly available header file, indicating that it is a private API. - Since private APIs cannot be used in App Store-distributed apps and are best avoided for Developer ID-signed apps, this does not seem like a viable solution.
- So to mitigate those limitations I prefer my app to not even try to connect to untrusted XPC or launch untrusted Processes when SIP is disabled. The only way to determine SIP state I could find is a low-level C function
Given these limitations, what is the recommended and proper approach to programmatically determine the SIP state in a macOS application?
Any insights or guidance would be greatly appreciated.
Thank you!
AFAIK there’s no supported way to determine if SIP is enabled [1]. If you have a specific need for that, I recommend that you file an enhancement request for such an API, making sure to explain why it’s necessary.
Please post your bug number, just for the record.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] One option which you didn’t mention is to run csrutil status
, but that’s also not something I’d recommend.