macOS 27.0.1: diagnosing SecItemCopyMatching errSecAuthFailed (-25293)

On macOS 27.0.1, SecItemCopyMatching returns -25293 (errSecAuthFailed) when a native app reads an existing login keychain item. We have verified that the app signature matches and that the user has added the app to the list of allowed applications. This occurs with user interaction disabled, and execution stops before connecting to the mail server.

Is there an officially recommended diagnostic method to distinguish whether the cause is app authorization, the execution session, or the internal state of the keychain, without reading secret information, changing permissions, or unlocking the keychain?

There isn't a single public API that tells you which authorization check caused -25293. Apple defines errSecAuthFailed broadly as an authorization and/or authentication failure, so the code alone can't distinguish a bad ACL, an authentication requirement, or keychain state.

Without changing access or reading the secret, I'd first record the exact query's nonsecret fields (class, service, account, access group, synchronizable and data-protection-keychain flags) and the returned OSStatus. Then compare the item's access group with the signed app's keychain entitlements, and confirm the query is targeting the same keychain type that contains the item. On macOS the legacy file-based keychain and the data-protection keychain behave differently; Apple's TN3137 explains how to tell which API path you're using.

If the query and entitlements line up, capture a minimal reproduction and a sysdiagnose while the failure is happening for Apple. A user-visible Keychain Access prompt or a manual unlock may change the state you're trying to diagnose, so I wouldn't use that as the first test if the goal is to observe the failure unchanged.

References: Security Framework result codes, TN3137: On Mac keychain APIs and implementations, keychain access groups.

Thank you for explaining that errSecAuthFailed alone does not identify which authorization check failed. Here is some additional evidence.

On macOS 27.0.1, the native app’s recorded failure on October 22, 2026 was:

  • SecKeychainSetUserInteractionAllowed(false): success.
  • SecKeychainOpen: success.
  • SecItemCopyMatching: -25293.
  • No mail-server connection was attempted.

The query is equivalent to:

[
    kSecMatchSearchList: [loginKeychainReference],
    kSecClass: kSecClassGenericPassword,
    kSecAttrService: "<service>",
    kSecAttrAccount: "<account>",
    kSecReturnData: true,
    kSecMatchLimit: kSecMatchLimitOne,
    kSecUseAuthenticationUI: kSecUseAuthenticationUIFail
]

It does not specify kSecAttrAccessGroup, kSecAttrSynchronizable, or kSecUseDataProtectionKeychain.

On October 25, the deployed app passed strict signature verification, and its executable hash and CDHash matched the recorded build. It is ad-hoc signed with hardened runtime, has no TeamIdentifier, and signature inspection returned no entitlements dictionary.

Keychain Access shows the target item in the login keychain. “Confirm before allowing access” is selected, and the allowed-app list contains security and an app with the expected name. We have not verified the stored trusted-app code requirement against the deployed binary.

Also on October 25, a separate, manually launched Python status-only diagnostic returned success from SecKeychainGetStatus, with flags 7 (unlocked, readable, writable). This establishes only the keychain-level status in that process at that time—not the native app’s item access or the keychain state during the earlier failure. No new credential-access test has been performed.

An earlier Python credential-access test succeeded after a one-time authentication UI approval. That used a different caller and the default keychain search scope. The native app forbids interaction, so this is not a controlled comparison.

Is there a supported public diagnostic path to distinguish an item-specific trusted-application mismatch from execution-session or interaction-policy requirements, without retrieving password data, weakening or rewriting the ACL, or unlocking the keychain?

We understand that SecTrustedApplicationCopyData is not a complete stored code-requirement representation and do not want to rely on private APIs or treat current signature validity as proof of an ACL match. The existing binary has no authentication-only mode; after successful retrieval it proceeds to mail access, so simply rerunning it would not be a bounded diagnostic.

Who created this keychain item? Specifically:

  • Are you trying to read back a keychain item that you previously created?
  • Or are you trying to read a keychain item created by some other app?

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"