Reject out-of-range push_asset_amount in handle_funding - #33
Open
0xaudron wants to merge 1 commit into
Open
Conversation
Member
|
Thank you! Could you add a test in RLN to prove the attack? |
Author
|
Sure, btw would you prefer
|
Member
|
Since we have a long-term plan to drop the LDK fork (by introducing the required flexibility upstream), we do not run or write unit tests there. So please write an integration test in RLN. |
Author
|
Opened a pull request in RLN: RGB-Tools/rgb-lightning-node#138 |
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.
handle_fundingcomputes the acceptor side RGB split asremote_rgb_amount = channel_rgb_amount - push_amount, wherepush_amountcomes from the counterparty suppliedpush_asset_amountinopen_channel. The value is not validated againstchannel_rgb_amount.When a peer sends
push_asset_amountgreater than the funded asset amount the subtraction underflows. Release builds have overflow checks off, so the value wraps. The wrappedremote_rgb_amountis then passed tocolor_psbt, which returnsInvalidColoringInfo, and the result is unwrapped. The panic poisons the channel manager mutex and the node stops serving channel operations until it is restarted.The initiator side already rejects this in
rgb-lightning-nodebefore sending but the acceptor cannot rely on the counterparty running that check.Fix: Reject
push_amount > channel_rgb_amountinhandle_fundingbefore the subtraction, using the existingChannelError::closepath.