Skip to content

Commit d731979

Browse files
erickcestarirustyrussell
authored andcommitted
common/bolt11: enforce minimum witness program length for fallback addresses
BIP-141 specifies that a witness program must be between 2 and 40 bytes in length. In our fallback address parsing, we were already checking the upper bound, but missing the lower bound check. This commit adds validation to ensure fallback address witness programs are at least 2 bytes long, bringing our implementation in line with the spec and other implementations like rust-lightning. Changelog-Fixed: Enforced minimum witness program length of 2 bytes for fallback addresses to comply with BIP-141 and prevent invalid decodings.
1 parent d3c7d2c commit d731979

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

common/bolt11.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ static const char *decode_f(struct bolt11 *b11,
420420
"f: witness v1 bad length %zu",
421421
tal_count(f));
422422
}
423-
if (tal_count(f) > 40) {
423+
if (tal_count(f) > 40 || tal_count(f) < 2) {
424424
return tal_fmt(b11,
425425
"f: witness v%"PRIu64" bad length %zu",
426426
version,

0 commit comments

Comments
 (0)