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 restriction

This 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:

  1. 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?

  2. 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.

  3. 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?

  4. 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?

  5. 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.

I can’t really answer the big picture Live Activity side of this, but I’m happy to address the keychain part.

The evidence you’ve presented makes it clear that your process is unable to access the keychain because that access is blocked by its sandbox. On iOS the sandbox configuration is entirely under the control of the OS. There is no scope for a “configuration issue” on your part.

If you want this behaviour to change then you should file a bug about it. Please post your bug number, just for the record.

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

Thank you !

I filed FB25633162 (ActivityKit, iOS 27.2.1 24B156) with the details above. I can provide a minimal reproducer and a sysdiagnose on request.

Have a nice day.

Written by User255582 in 917493022

I filed FB25633162

Thanks.

Written by User255582 in 917493022

I can provide a minimal reproducer and a sysdiagnose on request.

Please add both to your bug report. Make sure to take the sysdiagnose log shortly after reproducing the problem.

The sysdiagnose log is important even if the problem readily reproduces, because our engineering teams use it to triage bug reports.

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