commit b9d14a4a361f734da28b9a388e5e26f1b1266ae3
parent f1e0baad57cb31146d3879ad3ff0eb055c624b9a
Author: Jared Tobin <jared@jtobin.io>
Date: Sat, 10 Oct 2026 13:21:27 +0400
lib: fail validateReplyChannelRange on undecodable data
validateReplyChannelRange returned Right () when it could not decode
encoded_short_ids, so zlib-encoded (type 1, which MUST NOT be used),
unknown-encoding and truncated data all passed.
It now fails with the new ValidateScidEncoding.
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/Lightning/Protocol/BOLT7/Validate.hs b/lib/Lightning/Protocol/BOLT7/Validate.hs
@@ -42,6 +42,7 @@ data ValidationError
| ValidateBlockOverflow -- ^ first_blocknum + number_of_blocks overflow
| ValidateScidNotAscending -- ^ short_channel_ids not in ascending order
| ValidateMultipleDns -- ^ more than one DNS hostname address
+ | ValidateScidEncoding -- ^ encoded_short_ids cannot be decoded
deriving (Eq, Show, Generic)
instance NFData ValidationError
@@ -117,11 +118,14 @@ validateQueryChannelRange msg = do
--
-- Checks:
--
+-- * Encoded short_channel_ids decode: the encoding type is 0
+-- (uncompressed; type 1, zlib, MUST NOT be used) and the data is
+-- a whole number of short_channel_ids
-- * Encoded short_channel_ids are in ascending order
validateReplyChannelRange :: ReplyChannelRange -> Either ValidationError ()
validateReplyChannelRange msg =
case decodeShortChannelIdList (replyRangeData msg) of
- Left _ -> Right () -- Can't decode, skip validation
+ Left _ -> Left ValidateScidEncoding
Right scids -> checkAscending scids
where
checkAscending [] = Right ()