Skip to content

Commit 49b4148

Browse files
arimxyerclaude
andcommitted
fix: use consistent vaultID for audit key storage and retrieval
Bug: Audit HMAC verification was failing because vaultID was inconsistent: - During init: vaultID = filepath.Base(vaultDir) (e.g., ".pass-cli") - During verify: vaultID = filepath.Abs(vaultPath) (e.g., "C:\Users\...\vault.enc") This caused GetOrCreateAuditKey() to create a new key during verification instead of retrieving the original, making all HMAC signatures invalid. Fix: Updated getVaultID() in cmd/helpers.go to use directory name (filepath.Base(filepath.Dir(vaultPath))) to match initialization behavior. Now audit key is consistently stored/retrieved with same vaultID. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1489f46 commit 49b4148

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

cmd/helpers.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,12 @@ func getAuditLogPath(vaultPath string) string {
9494
}
9595

9696
// T072: getVaultID returns a unique identifier for the vault (used for keychain)
97-
// Uses vault file path as unique identifier
97+
// Uses directory name as vault ID to match initialization behavior in firstrun.go
9898
func getVaultID(vaultPath string) string {
99-
// Use absolute path as vault ID for keychain
100-
absPath, err := filepath.Abs(vaultPath)
101-
if err != nil {
102-
return vaultPath // Fallback to relative path
103-
}
104-
return absPath
99+
// Use directory name as vault ID to match how it's set during initialization
100+
// This ensures audit key retrieval matches how it was stored
101+
vaultDir := filepath.Dir(vaultPath)
102+
return filepath.Base(vaultDir)
105103
}
106104

107105
// getKeychainUnavailableMessage returns platform-specific error message when keychain is unavailable

0 commit comments

Comments
 (0)