repository: reject key and config files that are too short (#21977)

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
This commit is contained in:
Arpit Jain authored and GitHub committed 2026-07-22 20:38:07 +00:00
1 parent d4088aa09b
commit 8baffc4027
4 files changed
+65

No files matched your search

+4
View File
@@ -98,6 +98,10 @@ func openKey(ctx context.Context, s *Repository, id restic.ID, password string)
}
// decrypt master keys
if len(k.Data) < crypto.CiphertextLength(0) {
return nil, errors.New("invalid key file, data too short")
}
nonce, ciphertext := k.Data[:k.user.NonceSize()], k.Data[k.user.NonceSize():]
buf, err := k.user.Open(nil, nonce, ciphertext, nil)
if err != nil {