BOLT 7 states in multiple places that gossip message signatures are to be verified over the actual message bytes. For example, for node_announcement:
The receiving node:
- if
signature is NOT a valid signature (using node_id of the double-SHA256 of the entire message following the signature field, including any future fields appended to the end):
- SHOULD send a
warning.
- MAY close the connection.
- MUST NOT process the message further.
But LND actually re-encodes messages through its own codec before verifying signatures, and for one particular field the round trip can change the underlying bytes:
features bitvectors are changed to minimal form
When this occurs, LND verifies signatures incorrectly and may reject gossip that other implementations accept, or vice versa.
Implications
While a spec-conforming node should never create gossip that triggers this bug, a buggy or malicious node could do it and cause LND's view of the LN network to diverge from other nodes' views.
A more concerning network isolation vector could arise if any implementation ever decides to ban peers that repeatedly send gossip with incorrect signatures. While no implementation does this currently, Eclair does have a TODO indicating the intention to do it in the future:
https://github.com/ACINQ/eclair/blob/2dda79468a8b69a2acf7962cdac63245f7cc3ee8/eclair-core/src/main/scala/fr/acinq/eclair/io/PeerConnection.scala#L459-L468
Reproducing
0001-Demonstrate-signature-verification-bug.patch
Discovery
This issue was surfaced while fuzzing node_announcements using Smite.
BOLT 7 states in multiple places that gossip message signatures are to be verified over the actual message bytes. For example, for
node_announcement:But LND actually re-encodes messages through its own codec before verifying signatures, and for one particular field the round trip can change the underlying bytes:
featuresbitvectors are changed to minimal formWhen this occurs, LND verifies signatures incorrectly and may reject gossip that other implementations accept, or vice versa.
Implications
While a spec-conforming node should never create gossip that triggers this bug, a buggy or malicious node could do it and cause LND's view of the LN network to diverge from other nodes' views.
A more concerning network isolation vector could arise if any implementation ever decides to ban peers that repeatedly send gossip with incorrect signatures. While no implementation does this currently, Eclair does have a TODO indicating the intention to do it in the future:
https://github.com/ACINQ/eclair/blob/2dda79468a8b69a2acf7962cdac63245f7cc3ee8/eclair-core/src/main/scala/fr/acinq/eclair/io/PeerConnection.scala#L459-L468
Reproducing
0001-Demonstrate-signature-verification-bug.patch
Discovery
This issue was surfaced while fuzzing
node_announcements using Smite.