AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 42 Bitcoin

lnwallet: add and use AuxHtlcValidator to lightning channel

Public commit record

What the developer wrote

Authored by George Tsagkarelis

73/100 · Adequate
lnwallet: add and use AuxHtlcValidator to lightning channel

Previously we'd perform aux bandwidth checks during path finding. This
could lead to issues where multiple HTLCs where querying the same
bandwidth but were not accounting for each other before being added to
the commitment log. We now add a new validator function that will serve
as the last point of checks before adding the HTLC to the commitment.

During path finding HTLCs could query channel bandwidth asynchronously.
At this new call site all HTLCs that are about to be added to the
channel have been organised in sequence, so it's safe to query bandwdith
again at this point as we're getting the actual up-to-date values.

We remove the aux bandwidth check from the helper canSendHtlc, which was
called from CheckHTLCTransit and CheckHTLCForward (both are methods of
the htlcswitch).

For forwards we now fail at the link level, following the introduction
of the AuxHtlcValidator.

For payments, we now may fail either at the pathfinding level, or at the
link level. The htlcswitch may no longer fail for aux bandwidth checks.

Finally, when fetching the latest htlc view (for bandwidth checks during
pathfinding) we'd silently set the nextHeight of the view to the default
zero value. We now make sure to set it to the correct nextHeight value.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit changes how Lightning Network channels check whether a special 'custom' payment (HTLC) can be added. Previously, bandwidth checks for these custom payments happened earlier, while routes were still being planned, and multiple payments could look at the same balance without knowing about each other. The new code moves the final check to the moment just before the payment is committed to the channel, using the most up-to-date balance and a corrected view of pending payments. It also fixes a bug where a height counter used in these checks was being left at zero. The change is defensive and aimed at preventing inconsistent or over-committed custom channel states rather than a classic remote exploit.

Recommended action

Review the corresponding htlcswitch changes that remove canSendHtlc aux checks to ensure no bypass remains, and verify that all custom channel implementations (e.g., tapd-assets traffic shaper) register an AuxHtlcValidator. Consider regression tests for concurrent HTLC additions and NextHeight correctness.

Security signals we found

01

Moved aux bandwidth validation to a single, synchronous final check before commitment

02

Fixed NextHeight being silently left at zero in FetchLatestAuxHTLCView

03

Switched HTLC view to use remote ACKed index from signed local commitment tail for consistency

04

Removed earlier aux bandwidth checks from htlcswitch forwarding/payment paths

05

Validator runs only after standard Lightning commitment sanity checks

Risk score

Why this scored 42/100

Our methodology →
Potential impact 12/30
Exploitability 8/25
Stealth signal 7/15
Affected reach 6/15
Confidence 6/10
Evidence quality 3/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.