From ed09c32ecd0ee6c59d45997f1e0da03158ac46ac Mon Sep 17 00:00:00 2001 From: Jeremy Letang Date: Tue, 17 Sep 2024 11:38:44 +0200 Subject: [PATCH] feat: add validation when loading tendermint pubkey Signed-off-by: Jeremy Letang --- cmd/vega/commands/nodewallet/import.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/vega/commands/nodewallet/import.go b/cmd/vega/commands/nodewallet/import.go index 11d9a74e9ad..241507d2de4 100644 --- a/cmd/vega/commands/nodewallet/import.go +++ b/cmd/vega/commands/nodewallet/import.go @@ -16,6 +16,7 @@ package nodewallet import ( + "encoding/base64" "encoding/json" "errors" "fmt" @@ -137,6 +138,12 @@ func (opts *importCmd) Execute(_ []string) error { } } + // validate the key is base64 + _, err := base64.StdEncoding.DecodeString(tendermintPubkey) + if err != nil { + return fmt.Errorf("tendermint pubkey must be base64 encoded: %w", err) + } + data, err = nodewallets.ImportTendermintPubkey(vegaPaths, registryPass, tendermintPubkey, opts.Force) if err != nil { return fmt.Errorf("couldn't import Tendermint pubkey: %w", err)