Closed c4-bot-1 closed 4 months ago
trust1995 marked the issue as satisfactory
trust1995 marked issue #44 as primary and marked this issue as a duplicate of 44
Hello trust1995, thanks for judging this. May I request for this finding #7 to be reconsidered as the primary issue/selected for report instead of #44 due to the following reasons?
The primary impact and PoC explained in #44 appears to be that Ether can be stolen from the contract after the contract amasses a large Ether balance:
"Consider a scenario where the Router's balance is 100e18 ethers."
However by invalidating findings such as #49, it has been established that the router should not hold Ether.
The mainnet Router also does not currently hold any Ether, so the chances of the Router gaining a substantial Ether balance appears slim (this is also why the issues in QA report #9 were raised as nothing more than low/QA severity).
However #44 does appear to be a duplicate of this issue #7, as the root cause is correctly called out as the use of msg.value
in a loop in #44, and #44 does state that the batchTransferOutAndCallV5
function will revert as a secondary impact:
"The first one, described in the Proof of Concept section below, is of high severity. A malicious user could potentially drain all funds from the THORChain_Router." "The second issue is of medium severity. When a trusted actor invokes the batchTransferOutAndCallV5 function and if the length of the aggregationPayloads array exceeds 1, it will constantly revert."
This finding #7 however focuses on the primary impact of the batchTransferOutAndCallV5
function reverting, with a PoC, and appropriately does not reference the primary impact as high severity.
Thank you for your consideration.
Hi, The mitigation section in #44 is far superior, which is why it was chosen in the end.
Lines of code
https://github.com/code-423n4/2024-06-thorchain/blob/e3fd3c75ff994dce50d6eb66eb290d467bd494f5/ethereum/contracts/THORChain_Router.sol#L399 https://github.com/code-423n4/2024-06-thorchain/blob/e3fd3c75ff994dce50d6eb66eb290d467bd494f5/ethereum/contracts/THORChain_Router.sol#L401
Vulnerability details
Impact
The payable external
THORChain_Router.batchTransferOutAndCallV5
function uses the internal_transferOutAndCallV5
function for batch TransferOutAndCallV5 operations, which usesmsg.value
when calling the aggregator'sswapOutV5
function on line 399. All ether sent usingmsg.value
will effectively be used in the first iteration of the_transferOutAndCallV5
loop on line 401, and only 1 call toswapOutV5
takes place:It is understood that
THORChain_Router.batchTransferOutAndCallV5
is intended to be called by Bifrost components. Assuming normal usage ofTHORChain_Router.batchTransferOutAndCallV5
(nonzeromsg.value
amounts and anaggregationPayloads
argument with more than 1 element), this will cause all subsequent loop iterations to revert, breakingbatchTransferOutAndCallV5
functionality which may constitute as DoS. The same will occur if any other contract/EOA ever needs to callTHORChain_Router.batchTransferOutAndCallV5
to process batch transactions.Proof of Concept
The following Forge PoC
BatchTransferCallV5.t.sol
shows the impact of this finding:ethereum/test
directory, run the following command to install the Foundry Hardat package.requires
inethereum/hardhat.config.js
:ethereum/test
directory.Ran 1 test for test/BatchTransferCallV5.t.sol:BatchTransferOutAndCallV5Test [PASS] test_audit_batchTransferOutAndCallV5() (gas: 285918) Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 691.13µs (176.38µs CPU time)
Ran 1 test suite in 2.98ms (691.13µs CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)