From 288b0567b158fdec18a46a695200098fadf96383 Mon Sep 17 00:00:00 2001 From: Brian Kassouf Date: Wed, 16 Nov 2022 09:53:22 -0800 Subject: [PATCH] Barrier: Fix potential locking issue (#17944) * Barrier: Fix potential locking issue * add changelog --- changelog/17944.txt | 3 +++ vault/barrier_aes_gcm.go | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 changelog/17944.txt diff --git a/changelog/17944.txt b/changelog/17944.txt new file mode 100644 index 000000000..2ce17ca36 --- /dev/null +++ b/changelog/17944.txt @@ -0,0 +1,3 @@ +```release-note:bug +core: Fix potential deadlock if barrier ciphertext is less than 4 bytes. +``` diff --git a/vault/barrier_aes_gcm.go b/vault/barrier_aes_gcm.go index a531bacd4..b6f6d96df 100644 --- a/vault/barrier_aes_gcm.go +++ b/vault/barrier_aes_gcm.go @@ -1069,11 +1069,13 @@ func (b *AESGCMBarrier) Decrypt(_ context.Context, key string, ciphertext []byte } if len(ciphertext) == 0 { + b.l.RUnlock() return nil, fmt.Errorf("empty ciphertext") } // Verify the term if len(ciphertext) < 4 { + b.l.RUnlock() return nil, fmt.Errorf("invalid ciphertext term") } term := binary.BigEndian.Uint32(ciphertext[:4])