From cb722a3cea16a04844c83e56fd6deaa1f0dc0a7e Mon Sep 17 00:00:00 2001 From: brunoerg Date: Tue, 31 Dec 2024 11:16:42 -0300 Subject: [PATCH] descriptor: check whitespace in ParsePubkeyInner Due to Base58, keys with whitespace at the beginning or at the end are successfully parsed. This commit adds a check into `ParsePubkeyInner` to verify whether if the first or last char of the key is a space. --- src/script/descriptor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 499af47ee55..79959dbf4c5 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -1509,6 +1509,10 @@ std::vector> ParsePubkeyInner(uint32_t key_exp_i error = "No key provided"; return {}; } + if (IsSpace(str.front()) || IsSpace(str.back())) { + error = strprintf("Key '%s' is invalid due to whitespace", str); + return {}; + } if (split.size() == 1) { if (IsHex(str)) { std::vector data = ParseHex(str);