H-L06: fix(contracts/ChannelHub): remove payable from methods, clarify in create#666
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR strengthens ETH value handling in the ChannelHub contract by enforcing stricter validation rules. It adds a check in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
H-H01: fix(contracts): disallow challenge with CLOSE or FIN_MIG intents (#631) H-M01: fix(contracts/ChannelHub): remove transferred amount check (#636) fix(contracts/ChannelHub): allow unblocking escrow ops after migration (#637) M-C01: feat(contracts): add token check between states (#639) H-L03: fix(contracts/ChannelHub): skip disputed escrow during purge (#640) M-H04: feat(contracts/ChannelHub): purge during escrow challenge finalization, count both skip and purge (#641) M-M02: fix(contracts): require zero allocs on close (#643) M-C02: fix(rpc/core): apply finalize escrow deposit correctly (#644) H-L02: fix(contracts/ChannelHub): revert on withdrawFromVault failure (#651) M-H03: fix(clearnode): log correct fields on failure (#647) M-C03: fix(pkg/core): disallow negative amount transitions (#645) H-L01: fix(contracts/ChannelHub): add CH address to prevent val addition replay (#650) M-H06(clearnode): restrict max channel challenge duration (#654) M-M03(clearnode): revert EscrowLock on insufficient home user balance (#655) M-M04(clearnode): support default signer even if it is not approved (#656) M-M05(clearnode): require correct intent on FinalizeEscrowWithdrawal (#657) M-M09: reject asset decimals exceeding its token's decimals (#659) M-L01: return correct errors during state advancement validation (#660) M-L03: limit number of related ids per session key state (#662) M-I02: normalize input hex addresses (#663) M-H01: feat(contracts/ChannelHub): restrict to one node (#649) M-H07: fix(contracts/ChannelHub): emit stored, not arbitrary candidate state (#664) M-I01: feat(contracts/ChannelHub): remove updateLastState flag (#665) H-L06: fix(contracts/ChannelHub): remove payable from methods, clarify in create (#666) H-L09: feat(contracts/ChannelEngine): add non-home migration version check (#669) YNU-839: fix blockchain listener lifecycle (#658) M-H09: use channel signer for all channel state node sigs (#667) H-L07: fix(contracts/ChannelHub): restrict createChannel to non-existing channels (#668) H-I02: docs(contracts): add a note that rebasing tokens are not supported (#670) H-I03: fix(contracts/ChannelHub): use CIE pattern in depositToHub (#671) M-H11: revert empty signatures on quorum verification (#672) M-H11: reject issuance of receiver state during escrow ops (#674) H-I01: docs(contracts): note that fee-on-transfer tokens are not supported (#675) M-L04: docs: mention liquidity monitoring (#677) fix(contracts/ChannelHub): fix initialize escrow deposit dos (#679) M-H08: enforce strict transition ordering after MutualLock and EscrowLock (#680) fix: run forge fmt (#681) M-L05: docs(contracts): document native token deposits (#685) fix(clearnode): resolve a set of audit findings (#686) M-H13: feat(contract): add validateChallengeSignature, revert in SK validator (#688)
Description
The functions
withdrawFromChannel(...),checkpointChannel(...), andcreateChannel(...)are marked payable but fail to validatemsg.valuefor operations that should never accept ETH.Specifically:
withdrawFromChannel(...)only acceptsWITHDRAWintent, which always has userFundsDelta < 0 (funds flowing OUT to user), yet is marked payable;checkpointChannel(...)only acceptsOPERATEintent, which always hasuserFundsDelta = 0(no user fund movement), yet is marked payable;createChannel(...)accepts multiple intents (DEPOSIT,WITHDRAW,OPERATE) but only validatesmsg.valueinside_pullFunds(...), which is only called whenuserFundsDelta > 0. ForWITHDRAW(userFundsDelta < 0) andOPERATE(userFundsDelta = 0) intents,msg.valueis never validated.Any ETH sent with these non-deposit operations is added to the contract balance, but not tracked in any accounting variable (
_nodeBalances,lockedFunds, or_reclaims), making it permanently stuck with no recovery mechanism.Impact
This is a fail-unsafe design where the protocol silently accepts invalid input instead of rejecting it. The payable modifier on
withdrawFromChannel(..)andcheckpointChannel(..)creates a misleading interface that suggests these functions can accept ETH when they logically never should. Users who send ETH with these operations (whether through direct calls, contract integration bugs, SDK errors, or UI mistakes) will permanently lose those funds. While this requires user error to trigger and provides no direct benefit to attackers, it represents a protocol design flaw where the declared interface (payable) doesn't match the actual behavior (never processes ETH).Summary by CodeRabbit
Bug Fixes
Tests