- Notifications
You must be signed in to change notification settings - Fork3
fix: unquarantine dylib after download#38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Merged
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
MemberAuthor
ethanndickson commentedFeb 10, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This stack of pull requests is managed byGraphite. Learn more aboutstacking. |
d434e77
to024d7e3
CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
ThomasK33 approved these changesFeb 11, 2025
2bfe5bd
intomain 4 checks passed
Uh oh!
There was an error while loading.Please reload this page.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading.Please reload this page.
When building Coder Desktop for distribution for the first time, and running the app on a device with System Integrity Protection, we hit a bit of a roadblock:
As a result, the CoderVPN
.dylib
downloaded from the Coder deployment has thecom.apple.quarantine
xattr set, prompting Gatekeeper to check it. Presumably because the.dylib
isn't notarized, it gets blocked. This wasn't noticed during earlier prototyping as the file was never created within the System Extension sandbox, and so it never had the xattr.Unfortunately, System Network Extensionsmust run in a sandbox. I was also unable to abuse the
com.apple.security.files.user-selected.executable
entitlement to remove the quarantinexattr
from the file - all signs point to theuser-selected
part of the entitlement being very much crucial.Fortunately, we're not required to run the application itself sandboxed. When not sandboxed, an app is able to remove the quarantine xattr.
Of note here is that our System Network Extensions runs as
root
, whilst the applications runs as the logged-in user. This means there is no overlap in files writable by both the Network Extension, and the app[1].Given this, one thing I explored was if we could somehow notarize the
.dylib
, and have Gatekeeper use that notarization ticket to remove the quarantine. Unfortunately, notarizing the dylib alone (or within a framework bundle) had no effect when attempting to open the.dylib
on an internet-connected computer. Furthermore, there's no way to staple a notarization ticket to an unbundled.dylib
. Placing it into a container that can be stapled, such as a.dmg
or a.pkg
would make it unsbale by the sandboxed network extension - it cannot mount the disk image (which was the source of other sandbox escapes), and it cannot work with apkg
installer.I've sent in an Apple Support ticket asking if we've missed anything on this topic, and if there's potentially a better way, though from what I've read online that would appear unlikely - if we were able to execute the dylib without the user's explicit consent, it would constitute a sandbox escape CVE[2].
Employed Workaround
To deal with this issue, this PR removes the app sandbox from the Coder Desktop application, and uses a privileged
AppleScript
command to run/usr/bin/xattr -d com.apple.quarantine /path/to/dylib
- this is requested over XPC, and the Network Extension waits for the user to complete thesudo
prompt before continuing.Some downsides to this workaround are:
.dylib
is downloaded. (This is annoying for us at Coder - our Coder deployment updates on each push tocoder/coder/main
.)