XPC codesign requirement crashes application

We have an application that sets a code signing requirement on a XPC connection between a File Provider extension and the main application. Only with a specific Developer ID certificate <DEVELOPER_ID_TEAM_IDENTIFIER> that designated requirement is not accepted and the application crashes with EXC_CRASH (SIGABRT) and the stacktrace

Thread 1 Crashed:: Dispatch queue: com.apple.root.default-qos
0 libsystem_kernel.dylib 0x19b556388 __pthread_kill + 8
1 libsystem_pthread.dylib 0x19b58f88c pthread_kill + 296
2 libsystem_c.dylib 0x19b498a3c abort + 124
3 libc++abi.dylib 0x19b545384 abort_message + 132
4 libc++abi.dylib 0x19b533cf4 demangling_terminate_handler() + 344
5 libobjc.A.dylib 0x19b1b8dd4 _objc_terminate() + 156
6 libc++abi.dylib 0x19b544698 std::__terminate(void (*)()) + 16
7 libc++abi.dylib 0x19b547c30 __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 88
8 libc++abi.dylib 0x19b547bd8 __cxa_throw + 92
9 libobjc.A.dylib 0x19b1aecf8 objc_exception_throw + 448
10 Foundation 0x19d5c3840 -[NSXPCConnection setCodeSigningRequirement:] + 140
11 libxpcfileprovider.dylib 0x301023048 NSXPCConnection.setCodeSigningRequirementFromTeamIdentifier(_:) + 1796
12 libxpcfileprovider.dylib 0x30101dc94 closure #1 in CallbackFileProviderManager.getFileProviderConnection(_:service:completionHandler:interruptionHandler:exportedObject:) + 1936
13 libxpcfileprovider.dylib 0x30101e110 thunk for @escaping @callee_guaranteed @Sendable (@guaranteed NSXPCConnection?, @guaranteed Error?) -> () + 80
14 Foundation 0x19d46c3a4 __72-[NSFileProviderService getFileProviderConnectionWithCompletionHandler:]_block_invoke_2.687 + 284
15 libdispatch.dylib 0x19b3d7b2c _dispatch_call_block_and_release + 32
16 libdispatch.dylib 0x19b3f185c _dispatch_client_callout + 16
17 libdispatch.dylib 0x19b40e490 + 32
18 libdispatch.dylib 0x19b3e9fa4 _dispatch_root_queue_drain + 736
19 libdispatch.dylib 0x19b3ea5d4 _dispatch_worker_thread2 + 156
20 libsystem_pthread.dylib 0x19b58be28 _pthread_wqthread + 232
21 libsystem_pthread.dylib 0x19b58ab74 start_wqthread + 8

The designated codesign requirement on the XPC connection is set to

anchor apple generic and certificate leaf[subject.OU] = <DEVELOPER_ID_TEAM_IDENTIFIER>"

We have verified the designated code sign requirement to be valid on both the main bundle and the embedded extension using:

