security / codesign in Sierra Keychain ignores access control settings and UI-prompts for permission
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Overview
In Apple's macOS Sierra, managing security credentials and permissions is often reliant on the macOS Keychain. However, there have been instances where Keychain behaves unexpectedly, ignoring access control settings and causing UI-prompts for permission that can disrupt workflows. This article dives into the intricacies of these issues, providing both technical analyses and practical examples.
Keychain Basics
Keychain is macOS's password management system, designed to store passwords for applications, websites, and various system services securely. Keychain is an essential component of macOS, providing a central repository that third-party applications and system services use to store their credentials.
Access Control
Keychain access control settings are a way to define which applications or scripts can access sensitive items stored in the Keychain. These configurations can specify whether an application should prompt the user before accessing a Keychain item or not. Despite these settings, Sierra exhibits some friction in enforcing these rules.
Ignoring Access Control Settings
The Issue
In some cases, macOS Sierra seems to ignore pre-set access control settings for items in the Keychain. This issue typically manifests when an app or script attempts to access a Keychain item but does not respect the specified control settings, causing unanticipated access prompt dialogs to appear.
For example, a script designed to run unattended (e.g., a backup script that requires access to a saved network password) could provoke a prompt dialog, interrupting automated processes.
Technical Exploration
Keychain items have an access control list (ACL) which should define which applications are trusted to access them without prompting. The ACL is associated with each Keychain item and is configured using the Security
framework in Objective-C or Swift. However, certain conditions or application states could lead to these settings being ignored:
- Code Signing Issues: If an app is not properly code-signed, the system may treat it as untrusted, resulting in prompts.
- Keychain Corruption: Sometimes, Keychain corruption can lead to unpredictable behavior.
- OS Bugs: Sierra contained some known bugs that could lead to inconsistency in access control behavior.
UI-Prompts for Permission
Frequent Prompts
The most common symptom of the issue is the persistent appearance of authentication requests. Users report seeing more frequent prompts to access passwords or certificates even when these configurations should allow automatic access.
Mitigation Strategies
- Ensuring Proper Configuration: Double-check ACL settings for Keychain items using Keychain Access utility or programmatically verifying settings via code.
- Re-adding Applications: Removing and re-adding an application to the access list can sometimes resolve unexpected prompts.
- Repairing Keychains: Using the Keychain First Aid (pre-Catalina) or simply resetting Keychain can resolve underlying inconsistencies.
- Code Signing Applications: Developers need to ensure their applications are accurately signed with valid developer certificates and entitlements.
Practical Example
Below is a code snippet using Swift to check and modify access control settings for a Keychain item:
- Future Considerations: With the characteristics of macOS Sierra's Keychain in mind, future macOS versions aim to improve security and reliability.
- Security Best Practices: Developers should routinely validate their application's Keychain access methodologies and keep abreast of changes in macOS security practices.
- User Experience Improvements: Understanding Keychain's inner workings can inform UI/UX improvements, reducing unnecessary friction for the end user.

