Skip to content

add test reproducing the diverted-funding-output vout bug - #192

Merged
zoedberg merged 2 commits into
masterfrom
test/diverted-funding-vout-bypass
Nov 9, 2026
Merged

zoedberg merged 2 commits into
masterfrom
test/diverted-funding-vout-bypass

Conversation

@zoedberg

@zoedberg zoedberg commented Nov 9, 2026

Copy link
Copy Markdown
Member

No description provided.

_accept_transfer hardcodes funding_vout = 1 instead of using
msg.funding_output_index, so the acceptor validates the funding
consignment against vout 1 whatever output LDK treats as the funding
output.

A malicious funder seals a full channel's worth of assets, with the
static blinding, to its own address at vout 1 and leaves a single unit on
the real 2-of-2 funding output at vout 2. The acceptor reads the assets
off vout 1, credits the channel with all of them, and then panics the
moment it colors its first commitment: the funding output it spends holds
only the one unit. A remote peer can crash the node during an ordinary
channel open, and the crash is reachable before the funding TX is ever
broadcast.

The test asserts the correct outcome, so it fails until the acceptor
validates the consignment against the funding output LDK actually uses:
the victim must neither credit the channel with the assets sitting on the
funder's own output nor panic.

Two test-only hooks drive it: DIVERT_COLORED_FUNDING_ASSETS_ON_NODE
builds the diverted funding layout, and SKIP_COMMITMENT_COLORING_FOR_DIR
keeps the attacker's own node from panicking first. The latter is keyed on
the attacker's data dir, so a recorded panic can only be the victim's.
@zoedberg zoedberg self-assigned this Nov 9, 2026
Bumps rust-lightning to pass msg.funding_output_index into
handle_funding, instead of hardcoding vout 1, so the acceptor validates
the funding consignment on the outpoint the channel's commitments spend.

Makes the diverted_funding_assets test pass: the acceptor now credits
only the single unit actually on the funding output, instead of the full
channel amount the funder sealed to an output of its own, and no longer
panics while coloring its first commitment.
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.31%. Comparing base (8635741) to head (abac03d).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #192      +/-   ##
==========================================
+ Coverage   88.19%   88.31%   +0.11%     
==========================================
  Files          16       16              
  Lines        8838     8875      +37     
==========================================
+ Hits         7795     7838      +43     
+ Misses       1043     1037       -6     
Flag Coverage Δ
rust 88.31% <100.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zoedberg
zoedberg merged commit abac03d into master Nov 9, 2026
20 checks passed

This branch was successfully deployed

1 active deployment
github-pages — abac03df Deployed Nov 9, 2026 by zoedberg via deploy #41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant