Skip to content

Commit 5a5d26d

Browse files
committed
psbt: Require ECDSA signatures to be validly encoded
Needed for later validation of sighash types.
1 parent 53eb559 commit 5a5d26d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/psbt.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,11 @@ struct PSBTInput
520520
std::vector<unsigned char> sig;
521521
s >> sig;
522522

523+
// Check that the signature is validly encoded
524+
if (sig.empty() || !CheckSignatureEncoding(sig, SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_STRICTENC, nullptr)) {
525+
throw std::ios_base::failure("Signature is not a valid encoding");
526+
}
527+
523528
// Add to list
524529
partial_sigs.emplace(pubkey.GetID(), SigPair(pubkey, std::move(sig)));
525530
break;

0 commit comments

Comments
 (0)