Skip to content

Commit 869ffc6

Browse files
rustyrussellsangbida
authored andcommitted
gossipd: don't accept malformed channel_announcements with mis-ordered node-ids.
See lightning/bolts#1333 Every reader of the gossip_store gets upset, and we get many errors if this happens :( Reported-by: https://github.com/NishantBansal2003 Changelog-Fixed: Protocol: We correctly reject invalidly ordered channel_announcement messages. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent db7dfcd commit 869ffc6

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

gossipd/gossmap_manage.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,20 @@ const char *gossmap_manage_channel_announcement(const tal_t *ctx,
648648
tal_hex(tmpctx, announce));
649649
}
650650

651+
/* BOLT-gossip-node-check #7:
652+
* The receiving node:
653+
*...
654+
* - if `node_id_1` is not lexicographically less than `node_id_2`:
655+
* - SHOULD send a `warning`.
656+
* - MAY close the connection.
657+
* - MUST ignore the message.
658+
*/
659+
if (!(node_id_cmp(&node_id_1, &node_id_2) < 0)) {
660+
return tal_fmt(ctx, "node_id_1 must be the lesser node id! 1=%s, 2=%s",
661+
fmt_node_id(tmpctx, &node_id_1),
662+
fmt_node_id(tmpctx, &node_id_2));
663+
}
664+
651665
/* If a prior txout lookup failed there is little point it trying
652666
* again. Just drop the announcement and walk away whistling.
653667
*

0 commit comments

Comments
 (0)