codesign --verify -v -R '=anchor apple generic and certificate leaf[subject.OU] = "<DEVELOPER_ID_TEAM_IDENTIFIER>"' *.app
codesign --verify -v -R '=anchor apple generic and certificate leaf[subject.OU] = "<DEVELOPER_ID_TEAM_IDENTIFIER>"' *.app/Contents/PlugIns/*
Answered by DTS Engineer in 859379022

Thanks for bringing this to the forums. This is a weird one, and I’m glad to be able to answer it in public.

The designated codesign requirement on the XPC connection is set to …

The most likely cause of this issue is a quoting problem. Consider this:

% cat ok.txt
anchor apple generic and certificate leaf[subject.OU] = SKMME9E2Y8
% csreq -r ok.txt -t
anchor apple generic and certificate leaf[subject.OU] = SKMME9E2Y8
% cat ng.txt        
anchor apple generic and certificate leaf[subject.OU] = 1KMME9E2Y8
% csreq -r ng.txt -t
error: invalid or corrupted code requirement(s)
Requirement syntax error(s):
line 1:55: unexpected token: =
line 1:57: expecting EOF, found '1'

The only difference between ok.txt and ng.txt is that the Team ID starts with a digit. That throws off the requirements parser, resulting in wacky errors. When you use it with NSXPCConnection the error occurs at a point where it’s very hard to propagate, and thus you trap.

The fix is to apply always quote your Team ID:

% cat fixed.txt     
anchor apple generic and certificate leaf[subject.OU] = "1KMME9E2Y8"
% csreq -r fixed.txt -t
anchor apple generic and certificate leaf[subject.OU] = "1KMME9E2Y8"

Share and Enjoy

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

Log output from com.apple.securityd below:

2025-08-29 15:36:50.076408+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (libxpcfileprovider.dylib) [<APP_BUNDLE_IDENTIFIER>:NSXPCConnection] Set code signing requirement with team identifier <DEVELOPER_ID_TEAM_IDENTIFIER>
2025-08-29 15:36:50.076991+0200 0x6dc007 Default 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] MacOS error: -67052
2025-08-29 15:36:50.078752+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 0 Security 0x000000019fa4ec74 Security::CommonError::LogBacktrace() + 124
2025-08-29 15:36:50.078785+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 1 Security 0x000000019fa4f20c Security::MacOSError::MacOSError(int) + 312
2025-08-29 15:36:50.078800+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 2 Security 0x000000019f92bbd4 Security::CodeSigning::CSError::CSError(int, __CFDictionary const*) + 24
2025-08-29 15:36:50.078810+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 3 Security 0x000000019f94196c Security::CodeSigning::CSError::throwMe(int, __CFString const*, void const*) + 80
2025-08-29 15:36:50.078822+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 4 Security 0x000000019f95fd20 Security::CodeSigning::RequirementParser<Security::CodeSigning::Requirement>::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 288
2025-08-29 15:36:50.078829+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 5 Security 0x000000019f9224b4 SecRequirementCreateWithStringAndErrors + 88
2025-08-29 15:36:50.078837+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 6 XPCSupport 0x000000027e308224 xpc_support_check_token + 88
2025-08-29 15:36:50.078844+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 7 libxpc.dylib 0x000000019c00c58c xpc_connection_set_peer_code_signing_requirement + 64
2025-08-29 15:36:50.078954+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 8 Foundation 0x000000019e3237ec -[NSXPCConnection setCodeSigningRequirement:] + 56
2025-08-29 15:36:50.078997+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 9 libxpcfileprovider.dylib 0x000000013e233048 $sSo15NSXPCConnectionC15XPCFileProviderE43setCodeSigningRequirementFromTeamIdentifieryySo8NSBundleCF + 1796
2025-08-29 15:36:50.079057+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 10 libxpcfileprovider.dylib 0x000000013e22dc94 $s15XPCFileProvider012CallbackFileB7ManagerC03getdB10Connection_7service17completionHandler012interruptionJ014exportedObjectySo06NSFilebE0C_So0nB7ServiceCAA0dbe7ConnectC0_pSgAnA08InternaldbJ0_ptFySo15NSXPCConnectionCSg_s5Error_pSgtYbcfU_ + 1936
2025-08-29 15:36:50.079100+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 11 libxpcfileprovider.dylib 0x000000013e22e110 $sSo15NSXPCConnectionCSgs5Error_pSgIeghgg_ACSo7NSErrorCSgIeyBhyy_TR + 80
2025-08-29 15:36:50.079628+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 12 Foundation 0x000000019e1cc3a4 __72-[NSFileProviderService getFileProviderConnectionWithCompletionHandler:]_block_invoke_2.687 + 284
2025-08-29 15:36:50.079649+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 13 libdispatch.dylib 0x000000019c137b2c _dispatch_call_block_and_release + 32
2025-08-29 15:36:50.079658+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 14 libdispatch.dylib 0x000000019c15185c _dispatch_client_callout + 16
2025-08-29 15:36:50.079666+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 15 libdispatch.dylib 0x000000019c16e490 _dispatch_channel_invoke.cold.5 + 32
2025-08-29 15:36:50.079673+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 16 libdispatch.dylib 0x000000019c149fa4 _dispatch_root_queue_drain + 736
2025-08-29 15:36:50.079681+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 17 libdispatch.dylib 0x000000019c14a5d4 _dispatch_worker_thread2 + 156
2025-08-29 15:36:50.079691+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 18 libsystem_pthread.dylib 0x000000019c2ebe28 _pthread_wqthread + 232
2025-08-29 15:36:50.079700+0200 0x6dc007 Debug 0x0 26936 0 <APPLICATION>: (Security) [com.apple.securityd:security_exception] 19 libsystem_pthread.dylib 0x000000019c2eab74 start_wqthread + 8
2025-08-29 15:36:50.079786+0200 0x6dc007 Error 0x0 26936 0 <APPLICATION>: (XPCSupport) xpc_support_check_token: <private> error: <private> status: -67052
2025-08-29 15:36:50.080448+0200 0x6dc007 Default 0x0 26936 0 <APPLICATION>: (CoreFoundation) *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSXPCConnection 0x600000a4f980: The peer code signing requirement of anchor apple generic and certificate leaf[subject.OU] = <DEVELOPER_ID_TEAM_IDENTIFIER> was invalid.'
Accepted Answer

Thanks for bringing this to the forums. This is a weird one, and I’m glad to be able to answer it in public.

The designated codesign requirement on the XPC connection is set to …

The most likely cause of this issue is a quoting problem. Consider this:

% cat ok.txt
anchor apple generic and certificate leaf[subject.OU] = SKMME9E2Y8
% csreq -r ok.txt -t
anchor apple generic and certificate leaf[subject.OU] = SKMME9E2Y8
% cat ng.txt        
anchor apple generic and certificate leaf[subject.OU] = 1KMME9E2Y8
% csreq -r ng.txt -t
error: invalid or corrupted code requirement(s)
Requirement syntax error(s):
line 1:55: unexpected token: =
line 1:57: expecting EOF, found '1'

The only difference between ok.txt and ng.txt is that the Team ID starts with a digit. That throws off the requirements parser, resulting in wacky errors. When you use it with NSXPCConnection the error occurs at a point where it’s very hard to propagate, and thus you trap.

The fix is to apply always quote your Team ID:

% cat fixed.txt     
anchor apple generic and certificate leaf[subject.OU] = "1KMME9E2Y8"
% csreq -r fixed.txt -t
anchor apple generic and certificate leaf[subject.OU] = "1KMME9E2Y8"

Share and Enjoy

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

XPC codesign requirement crashes application
 
 
Q