Repository navigation
add test reproducing the diverted-funding-output vout bug - #192
Merged
Merged
Conversation
_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.
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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.