Hi,
Our project is a MacOS SwiftUI GUI application that bundles a System Network Extension, signed with a Developer ID certificate for distribution outside of the app store. The system network extension is used to write a packet tunnel provider. The signing of the app & network extension is handled by XCode (v16.0.0), we do not run codesign ourselves. We have no issues with XPC or the system network extension during normal usage, nor when the application is installed on a user's device for the first time. The problem only arises when the user upgrades the application. I have experienced this issue myself, as have our users. It's been reported on Apple Silicon macbooks running at least macOS 15.3.2.
Much like the SimpleFirewall
example (which we used as a reference), we use XPC for basic communication of state between the app and NE. These XPC connections stop working when the user installs a new version of the app, with OS logs from the process indicating that the connection is immediately invalidated. Subsequent connection attempts are also immediately invalidated. Toggling the VPN in system settings (or via the app) does not resolve the problem, nor does restarting the app, nor does deleting and reinstalling the app, nor does restarting the device.
The only reliable workaround is to delete the system extension in Login Items & Extensions, under Network Extensions. No device restart is necessary to garbage collect the old extension - once the extension is reapproved by the user, the XPC issue resolves itself.
This would be an acceptable workaround were it possible to automate the deleting of the system extension, but that appears deliberately not possible, and requiring our users to do this each time they update is unreasonable.
When the upgraded app is opened for the first time, the OSSystemExtensionRequest
request is sent, and the outcome is that the previously installed system network extension is replaced, as both the CFBundleVersion
and CFBundleShortVersionString
differ. When this issue is encountered, the output of systemextensionsctl list
shows the later version is installed and activated.
I've been able to reproduce this bug on my personal laptop, with SIP on and systemextensionsctl developer off
, but on my work laptop with SIP off and systemextensionsctl developer on
(where the network extension is replaced on each activation request, instead of only when the version strings differ), I do not encounter this issue, which leads me to believe it has something to do with the notarization process. We notarize the pkg using xcrun notarytool
, and then staple to the pkg.
This is actually the same issue described in:
https://developer.apple.com/forums/thread/711713
https://developer.apple.com/forums/thread/667597
https://developer.apple.com/forums/thread/742992
https://developer.apple.com/forums/thread/728063
but it's been a while since any of these threads were updated, and we've made attempts to address it off the suggestions in the threads to no avail.
Those suggestions are:
- Switching to a .pkg installer from a .dmg
- As part of the .pkg preinstall, doing all of the following: Stopping the VPN (scutil --nc stop), shutting down the app (using osascript 'quit app id'), and deleting the app (which claims to delete the network extension, but not the approval in Login Items & Extensions remains??), by running
rm -rf
on the bundle in /Applications - As part of the .pkg postinstall: Forcing macOS to ingest the App bundle's notarization ticket using spctl --assess.
- Ensuring
NSXPCListener.resume()
is called afterautoreleasepool { NEProvider.startSystemExtensionMode() }
(mentioned in a forum thread above as a fix, did not help.)
One thing I'm particularly interested in is the outcome of this feedback assistant ticket, as I can't view it: FB11086599. It was shared on this forum in the first thread above, and supposedly describes the same issue. I almost find it hard to believe that this issue has been around for this many years without a workaround (there's system network extension apps out there that appear to work fine when updating, are they not using XPC?), so I wonder if there's a fix described in that FB ticket.
Since I can't view that above feedback ticket, I've created my own: FB17032197