On macOS, keychain-auth listens on a Unix domain socket and uses theDocumentation Index
Fetch the complete documentation index at: https://theseventeen-2abbdf80.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
LOCAL_PEERPID kernel option to retrieve the true PID of every connecting process. It resolves that PID to an executable path using proc_pidpath, computes a SHA-256 hash of the binary, and checks it against your approved policy before touching Apple Keychain Services on your behalf.
The problem: macOS prompt fatigue
macOS SecurityAgent is designed for signed GUI application bundles. Command-line tools are often compiled locally, run inside virtual environments, or distributed unsigned, so macOS cannot uniquely identify them. The result is a constant stream of dialogs: “your-cli wants to use your keychain. Enter your password.” Over time, users click Always Allow out of frustration. Once clicked, macOS grants access to that keychain item to any command-line invocation — completely bypassing the boundary the dialog was meant to create. keychain-auth eliminates the prompt cycle. Your approved CLI tools connect to the daemon silently; the daemon handles the single, stable entry in Apple Keychain under its own service namespace, and SecurityAgent prompts you only once (if at all) to grant the daemon itself access.Socket path
The daemon listens on a Unix domain socket in your macOS user Library:0600 permissions so only your user account can connect to it.
Kernel-level process verification
When a client connects, the daemon callsGetsockoptInt with the LOCAL_PEERPID socket option on the SOL_LOCAL level. This retrieves the PID directly from the kernel — the connecting process has no way to forge it.
With the verified PID in hand, the daemon calls proc_pidpath to resolve the absolute path of the running executable on disk. It then reads the binary file and computes a SHA-256 hash. Because macOS locks running executables from in-place modification (ETXTBSY), the hash of a running binary reflects exactly what you approved.
Code signature context
GUI applications on macOS carry code signatures that SecurityAgent uses to identify them. CLI tools typically do not. keychain-auth provides an equivalent guarantee for CLI tools through its hash-based approval model:- The first time an unregistered binary connects, the daemon rejects it gracefully and queues it in
~/Library/Application Support/keychain-auth/pending.json. - You inspect the queue with
keychain-auth list-pendingand approve the binary by hash withkeychain-auth approve <hash>. - From that point forward, that exact binary — verified by its SHA-256 hash — is the only version that can access the secrets you have scoped to it.
Apple Keychain Services backend
The daemon reads and writes secrets through Apple Keychain Services. Secrets are stored as generic password items, scoped to the service namespace you configure. The daemon manages all Keychain API calls on your behalf — you interact only through the keychain-auth socket protocol. The audit log at~/Library/Logs/keychain-auth/audit.log records every approved and denied access attempt, including the binary path, hash, and targeted secret names. Plaintext values are never written to the log.
The O_CLOEXEC requirement
If your application forks a child process after connecting to the daemon, the child inherits all open file descriptors by default — including the live, already-authenticated socket. That child could then send requests to the daemon as if it were your trusted application.
To prevent this, always open the socket with SOCK_CLOEXEC:
exec() call, blocking the attack entirely. The official keychain-auth SDK handles this for you automatically.
Quick-start
~/Library/Application Support/keychain-auth/config.json. The audit log is written to ~/Library/Logs/keychain-auth/audit.log.