Your reference to keychain files suggest that you’re thinking about this in terms of the legacy file-based keychain on macOS. Before we go further, I recommend that you read TN3137 On Mac keychain APIs and implementations, which provides a lot of the background to this issue.
where (which keychain, which file) do these keys actually get saved?
SE-protected keys are only supported in the data protection keychain.
I realize there in a keychain somewhere, however they are invisible to
the user via Keychain Access and the security CLI.
I’m going to quote from TN3137 here:
Keychain Access displays all keychain items in file-based keychains but only password items in the data protection keychain.
and:
The keychain support in the security command-line tool is primarily focused on the file-based keychain.
Where do these keys actually live … ?
In the data protection keychain.
what mechanism/rules are hiding them from the user?
When Apple updated Keychain Access to show the data protection, we made an policy decision keychain to only show password items. For better or worse. If you disagree with that choice, feel free to file a bug against Keychain Access. And please post your bug number, just for the record.
As a user, how can I inspect this claim if the key metadata isn't
available to me?
There’s no good way to do this. Just like an iOS (-:
If you’re feeling particularly motivated you can poke around within the data protection keychain SQLite database in ~/Library/Keychains, but that’s not something we support.
Can any app that knows the kSecAttrApplicationTag use the key …
No. Access to data protection keychain items is determined by the item’s keychain access group. The ability to use a keychain access group is gated by entitlements, as discussed in Sharing Access to Keychain Items Among a Collection of Apps. These are restricted entitlements, as defined in TN3125 Inside Code Signing: Provisioning Profiles, and so must be authorised by a provisioning profile. Apple’s policies for creating profiles mean that, at most, only programs from the same team can share keychain access groups.
This assumes you have SIP enabled. Disabling SIP lets you set boot arguments that nobble a lot of this security. Don’t disable SIP on machines that you care about.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"