The system keychain is stored in /Library/Keychains/System.keychain
and the key to unlock it is stored in /var/db/SystemKey
(its default file permissions are readable by root only). The location of these files is referenced in the security-checksystem script (from the security_systemkeychain source). It is even possible to test to automatic locking/unlocking of the system keychain by using
systemkeychain -vt
The keychain security framework allows non-privileged programs to make requests for information provided they are in the ACL stored within the keychain entry. Obviously if a user has root they on a system they can directly access both the file storing the system keychain and the key to unlock it, thus they do not have make requests via the security framework and are not beholden to the ACLs stored within the keychain itself.
(I didn't actually answer the original questions so let's give this another go)
How are the keys architected such that any administrative user can unlock the System Keychain?
The libsecurity keychain framework allows regular processes to interact with the system keychain in an authenticated manner using Apple's XPC interprocess communication framework (IPC).
Program A sends a request to access the system keychain information using IPC. A check is made that the requesting user is already in the wheel group and also knows the password of a user in the wheel group. Once authorization is confirmed, the privileged kcproxy
daemon can be used to access material in /var/db/SystemKey
, unlock the system keychain and return the requested information.
Are there cryptographic restrictions that limit what an administrative user can do with information in the System Keychain in any way?
No - an administrative user is allowed to access/change anything in the system keychain. Even if they couldn't, they could copy the underlying files to another machine on which they have complete control and just unlock/access it there.
Given an unencrypted system backup without /Users, how would you gain access to the keys in the System Keychain?
If the backup contained copies of /Library/Keychains/System.keychain
and /var/db/SystemKey
then I would copy them to their respective locations on a new OS X system and use systemkeychain
to make the later unlock the former and dump the keychain database using security dump-keychain
.
I'm not sure how to prevent the creation of the credentials in the first place, but you can remove items from the Keychain using the security command, which is easily scriptable.
The command you want is security delete-internet-password -s server
, where server
is the hostname or address of the proxy server without the protocol (i.e. 192.168.0.1
, not https://192.168.0.1
). Alternatively you can use -l label
to match the name of the keychain item, or various other search parameters, which you can find detailed on the man page.
You can have this command run at logout for each user by saving it as an executable script in a location readable by all users (make sure the file is executable for all users as well). Then run sudo defaults write com.apple.loginwindow LogoutHook /path/to/script
.
Best Answer
Yes, you can modify your command line to look like this when adding the password:
This will ensure that no application is trusted to access the data without warning.