LND fixes Lightning bug that could hide settled payments

LND developers patched a bug that could make settled Lightning payments disappear from a node’s records after a restart. The flaw surfaced when an update counter reached 65,536 entries.

Developers of LND, a widely used implementation of Bitcoin’s Lightning Network, fixed a bug that could cause nodes to restore incomplete records of settled payments after a restart.

LND developers released versions v0.21.8-beta and v0.20.8-beta on Nov. 11. The issue involved how the software saved and restored updates to payment channels. Lightning lets users send Bitcoin through channels without recording each payment directly on the Bitcoin blockchain.

The affected counter tracked acknowledged updates received from a connected Lightning peer. LND stored the counter as a 16-bit unsigned integer, which can hold values from zero to 65,535. When the update list reached 65,536 entries, the counter reset to zero even though LND continued writing the updates to disk.

After a restart, the node could interpret the zero as an empty list and fail to restore a previously settled hashed timelock contract, or HTLC. HTLCs are conditional payments used to transfer funds between Lightning channels. The missing record could leave the two channel participants with different records of completed payments and amounts owed.

LND maintainer Olaoluwa Osuntokun, who uses the name Roasbeef, described the issue as involving acknowledged updates from a connected peer. Developers later found that a peer could increase the stored update list by repeatedly sending fee updates and commitment signatures while withholding a required revocation message.

An LND collaborator reproduced the behavior in a unit test that created 201 stored updates after 200 rounds of messages. The records remained after reconnecting, so repeated disconnections and reconnections would not necessarily clear the list before it reached the limit.

The patch rejects oversized update logs before they can advance channel state or be written to storage. Newer LND versions can also recover complete records created by older versions when the records pass validation. Incomplete or malformed records are rejected.

The fix was merged into LND’s main development branch on Nov. 5, before its inclusion in the two releases issued on Nov. 11. The available disclosures do not establish that the bug was exploited on live nodes or that it caused financial losses.

Articles by this author