Platform: Code4rena
Start Date: 04/03/2024
Pot Size: $88,500 USDC
Total HM: 31
Participants: 105
Period: 11 days
Judge: ronnyx2017
Total Solo HM: 7
Id: 342
League: ETH
Rank: 60/105
Findings: 1
Award: $72.54
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: y0ng0p3
Also found by: 0xk3y, 0xspryon, Mike_Bello90, Myd, falconhoof, lightoasis, th3l1ghtd3m0n
72.5395 USDC - $72.54
https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/utils/Swapper.sol#L73-L118 https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/utils/Swapper.sol#L73-L118
_routerSwap
relies on the correctness and security of the external routers (0x Router and Universal Router). If there are vulnerabilities or exploits in these external contracts, an attacker could potentially craft malicious calldata to exploit the Revert Lend protocol.
The function does not have built-in mechanisms to detect or prevent such attacks.
Another issue is that the
_routerSwap
function does not have a deadline or expiration time for the swap, which could expose the protocol to potential front-running or sandwich attacks.
An attacker could potentially:
function _routerSwap(RouterSwapParams memory params) internal returns (uint256 amountInDelta, uint256 amountOutDelta) { // ... (address router, bytes memory routerData) = abi.decode(params.swapData, (address, bytes)); if (router == zeroxRouter) { ZeroxRouterData memory data = abi.decode(routerData, (ZeroxRouterData)); // ... (bool success,) = zeroxRouter.call(data.data); // ... } else if (router == universalRouter) { UniversalRouterData memory data = abi.decode(routerData, (UniversalRouterData)); // ... IUniversalRouter(universalRouter).execute(data.commands, data.inputs, data.deadline); } // ... }
The above shows that the
_routerSwap
function decodes the swap data based on the router address and directly calls the external router contracts (zeroxRouter.call
andIUniversalRouter(universalRouter).execute
) without performing any additional validation or checks on the swap data itself.
_routerSwap
function does not have a built-in mechanism to enforce a deadline or expiration time for the swap. This could expose the protocol to potential front-running or sandwich attacks.Without a deadline or expiration time, an attacker could:
function _routerSwap(RouterSwapParams memory params) internal returns (uint256 amountInDelta, uint256 amountOutDelta) { // ... if (router == zeroxRouter) { // ... (bool success,) = zeroxRouter.call(data.data); // ... } else if (router == universalRouter) { // ... IUniversalRouter(universalRouter).execute(data.commands, data.inputs, data.deadline); } // ... }
In the code above demonstrates that the _routerSwap
function does not have any built-in checks for a deadline or expiration time. It directly executes the swap without considering the time sensitivity of the transaction.
vs code
Verify that the swap data does not contain any malicious instructions or unauthorized actions. Consider implementing a whitelist of approved external routers and swap data formats.
Add a deadline or expiration time check to the _routerSwap
function to prevent front-running and sandwich attacks.
Other
#0 - c4-pre-sort
2024-03-20T16:33:38Z
0xEVom marked the issue as duplicate of #176
#1 - c4-pre-sort
2024-03-20T16:33:41Z
0xEVom marked the issue as insufficient quality report
#2 - 0xEVom
2024-03-20T16:35:51Z
Fails to recognize that _routerSwap()
is an internal function and checks could be performed at entry points.
#3 - c4-pre-sort
2024-03-21T13:23:21Z
0xEVom marked the issue as not a duplicate
#4 - c4-pre-sort
2024-03-21T13:23:27Z
0xEVom marked the issue as duplicate of #147
#5 - c4-judge
2024-03-31T16:01:29Z
jhsagd76 marked the issue as satisfactory