Skip to content

Age backend unconditionally encrypts secrets for all local identities, breaking store isolation #3392

Closed

Description

@nimser

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 once and --touch-policy always, and is tied to a core store (mounted, not root)
  • the low-security identity --pin-policy never, --touch-policy cached is tied to a common store and should not be allowed to decrypt core entries.

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

  1. Configure two age identities in ~/.config/gopass/age/identities (e.g., Identity A and Identity B).
  2. Create a sub-store configured to only use Identity A in its .age-recipients file.
  3. Insert a new secret into this sub-store.
  4. 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

  1. AnomalRoil commented on May 11, 2026

    @AnomalRoil
    Member

    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-recipients should be used.

    I'm leaning towards the latter.

  2. dominikschulz commented on Aug 20, 2026

    @dominikschulz
    Member

    I agree, I think only the entries in .age-recipients should be used.

  3. added a commit that references this issue on Aug 23, 2026
    c6a36f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    ⌂ 换网址