Closed directionless closed 6 months ago
Testing running Kolide launcher as a LaunchAgent by putting .plist config in /Library/LaunchAgents
as well as ~/Library/LaunchAgents
. As we have discovered in the past, this lets us access the secure enclave. It also inherits the Full Disk Access of the .app if set. So we can access the TCC database.
However, it does not provide the sudo / root access we need for tables such as kolide_apple_silicon_security_policy
. I have not found any feasible path to getting a launch agent to run with as sudo.
Did a test where I set up a launch daemon (to make sure I was in the root ctx) that ran the following script:
the script is intended for testing purposes only
#!bin/bash
/bin/launchctl asuser 501 sudo --preserve-env -u jamespickett /usr/local/kolide-k2/bin/launcher --config=/Users/jamespickett/Documents/kolide-k2-test/k2device-preprod.kolide.com/launcher.flags
launch daemon plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>run.launcher</string>
<key>Program</key>
<string>/Users/jamespickett/Documents/repos/launcher-runner/runlauncher.sh</string>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/jamespickett/Documents/repos/launcher-runner/stderr.log</string>
<key>StandardOutPath</key>
<string>/Users/jamespickett/Documents/repos/launcher-runner/stdout.log</string>
</dict>
</plist>
this ran launcher and in this context launcher was able to:
access secure enclave
access privileged tables like apple_silicon_security_policy
Did a test on macos:
/bin/launchctl asuser 501 sudo --preserve-env -u Alice $test_binary_path
I was able to access the secure enclave as Alice (who never logged in)
Maybe important to note that the binary was signed with macos development keys, it's possible this will behave differently with a "properly" signed binary.
This is mostly long term research. I'm closing this issue, since it's not an active project. Parts of it survive in PRs
As we've developed Desktop, it has become clear that (at least on macOS) the platform expectation is that we run as a user specific launcher agent. This comes up in many ways:
And, with the shift to Device Trust, we have a path for working in user context. Namely, if you want access to resource, you need to run our agent.
Thus, it behooves us to understand whether we can run our agent entirely in user context. Or maybe just primarily. 🤷 Research needed. Initial questions: