-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDK can't settle if partner closes with outdated balanceHash #1607
Comments
So the solution to this issue would be to store all the balance proofs ever received for a channel? |
Yes, and search for right values (amounts, locksroot) when settling, or else settleChannel tx will fail. |
So being in |
Yes, but that's valid for the whole state anyway. All transfers and past channels are also kept there. The state is composed only of simple objects anyway, so I don't see it being relevant for some time, but you brought a valid point. Could you create an issue so we can evaluate risks and options about it? Thank you |
Sure :) |
I think we actually don't need to change state schema. We can simply iterate over the past transfers, and check the respective balanceProofs, as the info is already there. For partner's balanceHash mismatch, iterate over |
That sounds more reasonable, especially if we already have all the data in the state. |
This is not expected on normal usage, but can be considered an attack vector from a malicious partner.
Upon closing a channel, partner needs to provide his perspective of the latest balanceProof we sent to them. We do the same for their balanceProof upon
updateNonClosingBalanceProof
on detecting their closing (if we're online) or MS stepping in. On settle though, the settling part needs to provide values (transferredAmount
,lockedAmount
,locksroot
) which matches the hash sent by both sides (see raiden-network/raiden-contracts#1370 (comment)).Since we currently only store our latest balanceProof (and theirs, but it doesn't matter here, since we called from our perspective), if they close with any past or zero balanceHash from us and don't settle, our SDK won't be able to settle and our deposit will be stuck in the channel forever.
Theoretically, a knowledgeable user can rebuild the matching balanceProof from transfers history and settle, but SDK doesn't do that currently. Notice the attacker can't force a random balanceHash to prevent us from settling ever again, as balanceHash and additionalHash are part of the signature, so they can only close with data we explicitly signed and sent to them.
The fix is to store all balanceProofs (both sent and received) on
ChannelEnd
, and look (backwards) for the matching balanceHash, and send these data on settle call. Optionally, we could have each end's balanceProof(s's list) dynamically [re]built fromTransferState
, as a view of it, instead of persisted on channel state.Steps to Reproduce
Expected Result
Actual Result
settling
state, and trying to settle it throws an error on on-chain transactionThe text was updated successfully, but these errors were encountered: