Repository navigation
Description
Description
When using the age crypto backend with multiple identities in ~/.config/gopass/age/identities, gopass unconditionally appends all local identities to the recipient list during encryption.
This may be intended to avoid a user locking themselves out but, it breaks the isolation of different password stores.
In my scenario, I have 2 identities with different security models/needs:
- The high-security identity is generated with
age-plugin-yubikey's--pin-policy onceand--touch-policy always, and is tied to acorestore (mounted, notroot) - the low-security identity
--pin-policy never,--touch-policy cachedis tied to acommonstore and should not be allowed to decryptcoreentries.
What happens is that any secret encrypted in the core store will be inadvertently encrypted for the low-security identity as well, weakening the security of the core store.
Note: this issue has nothing to do with yubikeys, it applies to any pair of age keys.
Steps to Reproduce
- Configure two
ageidentities in~/.config/gopass/age/identities(e.g., Identity A and Identity B). - Create a sub-store configured to only use Identity A in its
.age-recipientsfile. - Insert a new secret into this sub-store.
- Inspect the resulting encrypted file or observe decryption behavior.
Expected Behavior
The secret should only be encrypted for the specific recipients defined in the store's .age-recipients file (Identity A).
Actual Behavior
The secret is encrypted for the recipients in .age-recipients PLUS every identity present in ~/.config/gopass/age/identities (Identity A AND Identity B). When decrypting, gopass may randomly select Identity B to decrypt the file (due to non-deterministic map iteration implementation), which results a unwanted increased exposure for the core store.
Root Cause
In internal/backend/crypto/age/encrypt.go, the Encrypt function unconditionally fetches all identity recipients and appends them to the store's configured recipients:
// internal/backend/crypto/age/encrypt.go
func (a *Age) Encrypt(ctx context.Context, plaintext []byte, recipients []string) ([]byte, error) {
// add our own public keys to the recipients to ensure we can decrypt it later. <= BUG we should not do this unconditionally !
idRecps, err := a.IdentityRecipients(ctx)
// ...
recp, err := a.parseRecipients(ctx, recipients)
// ...
// dedupe also order recipients so that native ones are first
recp = dedupe(append(recp, idRecps...))
return a.encrypt(plaintext, recp...)
}Suggested Fix
The inclusion of all local identities (idRecps) should not be unconditional. It should strictly respect the .age-recipients file of the sub-store. If fallback access is desired, it should be configurable via age.always-add-local-identities defaulting to false, or allow users to opt out somehow 🤷🏼 .
Environment
- OS: Linux Debian 13 Trixie
- gopass Version: 1.16.1
- Crypto Backend: age (using age-plugin-yubikey)
Activity
AnomalRoil commentedon May 11, 2026
Mhhh, I'm not sure whether this is a feature and should be done using a config key as you suggest, or if it's more simply a bug and the behaviour should be that only the recipients in
.age-recipientsshould be used.I'm leaning towards the latter.
dominikschulz commentedon Aug 20, 2026
I agree, I think only the entries in
.age-recipientsshould be used.fix(age): only encrypt for recipients in .age-recipients (gopasspw#3564)