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

contractcourt: match second-level outputs

Public commit record

What the developer wrote

Authored by yyforyongyu

73/100 · Adequate
contractcourt: match second-level outputs

A re-signed success transaction can move its committed output to another
index while preserving the HTLC input signature.

Match the indexed output against the sweep descriptor and return the
confirmed outpoint. Keep malformed resolver and notifier state distinct
from complete non-matches.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit adds logic to LND's contract court so that when an incoming HTLC is claimed on-chain via a re-signed success transaction, the resolver correctly identifies which output of that transaction it should sweep next. Previously, the code may have relied on a fixed output index; now it checks the actual output at the same index as the HTLC input and verifies it matches the expected sweep descriptor. The change is defensive and includes tests, but the commit message frames it as fixing a real correctness issue that could affect fund recovery.

Recommended action

Treat as a security-relevant correctness fix. Review the full call sites of matchSecondLevelOutput in subsequent commits to confirm the returned outpoint is used for sweeping and that no other resolver paths still assume a fixed second-level output index. Run the new unit tests and consider backporting to maintained release branches.

Security signals we found

01

Funds-recovery correctness issue in on-chain HTLC resolution

02

SIGHASH_SINGLE|ANYONECANPAY signature semantics allow output index movement

03

New validation matches actual second-level output against sweep descriptor

04

Malformed-state errors separated from non-match cases

05

Unit tests added for edge cases including decoy commitment descriptor

Risk score

Why this scored 57/100

Our methodology →
Potential impact 18/30
Exploitability 12/25
Stealth signal 10/15
Affected reach 8/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.