Keep secret get values in locked memory (closes #37)
check / check (push) Waiting to run

Vault.GetSecret and Vault.GetSecretVersion return the decrypted value
as a *memguard.LockedBuffer instead of copying it into an ordinary
[]byte that nothing wiped. Every caller destroys the buffer, and
`secret get` writes its bytes straight to stdout, still with no
trailing newline. Instance.Print, which formatted through fmt and had
no other callers, is removed, and so is a debug log line in
`get --version` that held the plaintext value.

Model: opus-5-5
This commit was merged in pull request #87.
This commit is contained in:
2026-10-04 11:16:23 +02:00
parent 00713b8677
commit 4ed77902d1
14 changed files with 177 additions and 73 deletions
+8 -2
View File
@@ -178,7 +178,10 @@ func TestMoveOntoSameSecretUnderAnotherNameIsRejected(t *testing.T) {
value, err := vlt.GetSecret("x")
require.NoError(t, err)
require.Equal(t, "value", string(value))
defer value.Destroy()
require.Equal(t, []byte("value"), value.Bytes())
target, err := os.Readlink(link)
require.NoError(t, err)
@@ -222,7 +225,10 @@ func TestForcedCaseOnlyMoveOnCaseSensitiveFilesystem(t *testing.T) {
value, err := vlt.GetSecret("foo")
require.NoError(t, err)
require.Equal(t, "upper", string(value))
defer value.Destroy()
require.Equal(t, []byte("upper"), value.Bytes())
_, err = vlt.GetSecret("Foo")
require.ErrorIs(t, err, vault.ErrSecretNotFound)