Security

RSS for tag

Secure the data your app manages and control access to your app using the Security framework.

Posts under Security tag

201 Posts

Post

Replies

Boosts

Views

Activity

SecItem: Fundamentals
I regularly help developers with keychain problems, both here on DevForums and for my Day Job™ in DTS. Many of these problems are caused by a fundamental misunderstanding of how the keychain works. This post is my attempt to explain that. I wrote it primarily so that Future Quinn™ can direct folks here rather than explain everything from scratch (-: If you have questions or comments about any of this, put them in a new thread and apply the Security tag so that I see it. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" SecItem: Fundamentals or How I Learned to Stop Worrying and Love the SecItem API The SecItem API seems very simple. After all, it only has four function calls, how hard can it be? In reality, things are not that easy. Various factors contribute to making this API much trickier than it might seem at first glance. This post explains the fundamental underpinnings of the keychain. For information about specific issues, see its companion post, SecItem: Pitfalls and Best Practices. Keychain Documentation Your basic starting point should be Keychain Items. If your code runs on the Mac, also read TN3137 On Mac keychain APIs and implementations. Read the doc comments in <Security/SecItem.h>. In many cases those doc comments contain critical tidbits. When you read keychain documentation [1] and doc comments, keep in mind that statements specific to iOS typically apply to iPadOS, tvOS, and watchOS as well (r. 102786959). Also, they typically apply to macOS when you target the data protection keychain. Conversely, statements specific to macOS may not apply when you target the data protection keychain. [1] Except TN3137, which is very clear about this (-: Caveat Mac Developer macOS supports two different keychain implementations: the original file-based keychain and the iOS-style data protection keychain. IMPORTANT If you’re able to use the data protection keychain, do so. It’ll make your life easier. See the Careful With that Shim, Mac Developer section of SecItem: Pitfalls and Best Practices for more about this. TN3137 On Mac keychain APIs and implementations explains this distinction. It also says: The file-based keychain is on the road to deprecation. This is talking about the implementation, not any specific API. The SecItem API can’t be deprecated because it works with both the data protection keychain and the file-based keychain. However, Apple has deprecated many APIs that are specific to the file-based keychain, for example, SecKeychainCreate. TN3137 also notes that some programs, like launchd daemons, can’t use the file-based keychain. If you’re working on such a program then you don’t have to worry about the deprecation of these file-based keychain APIs. You’re already stuck with the file-based keychain implementation, so using a deprecated file-based keychain API doesn’t make things worse. The Four Freedoms^H^H^H^H^H^H^H^H Functions The SecItem API contains just four functions: SecItemAdd(_:_:) SecItemCopyMatching(_:_:) SecItemUpdate(_:_:) SecItemDelete(_:) These directly map to standard SQL database operations: SecItemAdd(_:_:) maps to INSERT. SecItemCopyMatching(_:_:) maps to SELECT. SecItemUpdate(_:_:) maps to UPDATE. SecItemDelete(_:) maps to DELETE. You can think of each keychain item class (generic password, certificate, and so on) as a separate SQL table within the database. The rows of that table are the individual keychain items for that class and the columns are the attributes of those items. Note Except for the digital identity class, kSecClassIdentity, where the values are split across the certificate and key tables. See Digital Identities Aren’t Real in SecItem: Pitfalls and Best Practices. This is not an accident. The data protection keychain is actually implemented as an SQLite database. If you’re curious about its structure, examine it on the Mac by pointing your favourite SQLite inspection tool — for example, the sqlite3 command-line tool — at the keychain database in ~/Library/Keychains/UUU/keychain-2.db, where UUU is a UUID. WARNING Do not depend on the location and structure of this file. These have changed in the past and are likely to change again in the future. If you embed knowledge of them into a shipping product, it’s likely that your product will have binary compatibility problems at some point in the future. The only reason I’m mentioning them here is because I find it helpful to poke around in the file to get a better understanding of how the API works. For information about which attributes are supported by each keychain item class — that is, what columns are in each table — see the Note box at the top of Item Attribute Keys and Values. Alternatively, look at the Attribute Key Constants doc comment in <Security/SecItem.h>. Uniqueness A critical part of the keychain model is uniqueness. How does the keychain determine if item A is the same as item B? It turns out that this is class dependent. For each keychain item class there is a set of attributes that form the uniqueness constraint for items of that class. That is, if you try to add item A where all of its attributes are the same as item B, the add fails with errSecDuplicateItem. For more information, see the errSecDuplicateItem page. It has lists of attributes that make up this uniqueness constraint, one for each class. These uniqueness constraints are a major source of confusion, as discussed in the Queries and the Uniqueness Constraints section of SecItem: Pitfalls and Best Practices. Parameter Blocks Understanding The SecItem API is a classic ‘parameter block’ API. All of its inputs are dictionaries, and you have to know which properties to set in each dictionary to achieve your desired result. Likewise for when you read properties in output dictionaries. There are five different property groups: The item class property, kSecClass, determines the class of item you’re operating on: kSecClassGenericPassword, kSecClassCertificate, and so on. The item attribute properties, like kSecAttrAccessGroup, map directly to keychain item attributes. The search properties, like kSecMatchLimit, control how the system runs a query. The return type properties, like kSecReturnAttributes, determine what values the query returns. The value type properties, like kSecValueRef perform multiple duties, as explained below. There are other properties that perform a variety of specific functions. For example, kSecUseDataProtectionKeychain tells macOS to use the data protection keychain instead of the file-based keychain. These properties are hard to describe in general; for the details, see the documentation for each such property. Inputs Each of the four SecItem functions take dictionary input parameters of the same type, CFDictionary, but these dictionaries are not the same. Different dictionaries support different property groups: The first parameter of SecItemAdd(_:_:) is an add dictionary. It supports all property groups except the search properties. The first parameter of SecItemCopyMatching(_:_:) is a query and return dictionary. It supports all property groups. The first parameter of SecItemUpdate(_:_:) is a pure query dictionary. It supports all property groups except the return type properties. Likewise for the only parameter of SecItemDelete(_:). The second parameter of SecItemUpdate(_:_:) is an update dictionary. It supports the item attribute and value type property groups. Outputs Two of the SecItem functions, SecItemAdd(_:_:) and SecItemCopyMatching(_:_:), return values. These output parameters are of type CFTypeRef because the type of value you get back depends on the return type properties you supply in the input dictionary: If you supply a single return type property, except kSecReturnAttributes, you get back a value appropriate for that return type. If you supply multiple return type properties or kSecReturnAttributes, you get back a dictionary. This supports the item attribute and value type property groups. To get a non-attribute value from this dictionary, use the value type property that corresponds to its return type property. For example, if you set kSecReturnPersistentRef in the input dictionary, use kSecValuePersistentRef to get the persistent reference from the output dictionary. In the single item case, the type of value you get back depends on the return type property and the keychain item class: For kSecReturnData you get back the keychain item’s data. This makes most sense for password items, where the data holds the password. It also works for certificate items, where you get back the DER-encoded certificate. Using this for key items is kinda sketchy. If you want to export a key, called SecKeyCopyExternalRepresentation. Using this for digital identity items is nonsensical. For kSecReturnRef you get back an object reference. This only works for keychain item classes that have an object representation, namely certificates, keys, and digital identities. You get back a SecCertificate, a SecKey, or a SecIdentity, respectively. For kSecReturnPersistentRef you get back a data value that holds the persistent reference. Value Type Subtleties There are three properties in the value type property group: kSecValueData kSecValueRef kSecValuePersistentRef Their semantics vary based on the dictionary type. For kSecValueData: In an add dictionary, this is the value of the item to add. For example, when adding a generic password item (kSecClassGenericPassword), the value of this key is a Data value containing the password. This is not supported in a query dictionary. In an update dictionary, this is the new value for the item. For kSecValueRef: In add and query dictionaries, the system infers the class property and attribute properties from the supplied object. For example, if you supply a certificate object (SecCertificate, created using SecCertificateCreateWithData), the system will infer a kSecClass value of kSecClassCertificate and various attribute values, like kSecAttrSerialNumber, from that certificate object. This is not supported in an update dictionary. For kSecValuePersistentRef: For query dictionaries, this uniquely identifies the item to operate on. This is not supported in add and update dictionaries. Revision History 2025-05-28 Expanded the Caveat Mac Developer section to cover some subtleties associated with the deprecation of the file-based keychain. 2023-09-12 Fixed various bugs in the revision history. Added a paragraph explaining how to determine which attributes are supported by each keychain item class. 2023-02-22 Made minor editorial changes. 2023-01-28 First posted.
0
0
5.1k
May ’25
Authentication-UI refusal for a file-based certificate query on macOS
The guidance in https://developer.apple.com/forums/thread/739774 explains the context search list, the kSecMatchSearchList override and continued use of deprecated file-based APIs where that keychain model is required. For a SecItemCopyMatching query using kSecClassCertificate and an explicitly supplied file-based test keychain, what is the supported way to refuse authentication UI rather than allow a prompt? I am considering macOS 26.6.1 with the macOS 27.0 SDK; please clarify applicability to that combination and any relevant application-context restrictions. In particular, which refusal mechanism applies to the file-based path given the deprecation of earlier authentication-UI options? If access would require keychain unlock or authentication UI, is an error guaranteed, or can the query omit items and return success? A public documentation reference and any version limitations would be helpful. This is a contract question for a prospective test; I have not run it or reproduced a problem.
0
0
90
19h
Launching a signed AppKit app from a Python supervisor while preserving instance ownership and bounded cleanup
I'm looking for a supported way to launch a signed AppKit application for user interaction from a local Python supervisor, while retaining reliable supervision of the exact launched instance. Environment Apple M3 MacBook Air, macOS 14.5, build 23F79. arm64 app built with Command Line Tools clang and the macOS 14.5 SDK, targeting macOS 14.0. AppKit/Foundation with embedded CPython 3.12. Apple Development signing, hardened runtime and strict signature checks passed. Current launch and activation sequence The supervisor directly launches the bundle executable with Popen: a fixed argument, empty environment, new process session, disconnected stdin, and an anonymous stdout pipe carrying fixed, nonsecret startup markers. There is no LaunchServices foreground handoff. On its main thread, the app initializes NSApplication, confirms Regular activation policy, calls finishLaunching and activateIgnoringOtherApps:YES, then waits for isActive. Event-retrieval waits are capped at 20 ms; event dispatch itself may take longer. Existing timeout supervision remains active. Our activation guard is two seconds from the readiness routine's start, subject to the remaining native timer. A separate overall test budget is 300 seconds from operator readiness, before preflight. Observed result The latest test exited with code 1 after approximately 2.57 seconds. The validated markers were: absence.begin → absence.absent → fields.begin → ui.begin → app.shared.begin → app.shared.ready → policy.before → policy.already_regular → policy.postcondition → launch.finish.begin → launch.finish.ready → activation.requested → activation.wait.begin → stop.activation.timeoutThe final recorded state was: main=1 app=1 active=0 policy=0 window=0 visible=-1 key=-1The app stopped before constructing the dialog. Adding event processing did not resolve activation. We have not established why activation failed or which events were delivered. The two-second deadline is our guard, not an asserted macOS activation guarantee. Questions What supported launch and activation approach should this supervisor use for a foreground, interactive AppKit app? Can this direct-executable design be corrected narrowly, or should launching move to LaunchServices with a different communication and supervision arrangement? With the recommended approach, how should the supervisor identify the exact launched instance, receive startup status, enforce bounded termination, and establish that the process has exited before cleanup? We reviewed a simple foreground-launch substitution, but it did not preserve our existing marker pipe and authoritative exit/reap evidence. That is a limitation of our proposed adaptation, not a claim that Apple's APIs cannot support these outcomes. The essential requirements are exact-instance identification, nonsecret status reporting, bounded termination and verified cleanup. An anonymous pipe and direct-child waiting are current implementation choices, not requirements in themselves.
6
0
134
1d
Screen Recording permission popup not shown & app not added to app list in Screen Recording settings
Requesting the Screen Recording permission seems broken on macOS 27.3 beta 2. I'd love to know whether this change is intentional or whether we can expect a fix before the stable macOS 27.3 release. Feedback report: FB25646769 Behavior until macOS 27.2 When an app calls CGRequestScreenCaptureAccess(), macOS shows the following popup: Additionally, the app is added to the app list in the “Screen & System Audio Recording” panel in the System Settings. It is toggled off by default and the user can easily toggle it on. Behavior on macOS 27.3 beta 2 When an app calls CGRequestScreenCaptureAccess(), no popup appears and the app is not added to the app list in the “Screen & System Audio Recording” panel in the System Settings. The user cannot easily grant the permission. What the user has to do to grant the permission on macOS 27.3 beta 2 It is not intuitive for the user to figure out how to grant the Screen Recording permission. Without any guidance, the user needs to: Click the little plus icon below the app list in the "Screen & System Audio Recording” panel in the System Settings Because the System Settings panel shows two app lists, the user needs to click the plus icon below the correct app list ("Screen & System Audio Recording", not "System Audio Recording Only") Find the app in the file picker and add it This is cumbersome and unintuitive. There's no explanation of what to do. The average user will be confused and will struggle to complete these tasks. Reproduction steps Install an app that requests the Screen Recording permission (e.g., Cap) Get to the onboarding step that requests the Screen Recording permission Observe that the permission request popup is not shown and that the app is not added to the System Settings panel
3
1
141
2d
Is JIT execution possible for ordinary third-party iOS apps?
I'm researching whether a normally signed third-party iOS application can use Just-In-Time (JIT) compilation on a stock, unjailbroken iPhone. My project, Kairavox, aims to run a genuine, unmodified iPadOS installation as a guest inside a native iOS application. JIT compilation is central to our intended execution architecture: we want to translate and execute guest AArch64 instructions through dynamically generated native code. We intend to test through personal development signing and sideloading using AltStore or SideStore. App Store distribution is not a requirement. I've found Apple's documentation for: Allow Execution of Just-In-Time (JIT) Compiled Code Entitlement Porting Just-In-Time Compilers to Apple Silicon Alternative Browser Engines in the European Union However, the first two appear to concern the macOS Hardened Runtime context. Apple's alternative browser engine provisions also describe a specifically authorized exception, which does not describe our application. I'd appreciate clarification on what is supported for an ordinary third-party iOS app: Is there a documented iOS API or entitlement that allows a normally signed third-party app to allocate writable memory, generate machine code, and execute that code at runtime? Does iOS support MAP_JIT for ordinary third-party applications, or is it restricted to other Apple platforms or specially authorized applications? Is com.apple.security.cs.allow-jit exclusively a macOS Hardened Runtime entitlement, or does it have any application on iOS? Can an app using free Personal Team development signing execute JIT-generated code? Does paid Apple Developer Program membership change this? Do development, ad hoc, or other signing arrangements differ in their JIT permissions? Is there a documented process for an independent developer to request the necessary capability? Does installing an app through AltStore or SideStore change its OS-granted executable-memory permissions, or does it retain the permissions associated with its signed build? Are there any documented restrictions on using JIT-generated native code for CPU emulation or virtualization workloads? I understand that Apple's EU alternative-browser-engine authorization is a narrow exception for eligible browser applications. I'm not assuming it applies to Kairavox. The main question is whether an independent developer can build and test a JIT-based application on a stock iPhone using an officially supported signing and permission model. Thank you.
1
0
50
2d
Sandbox restriction blocks Keychain access during Live Activity rendering: supported design for encrypted updates?
Hi, I'm building a Live Activity prototype using fictitious data. I want incoming updates to stay encrypted until they reach my iPhone, without putting the decryption key in ActivityAttributes, ContentState, or archived views. My goal is timely updates without an alert for each change. I'm using Xcode 27.2 and the iPhoneOS 27.2 SDK. My iPhone was running iOS 27.2.1 when I last checked. I haven't recorded its exact OS build or the OS version and build for every earlier test. My app and WidgetKit extension have the same shared Keychain access group in their signed entitlements. My app creates a 32-byte test key as a generic password with kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly, with synchronization disabled. The extension only reads the key. A failed lookup never causes the key to be replaced or deleted. When I try to read the key while rendering the Live Activity, the first, metadata-only SecItemCopyMatching call returns errSecNotAvailable (-25291). It fails before I request any secret bytes. I reproduced this after stopping and restarting the activity with my iPhone unlocked. I get the same result with a non-interactive LAContext and with kSecUseAuthenticationUIFail without a supplied context. I used the latter only for comparison, since it is deprecated. My query specifies the class, fixed service and account, and shared access group. It also sets kSecUseDataProtectionKeychain. For the metadata lookup, I use kSecAttrSynchronizableAny, kSecReturnAttributes: true, and kSecMatchLimitAll, without requesting data or item references. I only request the key bytes after finding exactly one item and validating its policy, so that second step is never reached here. For comparison, I added a regular widget to the same signed WidgetKit extension. Its timeline provider successfully validates the metadata using the same read-only query and client, while the Live Activity still returns errSecNotAvailable. I captured these results separately; I haven't established whether they ran simultaneously or in different processes. I have only confirmed metadata access in the regular widget, not access to the key bytes. I also tried decrypting in my foreground app and then passing the fictitious summary to ActivityKit through a local update. That renders correctly on my iPhone. It doesn't test remote delivery or background decryption, or fix the Keychain failure during rendering. I repeated the test with debug messages enabled in Console. The Live Activity in my diagnostic build still shows the same Keychain failure. The capture from the extension now includes the connection error, not just the generic securityd message: activating connection: ... name=com.apple.securityd failed to do a bootstrap look-up: xpc_error=[159: Unknown error: 159] invalidated after a failed init got event: Connection invalid Failed to talk to securityd after 4 attempts. error:[-25291] Error Domain=com.apple.security.xpc Code=3 Connection invalid - Connection init failed at lookup with error 159 - Sandbox restrictionThis excerpt omits connection addresses and account fields. The same -25291 error and sandbox-restriction reason appear five times in this capture. It establishes the reported reason for the connection failure in this test; I haven't established whether this is an intended restriction, an OS issue, or a configuration issue. I also don't infer the actual retry count from the generic message. I'd appreciate guidance on these questions: Given the explicit sandbox-restriction error for com.apple.securityd, is non-interactive Keychain access intentionally unavailable during Live Activity rendering, or should I investigate an OS or configuration issue? Displaying live data with Live Activities documents a separate sandbox and restrictions on network and location access, but I haven't found its Keychain access contract. How should I interpret the different result from my regular widget's timeline provider? For encrypted content-state updates, is there a supported execution point where my app can authenticate and decrypt each update before handing a local render value to ActivityKit? I found the documented app wake-up for push-to-start, but not an equivalent for ordinary updates. If neither approach is supported, how can I deliver timely, alert-free encrypted Live Activity updates while keeping the key solely in Keychain and out of archived state and views? How does ActivityKit protect static ActivityAttributes at rest? Can those attributes be included in backups or replicated to an Apple Watch or Mac, separately from rendered views? Does any of that data pass through Apple servers, and is there a public API to opt out of replication? Would a per-activity session key in locally created static attributes be a supported design, or does Apple advise against storing secrets there? I haven't implemented this alternative. I would keep the long-term pairing key in Keychain, exclude the session key from every APNs payload, and start the activity locally rather than through push-to-start. I'd like to understand the storage and replication guarantees before considering it further. I'm looking for a supported design without weakening Keychain protection, allowing authentication UI during rendering, or suppressing an ordinary notification to bypass its requirements. I can prepare a minimal reproducer with fictitious data and no tokens, real identifiers, or conversation content. Thanks for your help.
3
0
120
3d
macOS APFS: com.apple.macl and UF_TRACKED appear after creating a hard link — safe file replacement and rollback?
I'm investigating an unexpected metadata change during a controlled file deployment on macOS. Environment and observed state Two regular configuration files are used by a local service. Before replacement, the first file had: SHA-256: verified. File flags: 0. Extended attributes: none. Hard-link count: 1. Owner/group: 501/20. Permissions: 0644. ACL: empty. A backup procedure created a hard link to preserve the original inode before replacing the active pathname with an independently created file. Immediately after creating and verifying the hard link, the original file was observed with: The same SHA-256 and inode. Flags: 64 (UF_TRACKED). Extended attribute: com.apple.macl. Hard-link count: 2. No file content was replaced. The procedure stopped because the metadata no longer matched the original baseline. Additional observations Other backup methods also encountered unexpected metadata changes during destination creation. Tests using renamex_np with RENAME_SWAP successfully exchanged and restored artificial files with flags 0 and empty extended attributes. A test with artificial files already containing com.apple.provenance also succeeded. We could not reproduce the specific UF_TRACKED + com.apple.macl + two-hard-link state in an isolated fixture using ordinary documented operations. The operational original and its second hard link currently share the same inode. No attempt has been made to remove the protected attribute or change its flags. Questions for Apple filesystem/security specialists Under what documented circumstances can creating a hard link or related Finder/TCC document-tracking behavior cause UF_TRACKED and com.apple.macl to appear on an existing file? Are these metadata changes expected for a file accessed through a user-authorized Documents location? What supported mechanism can preserve the current original inode and provide a verifiable rollback when replacing its active pathname? Is renamex_np(..., RENAME_SWAP) appropriate for this situation, and what special considerations apply to the existing second hard link and protected extended attributes? What verification criteria would you recommend before permitting a production replacement? I am looking for a documented, reversible procedure that preserves macOS security protections. I do not want to disable SIP, forcibly remove com.apple.macl, or bypass TCC. I can provide sanitized metadata comparisons and a minimal reproduction if needed.
1
0
153
3d
Client identity selection and chain presentation when an intermediate CA in the identity’s chain is revoked
We deploy client-authentication identities (certificate + private key) to iOS/iPadOS devices for mutual TLS and Wi-Fi EAP-TLS. The identities are installed via MDM configuration profiles and used from Safari, from our app via URLSession client certificate challenges, and by the system for EAP-TLS. The intermediate CA certificate in these identities’ chain (issued by a publicly trusted root) will be revoked. A replacement intermediate certificate with the same subject and public key, but a different serial number, is valid, and the end-entity certificates will not be reissued. The private keys are not exportable. If the revoked intermediate is known to the device through Apple’s distributed revocation data, or only through the root CA’s CRL, does iOS/iPadOS evaluate this when offering the identity for selection in Safari, when handling a URLSession client certificate challenge, or when using it for EAP-TLS? Could the identity be hidden, flagged, or fail to be presented? If we install the replacement intermediate on the device (e.g. via a certificate payload in a configuration profile) and remove the original, will the system build and present the chain through the replacement certificate? For URLSession, if our app supplies the chain explicitly in URLCredential(identity:certificates:persistence:), is any revocation evaluation performed on that chain on the client side? The revocation is scheduled for 2026-11-20T09:00:00Z. Our users rely on this system for patient care in medical institutions, so any guidance before then would be greatly appreciated.
2
5
492
3d
macOS 27/APFS: Supported ACL Absence Verification When acl_get_fd_np Returns ENOENT
Subject: Supported fail-closed ACL absence verification on macOS 27.0.1 / APFS Environment: macOS 27.0.1, build 26A434; APFS; installed macOS 27.0 SDK. We need a supported, documented way to determine whether an existing filesystem object has no effective ACL entries, while rejecting genuine retrieval failures and unsupported or unavailable ACL evidence. We are seeking clarification of the public interface contract, not alleging an Apple defect. For existing directory and regular-file fixtures, pathname metadata and descriptor metadata identify the same object. Errno is cleared immediately before each native call and captured immediately afterward. ACL retrieval uses ACL_TYPE_EXTENDED: acl_get_file(path, ACL_TYPE_EXTENDED) acl_get_fd_np(fd, ACL_TYPE_EXTENDED) On fresh objects, both return NULL with ENOENT. Explicit one-entry fixture ACLs are retrieved successfully. Explicit zero-entry fixture ACLs can also yield NULL/ENOENT, while attribute queries return a serialized zero-entry ACL. The attribute queries use getattrlist() and descriptor-bound fgetattrlist(), requesting ATTR_CMN_RETURNED_ATTRS | ATTR_CMN_EXTENDED_SECURITY, with FSOPT_NOFOLLOW | FSOPT_REPORT_FULLSIZE and WITHOUT FSOPT_PACK_INVAL_ATTRS. Buffer lengths, variable-reference bounds and returned-attribute validity are checked. For the existing directories of interest, both calls succeed but omit the ATTR_CMN_EXTENDED_SECURITY returned bit. Explicit populated and zero-entry fixture records do set the bit. APFS reports valid VOL_CAP_INT_EXTENDED_SECURITY support; we do not assume that volume capability proves per-object ACL availability. On macOS 27.0.1, build 26A434, using APFS, which supported interface and documented conditions allow software to distinguish an absent ACL from unavailable or unsupported ACL evidence when descriptor-bound attribute queries succeed but omit ATTR_CMN_EXTENDED_SECURITY and native ACL getters return ENOENT for an existing object? Please clarify: Whether ENOENT has a supported ACL-absence interpretation, and under exactly which checked conditions. Whether an omitted extended-security attribute can establish ACL absence, rather than unavailable or unsupported evidence. How explicit zero-entry ACLs differ from absent ACL records through supported interfaces. How KAUTH_FILESEC_NOACL should be interpreted through supported APIs. How genuine retrieval failures, including permission, I/O, allocation and unsupported-operation errors, must remain distinguishable. Whether a supported descriptor-bound verification method exists that preserves fail-closed security checks and object identity binding; please identify its guarantees and limitations regarding pathname/ancestor changes and later operations. Whether relevant behavior is specific to this macOS/APFS version. Please identify the applicable public documentation or supported verification sequence. We do not want to modify permissions, synthesize ACLs on target objects, treat invalid-attribute defaults as real evidence, or accept ambiguous omission/ENOENT as success. Existing ownership, mode and confinement checks must remain separate mandatory checks. If no public API can make this distinction reliably, please state that limitation.
15
0
582
3d
CKKS zone deletions return success but stale 2019 key hierarchy persists; "Delete iCloud Data" not offered (FB25584356)
I filed FB25584356 for this and would appreciate any pointers. Setup: Mac mini on macOS 27.2.1 and an iPhone on iOS 27.2, same Apple Account, HSA2, Advanced Data Protection off. Octagon is healthy (otctl status = Ready, both devices trusted). Symptoms: AirDrop to my own iPhone fails when I pick the device (rapportd: "PairVerify server M2 failed: copy identity"), iPhone Mirroring ends with noCompatiblePhone, and various clients log CKErrorDomain 111 / 5009 "Keychain Sync Incomplete". What I see in CKKS: seven zones (AutoUnlock, LimitedPeersAllowed, Home, Manatee, ApplePay, Health, Engram) still hold a key hierarchy from August 2019. The only TLKShare was issued by a device that left the account years ago, so neither current device can unwrap the TLK ("No trusted TLKShares", CKKSErrorDomain 35). secd then does what I would expect: tlkmissing → "No other devices claim to have the TLK. Resetting zone..." → CKKSDeleteCKZoneOperation → local reset → zones recreated. The delete appears to succeed. With debug logging, cloudd shows status:200 and "RecordZone ... was successfully deleted from the server" for each zone. The next fetch returns the same 2019 records with an identical server change token. Over about 11 hours: 124 reset cycles, 869 zone deletions reported as successful, 182 consecutive AutoUnlock fetches with the same change token. When not throttled it runs roughly every 5 seconds; CloudKit eventually answers "Service Unavailable" (CKError 6/2009) with a ~59 minute retry-after, and all 23 zones are unusable in the meantime. ckksctl -v AutoUnlock reset-cloudkit behaves the same way. Reset path: Support article 120862 describes "Don't know passcode?" → "Forgot all passcodes?" → "More Options" → "Delete iCloud Data". With the Mac signed in but not yet trusted, "Don't know passcode?" only offered Cancel / Try Again Later, in the sign-in flow and in both System Settings follow-ups. After three wrong passcodes the alert had a single "Try Again Later" button, although cdpd logged "Creating recovery option: Reset". Questions: Is a client-side zone delete expected to be a no-op for these zones while the server reports success? Is there a supported way to reach performCKServerUnreadableDataRemoval / "Delete iCloud Data" when another trusted device exists? I am fine with losing the end-to-end encrypted data in those zones. Logs and a sysdiagnose are attached to the Feedback.
0
0
135
6d
Sandboxed app can't delete AppleDouble (._) files of quarantined files on exFAT, even with user-selected access.
My Mac App Store utility removes Mac metadata files (._* AppleDouble files and .DS_Store) from external drives formatted exFAT or FAT32. The app is sandboxed with com.apple.security.files.user-selected.read-write and com.apple.security.files.bookmarks.app-scope. The user grants access to the volume through NSOpenPanel. Deleting a ._ file works, except when its companion file carries com.apple.quarantine (for example, a file downloaded with Safari and copied to the drive with Finder). Then: let partner = volume + "/Nirvana.zip" // has com.apple.quarantine let appleDouble = volume + "/._Nirvana.zip" removexattr(partner, "com.apple.quarantine", XATTR_NOFOLLOW) // -1, errno 1 (EPERM) unlink(appleDouble) // -1, errno 1 (EPERM)The same unlink succeeds from Terminal (not sandboxed, without Full Disk Access). On exFAT the extended attributes live in the ._ file, so I assume the sandbox refuses because deleting it would remove the quarantine attribute. Tried, with no change: Full Disk Access granted to the app. Adding com.apple.security.files.user-selected.executable (verified in the built app with codesign -d --entitlements -). On a real drive (a music library), about 71% of the ._ files belong to quarantined files, so this is most of what users want removed. Is there a supported way for a sandboxed app to remove these files: an entitlement, an API, or an explicit user action? If not, can you confirm it's intended behavior, so I can explain it accurately to users? macOS 27.2, Xcode 27.2, Apple silicon. Focused sample project available (one source file). DTS case 23240704.
5
0
174
1w
Choosing a TLS server identity by client address with NWListener
I run an HTTPS server on NWListener (iOS and macOS) that serves several identities from one listener on port 443, picked per handshake in sec_protocol_options_set_challenge_block, as suggested in this thread. That works well for every handshake that carries a server name. The trouble is handshakes without one. Clients on the LAN connect by IP address, so they send no SNI (RFC 6066 keeps IP literals out of it), and they trust a self-signed certificate through a configuration profile. Internet clients and scanners that reach the public address through the router's port forward also often arrive without SNI. The two groups should get different certificates, and the only thing that tells them apart is the client's address. The listener knows it in newConnectionHandler, but the challenge block never sees it. What I tried: sec_protocol_metadata_t has accessors for the server name, ALPN, version, cipher suite and so on, but I can't find one for the connection's endpoints. Setting a challenge block on the accepted connection's own TLS options before start(): listener.newConnectionHandler = { connection in let remote = connection.endpoint if let tls = connection.parameters.defaultProtocolStack.applicationProtocols .compactMap({ $0 as? NWProtocolTLS.Options }).first { sec_protocol_options_set_challenge_block(tls.securityProtocolOptions, { _, complete in complete(identity(for: remote)) }, queue) } connection.start(queue: queue) }This block never runs. The listener's own block answers every handshake (tested on macOS 27.2). My questions: Is there a supported way to choose the server identity per connection based on its endpoints, short of terminating TLS myself? Is the challenge block supported under TLS 1.3 by now? I also see it run twice for every handshake; is that expected? When a server-side handshake fails, connection.metadata(definition: NWProtocolTLS.definition) returns nil. Is there any way to learn which server name a failed handshake asked for, so it can be logged? I filed FB25541009 with a small sample project that shows all three.
2
0
90
1w
Unexpected Core Foundation attribute types when inspecting an existing Secure Enclave-associated Keychain key on macOS
Hello Apple Developer community, I'm investigating an unexpected metadata representation returned by Apple's Security framework while inspecting an existing Secure Enclave-associated Keychain item on macOS. A read-only inspection using SecItemCopyMatching returns one matching key record with a successful status, a Secure Enclave token identifier (com.apple.setoken), and a 256-bit key size. However, direct Core Foundation type inspection reports: kSecAttrKeyType: CFNumber kSecAttrKeyClass: CFNumber kSecAttrSynchronizable: CFNumber The raw Core Foundation observations and bridged observations agree. Our current validator rejects these unexpected types and returns UNSUPPORTED_OR_INCOMPLETE_METADATA. We have deliberately stopped further key operations pending clarification. Questions: Can these CFNumber values legitimately appear in a dictionary returned by SecItemCopyMatching for Secure Enclave-associated key items on macOS? What returned value types should be expected for these three attributes, and are they dependent on the query or Keychain implementation? Is there an Apple-recommended way to normalize or validate these attributes without incorrectly accepting incompatible metadata? How should an application distinguish an existing Secure Enclave-backed key from an incomplete or unsupported Keychain record without performing a private-key operation? Are there relevant Security framework documentation references or known implementation differences we should consult? Our aim is to validate the existing record safely without regenerating, deleting, or using the private key. Thank you for your guidance.
5
0
427
1w
Can macOS restrict a signing key to one exact build of a system daemon?
Hi Apple Developer Technical Support, We have a locally signed macOS system daemon that an administrator starts manually. It needs to use a dedicated P-256 signing key in a file-based keychain. We want macOS to let only the exact approved build use that key, without a prompt. A different build signed with the same certificate should be denied. Apple’s published Security source shows that the keychain can identify some callers by their code directory hash (cdhash). Is setting a key’s partition list to that exact hash a supported way to enforce this restriction for a system daemon? If so, which macOS versions support it, and what API or Apple tool should we use to configure it? After setup, how can we verify that the intended key has the exact restriction in place, including whether any broader rule allows another process to sign with the key, export it, or change its access rules? If macOS doesn’t offer a supported way to set and verify this restriction, please confirm that limitation.
1
0
101
1w
Repeated login Keychain prompts and securityd crash after app upgrade on macOS 26.6.x
Overview We are investigating repeated "login" Keychain prompts affecting our macOS application on macOS 26.6.x. The issue appears after upgrading an existing installation. A clean uninstall/reinstall of the same version resolves it. Changing the affected Keychain item's Access Control from "Confirm before allowing access" to explicitly allowing our application/process also stops the prompts. On one affected machine, Apple Support observed a securityd crash followed by: SecKeyCreateSignature failed CSSMERR_DL_INVALID_DB_HANDLE Our code uses some legacy SecKeychain* APIs, so we are currently investigating whether this is related. Questions Were there any changes in macOS 26.6.x around securityd, Keychain ACL handling, or legacy SecKeychain* APIs that could explain this? Could an existing Keychain ACL become stale after an application upgrade, even when both versions are signed with the same Developer ID?
18
0
3.8k
2w
Secure Enclave: Supporting Signing-Only, Key-Agreement-Only, and Dual-Purpose Keys
Hello everyone, I'm trying to understand the actual limitations of the Secure Enclave (SEP) regarding cryptographic key capabilities, and more specifically how to generate and store the following key types in the keychain: Sign only: The key can only be used for digital signatures. Key agreement only: The key can only be used for key agreement operations. All operations: The key can be used for both signing and key agreement. I've noticed some apparent differences between Apple's Security framework and CryptoKit, and I'm trying to understand whether these differences reflect actual SEP limitations or simply framework-level restrictions. 1. Security framework: dual purpose keys I'm currently using SecKeyCreateRandomKey to generate Secure Enclave-backed keys. Here is the relevant code: NSDictionary *privateAttributes = @{ (__bridge id)kSecAttrIsPermanent : @YES, (__bridge id)kSecAttrAccessControl : ..., (__bridge id)kSecAttrApplicationTag : ..., // key agreement only (__bridge id)kSecAttrCanSign: @NO, (__bridge id)kSecAttrCanDerive: @YES }; NSMutableDictionary *attributes = [ @{ (__bridge id)kSecAttrKeyType : (__bridge id)kSecAttrKeyTypeECSECPrimeRandom, (__bridge id)kSecAttrTokenID : (__bridge id)kSecAttrTokenIDSecureEnclave, (__bridge id)kSecAttrKeySizeInBits : @256, (__bridge id)kSecPrivateKeyAttrs : privateAttributes } mutableCopy ]; CFErrorRef generationError = nullptr; SecKeyRef privateKey = SecKeyCreateRandomKey( (__bridge CFDictionaryRef)attributes, &generationError );However, when experimenting with these attributes, I encountered the following error: SecKeyCreateRandomKey failed: Error Domain=NSOSStatusErrorDomain Code=-50 "Failed to generate keypair" Underlying error: Error Domain=CryptoTokenKit Code=-8 "sepkey: sign requires '1' value when present"Using signing-only attributes results in the same kind of error. This makes me wonder whether the Security framework actually allows generating (and adding entries in the keyChain) only keys with both capabilities enabled. It is possible to create siging only key or key agreement only key with Security framework? 2. CryptoKit: Separate key types On the other hand, CryptoKit seems to expose two distinct Secure Enclave key types: P256.SecureEnclave.Signing.PrivateKey P256.SecureEnclave.KeyAgreement.PrivateKeyFrom the API design, it appears that CryptoKit only allows creating keys dedicated to one operation or the other. For example, a Signing.PrivateKey cannot be used for key agreement, and a KeyAgreement.PrivateKey cannot be used for signing. Is it possible to create both capabilities keys with CryptoKit framework? 3. Actual Secure Enclave limitations What are the actual cryptographic capability limitations imposed by the SEP itself? I'd particularly like to understand which restrictions originate from: The Secure Enclave hardware. Security and CryptoKit frameworks. Is there a documented way to generate and store in the keychain: A signing-only Secure Enclave key? A key-agreement-only Secure Enclave key? A Secure Enclave key supporting both operations? Thanks in advance, Idopte
1
0
89
2w
How can a macOS application establish that an open APFS file has no extended ACL?
On macOS 26.5.2 (build 25F84), which documented API and return conditions, if any, establish that a regular file on APFS has no extended access control list (ACL), using an already-open file descriptor? We tested three disposable regular files on an APFS volume reporting ACL support. For each file, we opened a read-only file descriptor and called: acl_get_fd_np(fd, ACL_TYPE_EXTENDED) fgetattrlist() requesting ATTR_CMN_RETURNED_ATTRS | ATTR_CMN_EXTENDED_SECURITY Before and after inspection, fstat() confirmed stable device, inode, mode, and change timestamp. Observed results: 1. Newly created file, no ACL explicitly assigned acl_get_fd_np() returned NULL with errno == ENOENT. fgetattrlist() succeeded but omitted ATTR_CMN_EXTENDED_SECURITY from the returned attribute mask. FSOPT_PACK_INVAL_ATTRS also left that bit clear. 2. File with an explicitly assigned empty ACL acl_get_fd_np() returned NULL with errno == ENOENT. fgetattrlist() returned the extended-security attribute with an ACL entry count of zero. 3. File with one explicit ACL entry acl_get_fd_np() returned a non-null ACL. fgetattrlist() returned the extended-security attribute with an ACL entry count of one. Apple's published XNU attribute-packing implementation appears to use the same omission branch when ACL metadata is unsupported or when the ACL pointer is null. My question: Is there a supported descriptor-based API sequence that reliably distinguishes: Genuine absence of an extended ACL Unavailable or unsupported per-file ACL metadata An ACL retrieval failure If so, which API, capability checks, return values, attribute bits, or error conditions should a caller rely on? Are there relevant APFS or macOS version limitations? If the public API cannot establish ACL absence unambiguously in this situation, confirmation of that limitation would also be helpful. Thank you for your guidance.
2
0
108
2w
Using Cryptokit.SecureEnclave API from a Launch Daemon
We are interested in using a hardware-bound key in a launch daemon. In a previous post, Quinn explicitly told me this is not possible to use an SE keypair outside of the system context and my reading of the Apple documentation also supports that. That said, we have gotten the following key-creation and persistence flow to work, so we have some questions as to how this fits in with the above. (1) In a launch daemon (running thus as root), we do: let key = SecureEnclave.P256.Signing.PrivateKey() (2) We then use key.dataRepresentation to store a reference to the key in the system keychain as a kSecClassGenericPassword. (3) When we want to use the key, we fetch the data representation from system keychain and we "rehydrate" the key using: SecureEnclave.P256.Signing.PrivateKey(dataRepresentation: data) (4) We then use the output of the above to sign whatever we want. My questions: in the above flow, are we actually getting a hardware-bound key from the Secure Enclave or is this working because it's actually defaulting to a non-hardware-backed key? if it is an SE key, is it that the Apple documentation stating that you can only use the SE with the Data Protection Keychain in the user context is outdated (or wrong)? does the above work, but is not an approach sanctioned by Apple? Any feedback on this would be greatly appreciated.
5
0
1.2k
2w
SecItem: Fundamentals
I regularly help developers with keychain problems, both here on DevForums and for my Day Job™ in DTS. Many of these problems are caused by a fundamental misunderstanding of how the keychain works. This post is my attempt to explain that. I wrote it primarily so that Future Quinn™ can direct folks here rather than explain everything from scratch (-: If you have questions or comments about any of this, put them in a new thread and apply the Security tag so that I see it. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" SecItem: Fundamentals or How I Learned to Stop Worrying and Love the SecItem API The SecItem API seems very simple. After all, it only has four function calls, how hard can it be? In reality, things are not that easy. Various factors contribute to making this API much trickier than it might seem at first glance. This post explains the fundamental underpinnings of the keychain. For information about specific issues, see its companion post, SecItem: Pitfalls and Best Practices. Keychain Documentation Your basic starting point should be Keychain Items. If your code runs on the Mac, also read TN3137 On Mac keychain APIs and implementations. Read the doc comments in <Security/SecItem.h>. In many cases those doc comments contain critical tidbits. When you read keychain documentation [1] and doc comments, keep in mind that statements specific to iOS typically apply to iPadOS, tvOS, and watchOS as well (r. 102786959). Also, they typically apply to macOS when you target the data protection keychain. Conversely, statements specific to macOS may not apply when you target the data protection keychain. [1] Except TN3137, which is very clear about this (-: Caveat Mac Developer macOS supports two different keychain implementations: the original file-based keychain and the iOS-style data protection keychain. IMPORTANT If you’re able to use the data protection keychain, do so. It’ll make your life easier. See the Careful With that Shim, Mac Developer section of SecItem: Pitfalls and Best Practices for more about this. TN3137 On Mac keychain APIs and implementations explains this distinction. It also says: The file-based keychain is on the road to deprecation. This is talking about the implementation, not any specific API. The SecItem API can’t be deprecated because it works with both the data protection keychain and the file-based keychain. However, Apple has deprecated many APIs that are specific to the file-based keychain, for example, SecKeychainCreate. TN3137 also notes that some programs, like launchd daemons, can’t use the file-based keychain. If you’re working on such a program then you don’t have to worry about the deprecation of these file-based keychain APIs. You’re already stuck with the file-based keychain implementation, so using a deprecated file-based keychain API doesn’t make things worse. The Four Freedoms^H^H^H^H^H^H^H^H Functions The SecItem API contains just four functions: SecItemAdd(_:_:) SecItemCopyMatching(_:_:) SecItemUpdate(_:_:) SecItemDelete(_:) These directly map to standard SQL database operations: SecItemAdd(_:_:) maps to INSERT. SecItemCopyMatching(_:_:) maps to SELECT. SecItemUpdate(_:_:) maps to UPDATE. SecItemDelete(_:) maps to DELETE. You can think of each keychain item class (generic password, certificate, and so on) as a separate SQL table within the database. The rows of that table are the individual keychain items for that class and the columns are the attributes of those items. Note Except for the digital identity class, kSecClassIdentity, where the values are split across the certificate and key tables. See Digital Identities Aren’t Real in SecItem: Pitfalls and Best Practices. This is not an accident. The data protection keychain is actually implemented as an SQLite database. If you’re curious about its structure, examine it on the Mac by pointing your favourite SQLite inspection tool — for example, the sqlite3 command-line tool — at the keychain database in ~/Library/Keychains/UUU/keychain-2.db, where UUU is a UUID. WARNING Do not depend on the location and structure of this file. These have changed in the past and are likely to change again in the future. If you embed knowledge of them into a shipping product, it’s likely that your product will have binary compatibility problems at some point in the future. The only reason I’m mentioning them here is because I find it helpful to poke around in the file to get a better understanding of how the API works. For information about which attributes are supported by each keychain item class — that is, what columns are in each table — see the Note box at the top of Item Attribute Keys and Values. Alternatively, look at the Attribute Key Constants doc comment in <Security/SecItem.h>. Uniqueness A critical part of the keychain model is uniqueness. How does the keychain determine if item A is the same as item B? It turns out that this is class dependent. For each keychain item class there is a set of attributes that form the uniqueness constraint for items of that class. That is, if you try to add item A where all of its attributes are the same as item B, the add fails with errSecDuplicateItem. For more information, see the errSecDuplicateItem page. It has lists of attributes that make up this uniqueness constraint, one for each class. These uniqueness constraints are a major source of confusion, as discussed in the Queries and the Uniqueness Constraints section of SecItem: Pitfalls and Best Practices. Parameter Blocks Understanding The SecItem API is a classic ‘parameter block’ API. All of its inputs are dictionaries, and you have to know which properties to set in each dictionary to achieve your desired result. Likewise for when you read properties in output dictionaries. There are five different property groups: The item class property, kSecClass, determines the class of item you’re operating on: kSecClassGenericPassword, kSecClassCertificate, and so on. The item attribute properties, like kSecAttrAccessGroup, map directly to keychain item attributes. The search properties, like kSecMatchLimit, control how the system runs a query. The return type properties, like kSecReturnAttributes, determine what values the query returns. The value type properties, like kSecValueRef perform multiple duties, as explained below. There are other properties that perform a variety of specific functions. For example, kSecUseDataProtectionKeychain tells macOS to use the data protection keychain instead of the file-based keychain. These properties are hard to describe in general; for the details, see the documentation for each such property. Inputs Each of the four SecItem functions take dictionary input parameters of the same type, CFDictionary, but these dictionaries are not the same. Different dictionaries support different property groups: The first parameter of SecItemAdd(_:_:) is an add dictionary. It supports all property groups except the search properties. The first parameter of SecItemCopyMatching(_:_:) is a query and return dictionary. It supports all property groups. The first parameter of SecItemUpdate(_:_:) is a pure query dictionary. It supports all property groups except the return type properties. Likewise for the only parameter of SecItemDelete(_:). The second parameter of SecItemUpdate(_:_:) is an update dictionary. It supports the item attribute and value type property groups. Outputs Two of the SecItem functions, SecItemAdd(_:_:) and SecItemCopyMatching(_:_:), return values. These output parameters are of type CFTypeRef because the type of value you get back depends on the return type properties you supply in the input dictionary: If you supply a single return type property, except kSecReturnAttributes, you get back a value appropriate for that return type. If you supply multiple return type properties or kSecReturnAttributes, you get back a dictionary. This supports the item attribute and value type property groups. To get a non-attribute value from this dictionary, use the value type property that corresponds to its return type property. For example, if you set kSecReturnPersistentRef in the input dictionary, use kSecValuePersistentRef to get the persistent reference from the output dictionary. In the single item case, the type of value you get back depends on the return type property and the keychain item class: For kSecReturnData you get back the keychain item’s data. This makes most sense for password items, where the data holds the password. It also works for certificate items, where you get back the DER-encoded certificate. Using this for key items is kinda sketchy. If you want to export a key, called SecKeyCopyExternalRepresentation. Using this for digital identity items is nonsensical. For kSecReturnRef you get back an object reference. This only works for keychain item classes that have an object representation, namely certificates, keys, and digital identities. You get back a SecCertificate, a SecKey, or a SecIdentity, respectively. For kSecReturnPersistentRef you get back a data value that holds the persistent reference. Value Type Subtleties There are three properties in the value type property group: kSecValueData kSecValueRef kSecValuePersistentRef Their semantics vary based on the dictionary type. For kSecValueData: In an add dictionary, this is the value of the item to add. For example, when adding a generic password item (kSecClassGenericPassword), the value of this key is a Data value containing the password. This is not supported in a query dictionary. In an update dictionary, this is the new value for the item. For kSecValueRef: In add and query dictionaries, the system infers the class property and attribute properties from the supplied object. For example, if you supply a certificate object (SecCertificate, created using SecCertificateCreateWithData), the system will infer a kSecClass value of kSecClassCertificate and various attribute values, like kSecAttrSerialNumber, from that certificate object. This is not supported in an update dictionary. For kSecValuePersistentRef: For query dictionaries, this uniquely identifies the item to operate on. This is not supported in add and update dictionaries. Revision History 2025-05-28 Expanded the Caveat Mac Developer section to cover some subtleties associated with the deprecation of the file-based keychain. 2023-09-12 Fixed various bugs in the revision history. Added a paragraph explaining how to determine which attributes are supported by each keychain item class. 2023-02-22 Made minor editorial changes. 2023-01-28 First posted.
Replies
0
Boosts
0
Views
5.1k
Activity
May ’25
Authentication-UI refusal for a file-based certificate query on macOS
The guidance in https://developer.apple.com/forums/thread/739774 explains the context search list, the kSecMatchSearchList override and continued use of deprecated file-based APIs where that keychain model is required. For a SecItemCopyMatching query using kSecClassCertificate and an explicitly supplied file-based test keychain, what is the supported way to refuse authentication UI rather than allow a prompt? I am considering macOS 26.6.1 with the macOS 27.0 SDK; please clarify applicability to that combination and any relevant application-context restrictions. In particular, which refusal mechanism applies to the file-based path given the deprecation of earlier authentication-UI options? If access would require keychain unlock or authentication UI, is an error guaranteed, or can the query omit items and return success? A public documentation reference and any version limitations would be helpful. This is a contract question for a prospective test; I have not run it or reproduced a problem.
Replies
0
Boosts
0
Views
90
Activity
19h
Launching a signed AppKit app from a Python supervisor while preserving instance ownership and bounded cleanup
I'm looking for a supported way to launch a signed AppKit application for user interaction from a local Python supervisor, while retaining reliable supervision of the exact launched instance. Environment Apple M3 MacBook Air, macOS 14.5, build 23F79. arm64 app built with Command Line Tools clang and the macOS 14.5 SDK, targeting macOS 14.0. AppKit/Foundation with embedded CPython 3.12. Apple Development signing, hardened runtime and strict signature checks passed. Current launch and activation sequence The supervisor directly launches the bundle executable with Popen: a fixed argument, empty environment, new process session, disconnected stdin, and an anonymous stdout pipe carrying fixed, nonsecret startup markers. There is no LaunchServices foreground handoff. On its main thread, the app initializes NSApplication, confirms Regular activation policy, calls finishLaunching and activateIgnoringOtherApps:YES, then waits for isActive. Event-retrieval waits are capped at 20 ms; event dispatch itself may take longer. Existing timeout supervision remains active. Our activation guard is two seconds from the readiness routine's start, subject to the remaining native timer. A separate overall test budget is 300 seconds from operator readiness, before preflight. Observed result The latest test exited with code 1 after approximately 2.57 seconds. The validated markers were: absence.begin → absence.absent → fields.begin → ui.begin → app.shared.begin → app.shared.ready → policy.before → policy.already_regular → policy.postcondition → launch.finish.begin → launch.finish.ready → activation.requested → activation.wait.begin → stop.activation.timeoutThe final recorded state was: main=1 app=1 active=0 policy=0 window=0 visible=-1 key=-1The app stopped before constructing the dialog. Adding event processing did not resolve activation. We have not established why activation failed or which events were delivered. The two-second deadline is our guard, not an asserted macOS activation guarantee. Questions What supported launch and activation approach should this supervisor use for a foreground, interactive AppKit app? Can this direct-executable design be corrected narrowly, or should launching move to LaunchServices with a different communication and supervision arrangement? With the recommended approach, how should the supervisor identify the exact launched instance, receive startup status, enforce bounded termination, and establish that the process has exited before cleanup? We reviewed a simple foreground-launch substitution, but it did not preserve our existing marker pipe and authoritative exit/reap evidence. That is a limitation of our proposed adaptation, not a claim that Apple's APIs cannot support these outcomes. The essential requirements are exact-instance identification, nonsecret status reporting, bounded termination and verified cleanup. An anonymous pipe and direct-child waiting are current implementation choices, not requirements in themselves.
Replies
6
Boosts
0
Views
134
Activity
1d
Screen Recording permission popup not shown & app not added to app list in Screen Recording settings
Requesting the Screen Recording permission seems broken on macOS 27.3 beta 2. I'd love to know whether this change is intentional or whether we can expect a fix before the stable macOS 27.3 release. Feedback report: FB25646769 Behavior until macOS 27.2 When an app calls CGRequestScreenCaptureAccess(), macOS shows the following popup: Additionally, the app is added to the app list in the “Screen & System Audio Recording” panel in the System Settings. It is toggled off by default and the user can easily toggle it on. Behavior on macOS 27.3 beta 2 When an app calls CGRequestScreenCaptureAccess(), no popup appears and the app is not added to the app list in the “Screen & System Audio Recording” panel in the System Settings. The user cannot easily grant the permission. What the user has to do to grant the permission on macOS 27.3 beta 2 It is not intuitive for the user to figure out how to grant the Screen Recording permission. Without any guidance, the user needs to: Click the little plus icon below the app list in the "Screen & System Audio Recording” panel in the System Settings Because the System Settings panel shows two app lists, the user needs to click the plus icon below the correct app list ("Screen & System Audio Recording", not "System Audio Recording Only") Find the app in the file picker and add it This is cumbersome and unintuitive. There's no explanation of what to do. The average user will be confused and will struggle to complete these tasks. Reproduction steps Install an app that requests the Screen Recording permission (e.g., Cap) Get to the onboarding step that requests the Screen Recording permission Observe that the permission request popup is not shown and that the app is not added to the System Settings panel
Replies
3
Boosts
1
Views
141
Activity
2d
Is JIT execution possible for ordinary third-party iOS apps?
I'm researching whether a normally signed third-party iOS application can use Just-In-Time (JIT) compilation on a stock, unjailbroken iPhone. My project, Kairavox, aims to run a genuine, unmodified iPadOS installation as a guest inside a native iOS application. JIT compilation is central to our intended execution architecture: we want to translate and execute guest AArch64 instructions through dynamically generated native code. We intend to test through personal development signing and sideloading using AltStore or SideStore. App Store distribution is not a requirement. I've found Apple's documentation for: Allow Execution of Just-In-Time (JIT) Compiled Code Entitlement Porting Just-In-Time Compilers to Apple Silicon Alternative Browser Engines in the European Union However, the first two appear to concern the macOS Hardened Runtime context. Apple's alternative browser engine provisions also describe a specifically authorized exception, which does not describe our application. I'd appreciate clarification on what is supported for an ordinary third-party iOS app: Is there a documented iOS API or entitlement that allows a normally signed third-party app to allocate writable memory, generate machine code, and execute that code at runtime? Does iOS support MAP_JIT for ordinary third-party applications, or is it restricted to other Apple platforms or specially authorized applications? Is com.apple.security.cs.allow-jit exclusively a macOS Hardened Runtime entitlement, or does it have any application on iOS? Can an app using free Personal Team development signing execute JIT-generated code? Does paid Apple Developer Program membership change this? Do development, ad hoc, or other signing arrangements differ in their JIT permissions? Is there a documented process for an independent developer to request the necessary capability? Does installing an app through AltStore or SideStore change its OS-granted executable-memory permissions, or does it retain the permissions associated with its signed build? Are there any documented restrictions on using JIT-generated native code for CPU emulation or virtualization workloads? I understand that Apple's EU alternative-browser-engine authorization is a narrow exception for eligible browser applications. I'm not assuming it applies to Kairavox. The main question is whether an independent developer can build and test a JIT-based application on a stock iPhone using an officially supported signing and permission model. Thank you.
Replies
1
Boosts
0
Views
50
Activity
2d
Sandbox restriction blocks Keychain access during Live Activity rendering: supported design for encrypted updates?
Hi, I'm building a Live Activity prototype using fictitious data. I want incoming updates to stay encrypted until they reach my iPhone, without putting the decryption key in ActivityAttributes, ContentState, or archived views. My goal is timely updates without an alert for each change. I'm using Xcode 27.2 and the iPhoneOS 27.2 SDK. My iPhone was running iOS 27.2.1 when I last checked. I haven't recorded its exact OS build or the OS version and build for every earlier test. My app and WidgetKit extension have the same shared Keychain access group in their signed entitlements. My app creates a 32-byte test key as a generic password with kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly, with synchronization disabled. The extension only reads the key. A failed lookup never causes the key to be replaced or deleted. When I try to read the key while rendering the Live Activity, the first, metadata-only SecItemCopyMatching call returns errSecNotAvailable (-25291). It fails before I request any secret bytes. I reproduced this after stopping and restarting the activity with my iPhone unlocked. I get the same result with a non-interactive LAContext and with kSecUseAuthenticationUIFail without a supplied context. I used the latter only for comparison, since it is deprecated. My query specifies the class, fixed service and account, and shared access group. It also sets kSecUseDataProtectionKeychain. For the metadata lookup, I use kSecAttrSynchronizableAny, kSecReturnAttributes: true, and kSecMatchLimitAll, without requesting data or item references. I only request the key bytes after finding exactly one item and validating its policy, so that second step is never reached here. For comparison, I added a regular widget to the same signed WidgetKit extension. Its timeline provider successfully validates the metadata using the same read-only query and client, while the Live Activity still returns errSecNotAvailable. I captured these results separately; I haven't established whether they ran simultaneously or in different processes. I have only confirmed metadata access in the regular widget, not access to the key bytes. I also tried decrypting in my foreground app and then passing the fictitious summary to ActivityKit through a local update. That renders correctly on my iPhone. It doesn't test remote delivery or background decryption, or fix the Keychain failure during rendering. I repeated the test with debug messages enabled in Console. The Live Activity in my diagnostic build still shows the same Keychain failure. The capture from the extension now includes the connection error, not just the generic securityd message: activating connection: ... name=com.apple.securityd failed to do a bootstrap look-up: xpc_error=[159: Unknown error: 159] invalidated after a failed init got event: Connection invalid Failed to talk to securityd after 4 attempts. error:[-25291] Error Domain=com.apple.security.xpc Code=3 Connection invalid - Connection init failed at lookup with error 159 - Sandbox restrictionThis excerpt omits connection addresses and account fields. The same -25291 error and sandbox-restriction reason appear five times in this capture. It establishes the reported reason for the connection failure in this test; I haven't established whether this is an intended restriction, an OS issue, or a configuration issue. I also don't infer the actual retry count from the generic message. I'd appreciate guidance on these questions: Given the explicit sandbox-restriction error for com.apple.securityd, is non-interactive Keychain access intentionally unavailable during Live Activity rendering, or should I investigate an OS or configuration issue? Displaying live data with Live Activities documents a separate sandbox and restrictions on network and location access, but I haven't found its Keychain access contract. How should I interpret the different result from my regular widget's timeline provider? For encrypted content-state updates, is there a supported execution point where my app can authenticate and decrypt each update before handing a local render value to ActivityKit? I found the documented app wake-up for push-to-start, but not an equivalent for ordinary updates. If neither approach is supported, how can I deliver timely, alert-free encrypted Live Activity updates while keeping the key solely in Keychain and out of archived state and views? How does ActivityKit protect static ActivityAttributes at rest? Can those attributes be included in backups or replicated to an Apple Watch or Mac, separately from rendered views? Does any of that data pass through Apple servers, and is there a public API to opt out of replication? Would a per-activity session key in locally created static attributes be a supported design, or does Apple advise against storing secrets there? I haven't implemented this alternative. I would keep the long-term pairing key in Keychain, exclude the session key from every APNs payload, and start the activity locally rather than through push-to-start. I'd like to understand the storage and replication guarantees before considering it further. I'm looking for a supported design without weakening Keychain protection, allowing authentication UI during rendering, or suppressing an ordinary notification to bypass its requirements. I can prepare a minimal reproducer with fictitious data and no tokens, real identifiers, or conversation content. Thanks for your help.
Replies
3
Boosts
0
Views
120
Activity
3d
macOS APFS: com.apple.macl and UF_TRACKED appear after creating a hard link — safe file replacement and rollback?
I'm investigating an unexpected metadata change during a controlled file deployment on macOS. Environment and observed state Two regular configuration files are used by a local service. Before replacement, the first file had: SHA-256: verified. File flags: 0. Extended attributes: none. Hard-link count: 1. Owner/group: 501/20. Permissions: 0644. ACL: empty. A backup procedure created a hard link to preserve the original inode before replacing the active pathname with an independently created file. Immediately after creating and verifying the hard link, the original file was observed with: The same SHA-256 and inode. Flags: 64 (UF_TRACKED). Extended attribute: com.apple.macl. Hard-link count: 2. No file content was replaced. The procedure stopped because the metadata no longer matched the original baseline. Additional observations Other backup methods also encountered unexpected metadata changes during destination creation. Tests using renamex_np with RENAME_SWAP successfully exchanged and restored artificial files with flags 0 and empty extended attributes. A test with artificial files already containing com.apple.provenance also succeeded. We could not reproduce the specific UF_TRACKED + com.apple.macl + two-hard-link state in an isolated fixture using ordinary documented operations. The operational original and its second hard link currently share the same inode. No attempt has been made to remove the protected attribute or change its flags. Questions for Apple filesystem/security specialists Under what documented circumstances can creating a hard link or related Finder/TCC document-tracking behavior cause UF_TRACKED and com.apple.macl to appear on an existing file? Are these metadata changes expected for a file accessed through a user-authorized Documents location? What supported mechanism can preserve the current original inode and provide a verifiable rollback when replacing its active pathname? Is renamex_np(..., RENAME_SWAP) appropriate for this situation, and what special considerations apply to the existing second hard link and protected extended attributes? What verification criteria would you recommend before permitting a production replacement? I am looking for a documented, reversible procedure that preserves macOS security protections. I do not want to disable SIP, forcibly remove com.apple.macl, or bypass TCC. I can provide sanitized metadata comparisons and a minimal reproduction if needed.
Replies
1
Boosts
0
Views
153
Activity
3d
Client identity selection and chain presentation when an intermediate CA in the identity’s chain is revoked
We deploy client-authentication identities (certificate + private key) to iOS/iPadOS devices for mutual TLS and Wi-Fi EAP-TLS. The identities are installed via MDM configuration profiles and used from Safari, from our app via URLSession client certificate challenges, and by the system for EAP-TLS. The intermediate CA certificate in these identities’ chain (issued by a publicly trusted root) will be revoked. A replacement intermediate certificate with the same subject and public key, but a different serial number, is valid, and the end-entity certificates will not be reissued. The private keys are not exportable. If the revoked intermediate is known to the device through Apple’s distributed revocation data, or only through the root CA’s CRL, does iOS/iPadOS evaluate this when offering the identity for selection in Safari, when handling a URLSession client certificate challenge, or when using it for EAP-TLS? Could the identity be hidden, flagged, or fail to be presented? If we install the replacement intermediate on the device (e.g. via a certificate payload in a configuration profile) and remove the original, will the system build and present the chain through the replacement certificate? For URLSession, if our app supplies the chain explicitly in URLCredential(identity:certificates:persistence:), is any revocation evaluation performed on that chain on the client side? The revocation is scheduled for 2026-11-20T09:00:00Z. Our users rely on this system for patient care in medical institutions, so any guidance before then would be greatly appreciated.
Replies
2
Boosts
5
Views
492
Activity
3d
macOS 27/APFS: Supported ACL Absence Verification When acl_get_fd_np Returns ENOENT
Subject: Supported fail-closed ACL absence verification on macOS 27.0.1 / APFS Environment: macOS 27.0.1, build 26A434; APFS; installed macOS 27.0 SDK. We need a supported, documented way to determine whether an existing filesystem object has no effective ACL entries, while rejecting genuine retrieval failures and unsupported or unavailable ACL evidence. We are seeking clarification of the public interface contract, not alleging an Apple defect. For existing directory and regular-file fixtures, pathname metadata and descriptor metadata identify the same object. Errno is cleared immediately before each native call and captured immediately afterward. ACL retrieval uses ACL_TYPE_EXTENDED: acl_get_file(path, ACL_TYPE_EXTENDED) acl_get_fd_np(fd, ACL_TYPE_EXTENDED) On fresh objects, both return NULL with ENOENT. Explicit one-entry fixture ACLs are retrieved successfully. Explicit zero-entry fixture ACLs can also yield NULL/ENOENT, while attribute queries return a serialized zero-entry ACL. The attribute queries use getattrlist() and descriptor-bound fgetattrlist(), requesting ATTR_CMN_RETURNED_ATTRS | ATTR_CMN_EXTENDED_SECURITY, with FSOPT_NOFOLLOW | FSOPT_REPORT_FULLSIZE and WITHOUT FSOPT_PACK_INVAL_ATTRS. Buffer lengths, variable-reference bounds and returned-attribute validity are checked. For the existing directories of interest, both calls succeed but omit the ATTR_CMN_EXTENDED_SECURITY returned bit. Explicit populated and zero-entry fixture records do set the bit. APFS reports valid VOL_CAP_INT_EXTENDED_SECURITY support; we do not assume that volume capability proves per-object ACL availability. On macOS 27.0.1, build 26A434, using APFS, which supported interface and documented conditions allow software to distinguish an absent ACL from unavailable or unsupported ACL evidence when descriptor-bound attribute queries succeed but omit ATTR_CMN_EXTENDED_SECURITY and native ACL getters return ENOENT for an existing object? Please clarify: Whether ENOENT has a supported ACL-absence interpretation, and under exactly which checked conditions. Whether an omitted extended-security attribute can establish ACL absence, rather than unavailable or unsupported evidence. How explicit zero-entry ACLs differ from absent ACL records through supported interfaces. How KAUTH_FILESEC_NOACL should be interpreted through supported APIs. How genuine retrieval failures, including permission, I/O, allocation and unsupported-operation errors, must remain distinguishable. Whether a supported descriptor-bound verification method exists that preserves fail-closed security checks and object identity binding; please identify its guarantees and limitations regarding pathname/ancestor changes and later operations. Whether relevant behavior is specific to this macOS/APFS version. Please identify the applicable public documentation or supported verification sequence. We do not want to modify permissions, synthesize ACLs on target objects, treat invalid-attribute defaults as real evidence, or accept ambiguous omission/ENOENT as success. Existing ownership, mode and confinement checks must remain separate mandatory checks. If no public API can make this distinction reliably, please state that limitation.
Replies
15
Boosts
0
Views
582
Activity
3d
CKKS zone deletions return success but stale 2019 key hierarchy persists; "Delete iCloud Data" not offered (FB25584356)
I filed FB25584356 for this and would appreciate any pointers. Setup: Mac mini on macOS 27.2.1 and an iPhone on iOS 27.2, same Apple Account, HSA2, Advanced Data Protection off. Octagon is healthy (otctl status = Ready, both devices trusted). Symptoms: AirDrop to my own iPhone fails when I pick the device (rapportd: "PairVerify server M2 failed: copy identity"), iPhone Mirroring ends with noCompatiblePhone, and various clients log CKErrorDomain 111 / 5009 "Keychain Sync Incomplete". What I see in CKKS: seven zones (AutoUnlock, LimitedPeersAllowed, Home, Manatee, ApplePay, Health, Engram) still hold a key hierarchy from August 2019. The only TLKShare was issued by a device that left the account years ago, so neither current device can unwrap the TLK ("No trusted TLKShares", CKKSErrorDomain 35). secd then does what I would expect: tlkmissing → "No other devices claim to have the TLK. Resetting zone..." → CKKSDeleteCKZoneOperation → local reset → zones recreated. The delete appears to succeed. With debug logging, cloudd shows status:200 and "RecordZone ... was successfully deleted from the server" for each zone. The next fetch returns the same 2019 records with an identical server change token. Over about 11 hours: 124 reset cycles, 869 zone deletions reported as successful, 182 consecutive AutoUnlock fetches with the same change token. When not throttled it runs roughly every 5 seconds; CloudKit eventually answers "Service Unavailable" (CKError 6/2009) with a ~59 minute retry-after, and all 23 zones are unusable in the meantime. ckksctl -v AutoUnlock reset-cloudkit behaves the same way. Reset path: Support article 120862 describes "Don't know passcode?" → "Forgot all passcodes?" → "More Options" → "Delete iCloud Data". With the Mac signed in but not yet trusted, "Don't know passcode?" only offered Cancel / Try Again Later, in the sign-in flow and in both System Settings follow-ups. After three wrong passcodes the alert had a single "Try Again Later" button, although cdpd logged "Creating recovery option: Reset". Questions: Is a client-side zone delete expected to be a no-op for these zones while the server reports success? Is there a supported way to reach performCKServerUnreadableDataRemoval / "Delete iCloud Data" when another trusted device exists? I am fine with losing the end-to-end encrypted data in those zones. Logs and a sysdiagnose are attached to the Feedback.
Replies
0
Boosts
0
Views
135
Activity
6d
Sandboxed app can't delete AppleDouble (._) files of quarantined files on exFAT, even with user-selected access.
My Mac App Store utility removes Mac metadata files (._* AppleDouble files and .DS_Store) from external drives formatted exFAT or FAT32. The app is sandboxed with com.apple.security.files.user-selected.read-write and com.apple.security.files.bookmarks.app-scope. The user grants access to the volume through NSOpenPanel. Deleting a ._ file works, except when its companion file carries com.apple.quarantine (for example, a file downloaded with Safari and copied to the drive with Finder). Then: let partner = volume + "/Nirvana.zip" // has com.apple.quarantine let appleDouble = volume + "/._Nirvana.zip" removexattr(partner, "com.apple.quarantine", XATTR_NOFOLLOW) // -1, errno 1 (EPERM) unlink(appleDouble) // -1, errno 1 (EPERM)The same unlink succeeds from Terminal (not sandboxed, without Full Disk Access). On exFAT the extended attributes live in the ._ file, so I assume the sandbox refuses because deleting it would remove the quarantine attribute. Tried, with no change: Full Disk Access granted to the app. Adding com.apple.security.files.user-selected.executable (verified in the built app with codesign -d --entitlements -). On a real drive (a music library), about 71% of the ._ files belong to quarantined files, so this is most of what users want removed. Is there a supported way for a sandboxed app to remove these files: an entitlement, an API, or an explicit user action? If not, can you confirm it's intended behavior, so I can explain it accurately to users? macOS 27.2, Xcode 27.2, Apple silicon. Focused sample project available (one source file). DTS case 23240704.
Replies
5
Boosts
0
Views
174
Activity
1w
Choosing a TLS server identity by client address with NWListener
I run an HTTPS server on NWListener (iOS and macOS) that serves several identities from one listener on port 443, picked per handshake in sec_protocol_options_set_challenge_block, as suggested in this thread. That works well for every handshake that carries a server name. The trouble is handshakes without one. Clients on the LAN connect by IP address, so they send no SNI (RFC 6066 keeps IP literals out of it), and they trust a self-signed certificate through a configuration profile. Internet clients and scanners that reach the public address through the router's port forward also often arrive without SNI. The two groups should get different certificates, and the only thing that tells them apart is the client's address. The listener knows it in newConnectionHandler, but the challenge block never sees it. What I tried: sec_protocol_metadata_t has accessors for the server name, ALPN, version, cipher suite and so on, but I can't find one for the connection's endpoints. Setting a challenge block on the accepted connection's own TLS options before start(): listener.newConnectionHandler = { connection in let remote = connection.endpoint if let tls = connection.parameters.defaultProtocolStack.applicationProtocols .compactMap({ $0 as? NWProtocolTLS.Options }).first { sec_protocol_options_set_challenge_block(tls.securityProtocolOptions, { _, complete in complete(identity(for: remote)) }, queue) } connection.start(queue: queue) }This block never runs. The listener's own block answers every handshake (tested on macOS 27.2). My questions: Is there a supported way to choose the server identity per connection based on its endpoints, short of terminating TLS myself? Is the challenge block supported under TLS 1.3 by now? I also see it run twice for every handshake; is that expected? When a server-side handshake fails, connection.metadata(definition: NWProtocolTLS.definition) returns nil. Is there any way to learn which server name a failed handshake asked for, so it can be logged? I filed FB25541009 with a small sample project that shows all three.
Replies
2
Boosts
0
Views
90
Activity
1w
is NSTextInputClient safe?
is NSTextInputClient safe? I have several apps that has autofill (app name) activity due to NSTextInputClient. I am wondering if my app has this activity will it be submittable to the app store?
Replies
2
Boosts
0
Views
357
Activity
1w
Unexpected Core Foundation attribute types when inspecting an existing Secure Enclave-associated Keychain key on macOS
Hello Apple Developer community, I'm investigating an unexpected metadata representation returned by Apple's Security framework while inspecting an existing Secure Enclave-associated Keychain item on macOS. A read-only inspection using SecItemCopyMatching returns one matching key record with a successful status, a Secure Enclave token identifier (com.apple.setoken), and a 256-bit key size. However, direct Core Foundation type inspection reports: kSecAttrKeyType: CFNumber kSecAttrKeyClass: CFNumber kSecAttrSynchronizable: CFNumber The raw Core Foundation observations and bridged observations agree. Our current validator rejects these unexpected types and returns UNSUPPORTED_OR_INCOMPLETE_METADATA. We have deliberately stopped further key operations pending clarification. Questions: Can these CFNumber values legitimately appear in a dictionary returned by SecItemCopyMatching for Secure Enclave-associated key items on macOS? What returned value types should be expected for these three attributes, and are they dependent on the query or Keychain implementation? Is there an Apple-recommended way to normalize or validate these attributes without incorrectly accepting incompatible metadata? How should an application distinguish an existing Secure Enclave-backed key from an incomplete or unsupported Keychain record without performing a private-key operation? Are there relevant Security framework documentation references or known implementation differences we should consult? Our aim is to validate the existing record safely without regenerating, deleting, or using the private key. Thank you for your guidance.
Replies
5
Boosts
0
Views
427
Activity
1w
Can macOS restrict a signing key to one exact build of a system daemon?
Hi Apple Developer Technical Support, We have a locally signed macOS system daemon that an administrator starts manually. It needs to use a dedicated P-256 signing key in a file-based keychain. We want macOS to let only the exact approved build use that key, without a prompt. A different build signed with the same certificate should be denied. Apple’s published Security source shows that the keychain can identify some callers by their code directory hash (cdhash). Is setting a key’s partition list to that exact hash a supported way to enforce this restriction for a system daemon? If so, which macOS versions support it, and what API or Apple tool should we use to configure it? After setup, how can we verify that the intended key has the exact restriction in place, including whether any broader rule allows another process to sign with the key, export it, or change its access rules? If macOS doesn’t offer a supported way to set and verify this restriction, please confirm that limitation.
Replies
1
Boosts
0
Views
101
Activity
1w
Repeated login Keychain prompts and securityd crash after app upgrade on macOS 26.6.x
Overview We are investigating repeated "login" Keychain prompts affecting our macOS application on macOS 26.6.x. The issue appears after upgrading an existing installation. A clean uninstall/reinstall of the same version resolves it. Changing the affected Keychain item's Access Control from "Confirm before allowing access" to explicitly allowing our application/process also stops the prompts. On one affected machine, Apple Support observed a securityd crash followed by: SecKeyCreateSignature failed CSSMERR_DL_INVALID_DB_HANDLE Our code uses some legacy SecKeychain* APIs, so we are currently investigating whether this is related. Questions Were there any changes in macOS 26.6.x around securityd, Keychain ACL handling, or legacy SecKeychain* APIs that could explain this? Could an existing Keychain ACL become stale after an application upgrade, even when both versions are signed with the same Developer ID?
Replies
18
Boosts
0
Views
3.8k
Activity
2w
Secure Enclave: Supporting Signing-Only, Key-Agreement-Only, and Dual-Purpose Keys
Hello everyone, I'm trying to understand the actual limitations of the Secure Enclave (SEP) regarding cryptographic key capabilities, and more specifically how to generate and store the following key types in the keychain: Sign only: The key can only be used for digital signatures. Key agreement only: The key can only be used for key agreement operations. All operations: The key can be used for both signing and key agreement. I've noticed some apparent differences between Apple's Security framework and CryptoKit, and I'm trying to understand whether these differences reflect actual SEP limitations or simply framework-level restrictions. 1. Security framework: dual purpose keys I'm currently using SecKeyCreateRandomKey to generate Secure Enclave-backed keys. Here is the relevant code: NSDictionary *privateAttributes = @{ (__bridge id)kSecAttrIsPermanent : @YES, (__bridge id)kSecAttrAccessControl : ..., (__bridge id)kSecAttrApplicationTag : ..., // key agreement only (__bridge id)kSecAttrCanSign: @NO, (__bridge id)kSecAttrCanDerive: @YES }; NSMutableDictionary *attributes = [ @{ (__bridge id)kSecAttrKeyType : (__bridge id)kSecAttrKeyTypeECSECPrimeRandom, (__bridge id)kSecAttrTokenID : (__bridge id)kSecAttrTokenIDSecureEnclave, (__bridge id)kSecAttrKeySizeInBits : @256, (__bridge id)kSecPrivateKeyAttrs : privateAttributes } mutableCopy ]; CFErrorRef generationError = nullptr; SecKeyRef privateKey = SecKeyCreateRandomKey( (__bridge CFDictionaryRef)attributes, &generationError );However, when experimenting with these attributes, I encountered the following error: SecKeyCreateRandomKey failed: Error Domain=NSOSStatusErrorDomain Code=-50 "Failed to generate keypair" Underlying error: Error Domain=CryptoTokenKit Code=-8 "sepkey: sign requires '1' value when present"Using signing-only attributes results in the same kind of error. This makes me wonder whether the Security framework actually allows generating (and adding entries in the keyChain) only keys with both capabilities enabled. It is possible to create siging only key or key agreement only key with Security framework? 2. CryptoKit: Separate key types On the other hand, CryptoKit seems to expose two distinct Secure Enclave key types: P256.SecureEnclave.Signing.PrivateKey P256.SecureEnclave.KeyAgreement.PrivateKeyFrom the API design, it appears that CryptoKit only allows creating keys dedicated to one operation or the other. For example, a Signing.PrivateKey cannot be used for key agreement, and a KeyAgreement.PrivateKey cannot be used for signing. Is it possible to create both capabilities keys with CryptoKit framework? 3. Actual Secure Enclave limitations What are the actual cryptographic capability limitations imposed by the SEP itself? I'd particularly like to understand which restrictions originate from: The Secure Enclave hardware. Security and CryptoKit frameworks. Is there a documented way to generate and store in the keychain: A signing-only Secure Enclave key? A key-agreement-only Secure Enclave key? A Secure Enclave key supporting both operations? Thanks in advance, Idopte
Replies
1
Boosts
0
Views
89
Activity
2w
How can a macOS application establish that an open APFS file has no extended ACL?
On macOS 26.5.2 (build 25F84), which documented API and return conditions, if any, establish that a regular file on APFS has no extended access control list (ACL), using an already-open file descriptor? We tested three disposable regular files on an APFS volume reporting ACL support. For each file, we opened a read-only file descriptor and called: acl_get_fd_np(fd, ACL_TYPE_EXTENDED) fgetattrlist() requesting ATTR_CMN_RETURNED_ATTRS | ATTR_CMN_EXTENDED_SECURITY Before and after inspection, fstat() confirmed stable device, inode, mode, and change timestamp. Observed results: 1. Newly created file, no ACL explicitly assigned acl_get_fd_np() returned NULL with errno == ENOENT. fgetattrlist() succeeded but omitted ATTR_CMN_EXTENDED_SECURITY from the returned attribute mask. FSOPT_PACK_INVAL_ATTRS also left that bit clear. 2. File with an explicitly assigned empty ACL acl_get_fd_np() returned NULL with errno == ENOENT. fgetattrlist() returned the extended-security attribute with an ACL entry count of zero. 3. File with one explicit ACL entry acl_get_fd_np() returned a non-null ACL. fgetattrlist() returned the extended-security attribute with an ACL entry count of one. Apple's published XNU attribute-packing implementation appears to use the same omission branch when ACL metadata is unsupported or when the ACL pointer is null. My question: Is there a supported descriptor-based API sequence that reliably distinguishes: Genuine absence of an extended ACL Unavailable or unsupported per-file ACL metadata An ACL retrieval failure If so, which API, capability checks, return values, attribute bits, or error conditions should a caller rely on? Are there relevant APFS or macOS version limitations? If the public API cannot establish ACL absence unambiguously in this situation, confirmation of that limitation would also be helpful. Thank you for your guidance.
Replies
2
Boosts
0
Views
108
Activity
2w
Using Cryptokit.SecureEnclave API from a Launch Daemon
We are interested in using a hardware-bound key in a launch daemon. In a previous post, Quinn explicitly told me this is not possible to use an SE keypair outside of the system context and my reading of the Apple documentation also supports that. That said, we have gotten the following key-creation and persistence flow to work, so we have some questions as to how this fits in with the above. (1) In a launch daemon (running thus as root), we do: let key = SecureEnclave.P256.Signing.PrivateKey() (2) We then use key.dataRepresentation to store a reference to the key in the system keychain as a kSecClassGenericPassword. (3) When we want to use the key, we fetch the data representation from system keychain and we "rehydrate" the key using: SecureEnclave.P256.Signing.PrivateKey(dataRepresentation: data) (4) We then use the output of the above to sign whatever we want. My questions: in the above flow, are we actually getting a hardware-bound key from the Secure Enclave or is this working because it's actually defaulting to a non-hardware-backed key? if it is an SE key, is it that the Apple documentation stating that you can only use the SE with the Data Protection Keychain in the user context is outdated (or wrong)? does the above work, but is not an approach sanctioned by Apple? Any feedback on this would be greatly appreciated.
Replies
5
Boosts
0
Views
1.2k
Activity
2w