Skip to content

fix(age-agent): redact sensitive protocol lines from debug logs - #3625

Merged
dominikschulz merged 1 commit into
gopasspw:masterfrom
yzx9:age-agent-redact-debug-log
Sep 29, 2026
Merged

dominikschulz merged 1 commit into
gopasspw:masterfrom
yzx9:age-agent-redact-debug-log

Conversation

@yzx9

@yzx9 yzx9 commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

The agent logged every received protocol line verbatim via debug.Log("received: %s", line). The identities command carries plaintext age private keys (bech32-encoded AGE-SECRET-KEY-1...) and the decrypt command carries the full base64 ciphertext, so enabling debug logging (GOPASS_DEBUG_LOG, inherited by the spawned agent) persisted key material to the debug log file.

Instead of logging the raw line up front, each command arm in the dispatch switch now logs its own redacted view, colocating the sensitivity judgment with the command semantics:

  • ping, status, lock, unlock, quit: log the verb
  • set-timeout: the timeout value is not sensitive, log it verbatim
  • identities: private keys are elided, only their count is logged
  • decrypt: ciphertext is elided, only its encoded size is logged (the relevant diagnostic for the scanner line-size limit, age: agent bufio.Scanner 64 KiB line limit silently drops large decrypt commands #3508)
  • unknown commands: the first token may itself be a mis-framed payload (e.g. a bare AGE-SECRET-KEY-1... line from a newline-separated identities send, see identitiesToString), so only a 12-char prefix — at most the constant key-type prefix, mirroring wrappedIdentity.SafeStr — and the line length are logged

The raw line is never logged under any configuration. A regression test covers the mis-framed identity line case.

Assisted-by: Claude-Code:GLM-5.3

The agent logged every received protocol line verbatim via
debug.Log("received: %s", line). The identities command carries
plaintext age private keys (bech32-encoded AGE-SECRET-KEY-1...) and
the decrypt command carries the full base64 ciphertext, so enabling
debug logging (GOPASS_DEBUG_LOG, inherited by the spawned agent)
persisted key material to the debug log file.

Instead of logging the raw line up front, each command arm in the
dispatch switch now logs its own redacted view, colocating the
sensitivity judgment with the command semantics:

  - ping, status, lock, unlock, quit: log the verb
  - set-timeout: the timeout value is not sensitive, log it verbatim
  - identities: private keys are elided, only their count is logged
  - decrypt: ciphertext is elided, only its encoded size is logged
    (the relevant diagnostic for the scanner line-size limit, gopasspw#3508)
  - unknown commands: the first token may itself be a mis-framed
    payload (e.g. a bare AGE-SECRET-KEY-1... line from a
    newline-separated identities send, see identitiesToString), so
    only a 12-char prefix — at most the constant key-type prefix,
    mirroring wrappedIdentity.SafeStr — and the line length are
    logged

The raw line is never logged under any configuration. A regression
test covers the mis-framed identity line case.

Assisted-by: Claude-Code:GLM-5.3
Signed-off-by: Zexin Yuan <git@yzx9.xyz>
}
case "identities":
// the arguments are private key material: log only their count
debug.Log("received: identities [%d ids]", len(args))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, but we could also include the actual identities using out.Secret. Those values are only printed if explicitly requested.

@dominikschulz
dominikschulz merged commit e4927c6 into gopasspw:master Sep 29, 2026
10 checks passed
@yzx9
yzx9 deleted the age-agent-redact-debug-log branch September 30, 2026 04:23
yzx9 added a commit to yzx9/gopass that referenced this pull request Sep 30, 2026
Follow-up to gopasspw#3625 implementing the review suggestion: each received
identity is now logged wrapped in out.Secret, so the debug log shows
"(elided)" by default and the actual value only when
GOPASS_DEBUG_LOG_SECRETS is set — matching the existing pattern in
recipients.go. The decrypt command still logs only its encoded size.

Assisted-by: Claude-Code:GLM-5.3
yzx9 added a commit to yzx9/gopass that referenced this pull request Sep 30, 2026
Follow-up to gopasspw#3625 implementing the review suggestion: each received
identity is now logged wrapped in out.Secret, so the debug log shows
"(elided)" by default and the actual value only when
GOPASS_DEBUG_LOG_SECRETS is set — matching the existing pattern in
recipients.go. The decrypt command still logs only its encoded size.

Signed-off-by: Zexin Yuan <git@yzx9.xyz>
Assisted-by: Claude-Code:GLM-5.3
dominikschulz pushed a commit that referenced this pull request Oct 1, 2026
Follow-up to #3625 implementing the review suggestion: each received
identity is now logged wrapped in out.Secret, so the debug log shows
"(elided)" by default and the actual value only when
GOPASS_DEBUG_LOG_SECRETS is set — matching the existing pattern in
recipients.go. The decrypt command still logs only its encoded size.


Assisted-by: Claude-Code:GLM-5.3

Signed-off-by: Zexin Yuan <git@yzx9.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址