Repository navigation
Conversation
The authentication prompt only said that age-plugin-se wanted to use a key, so it was easy to approve a request without knowing what it was. Before each key operation the plugin now sets the prompt text to three lines: - the key's name, looked up by its recipient in ~/.config/age-plugin-se/names (lines of "<recipient> <name>"), or a shortened recipient if the key has no name; - the names of up to five parent processes, outermost first, so you can see whether the request came from your own shell or from another program such as an AI agent; - an optional note from the caller, taken from AGE_SE_REASON. Facts the plugin looks up itself come first and the caller's note comes last. Line breaks, control characters and bidirectional overrides are removed from every part, so one part cannot pass itself off as another. This is meant to prevent approving by reflex, not to stop a deliberate attacker: any process that can read the identity file can use the Secure Enclave key directly and show any prompt it likes, and the names file and process names can be changed by the user's own processes. The README describes the names file and AGE_SE_REASON, and the new tests cover the names lookup, the cleaning of each part, and the order of the lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
Sign up for free
to 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.
Today the Touch ID prompt only says that age-plugin-se wants to use a key. When it pops up while a script or an AI agent is running, it's easy to approve it without knowing which key is being unlocked or who asked for it. This PR makes the prompt say which key, which programs asked, and optionally why, so that reflex approvals are less likely. It is not meant to stop a deliberate attacker; see the section on spoofing below.
This covers the same need as #18, which has gone quiet and now conflicts with
main. It takes a different approach to the concerns raised there: the facts the plugin can look up itself come first, and the caller's own text comes last.What the prompt shows
Before each key operation, the plugin sets the prompt text to up to three lines:
~/.config/age-plugin-se/names, with one<recipient> <name>per line. If the key isn't listed, the prompt shows a shortened recipient. The identity format doesn't change, so existing identity files keep working.AGE_SE_REASON. It is shown last and labelled as what the caller says.Line breaks, control characters and bidirectional overrides are removed from all three parts, so one part can't pass itself off as another.
On spoofing
Caller-supplied text alone can't be trusted, which is why it goes last. But nothing inside the plugin can make the prompt trustworthy against a process that is lying on purpose. The identity file holds the Secure Enclave key's wrapped data, and that data isn't tied to the plugin binary: a locally built, ad-hoc signed copy of the plugin uses keys created by the Homebrew build without any problem. So any program running as the user that can read the identity file can load the key itself, set any prompt text it likes, and name its executable
age-plugin-se, without going through the plugin at all. The real boundary is who can read the identity file.So the goal here is narrower: help an honest user catch mistakes, such as an agent reaching for the production key while its note says it is working on staging. The names file and process names can be changed by the user's own programs, and that's acceptable for this goal. The README section added here says so too.
If you'd rather take only part of this, for example only the key name, I'm happy to cut the PR down.
Technical details
Sources/AuthenticationReason.swift.Cryptogets asetAuthenticationReason(_:)method, which setslocalizedReasonon the sharedLAContext; the default implementation, used byDummyCrypto, does nothing.runIdentityV1calls it as soon as it knows which identity matches a stanza, before the key is used.$XDG_CONFIG_HOME/age-plugin-se/names, or from~/.config/age-plugin-se/namesif that variable isn't set. A key matches if itsage1se,age1tagorage1tagpqrecipient is listed.argv[0](read withKERN_PROCARGS2), falling back to the executable's file name.argv[0]comes first because some executables have uninformative file names; Claude Code's executable, for example, is named after its version number. The process lookup only runs on macOS; elsewhere the prompt has no "Requested by" line.make testandmake lintpass on macOS 26. Two jobs fail there for reasons unrelated to this change: the macOS 14 runner is no longer available (this also happens onmain), and the Alpine package step needs the signing key, which a fork doesn't have. I haven't tested a post-quantum key by hand.🤖 Generated with Claude Code