Platform: Code4rena
Start Date: 24/03/2022
Pot Size: $75,000 USDC
Total HM: 15
Participants: 59
Period: 7 days
Judge: gzeon
Id: 103
League: ETH
Rank: 18/59
Findings: 5
Award: $1,222.11
π Selected for report: 0
π Solo Findings: 0
π Selected for report: hake
Also found by: Kenshin, Ruhum, VAD37, WatchPug, csanuragjain, hickuphh3, hyh, kirk-baird, obront, pmerkleplant, rayn, shw, tintin, wuwe1
77.3842 USDC - $77.38
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Libraries/LibSwap.sol#L29
The from amount in swap must always be transferred from user to the contract. But under certain circumstances contract may end up using its own funds for swapping thereby giving users free funds
swap
Remove L33-L35 and revise like below:
function swap(bytes32 transactionId, SwapData calldata _swapData) internal {
... // if (!LibAsset.isNativeAsset(fromAssetId) && LibAsset.getOwnBalance(fromAssetId) < fromAmount) {
// }
if (!LibAsset.isNativeAsset(fromAssetId)) {
LibAsset.transferFromERC20(fromAssetId, msg.sender, address(this), fromAmount); LibAsset.approveERC20(IERC20(fromAssetId), _swapData.approveTo, fromAmount); } .... }
#0 - H3xept
2022-04-12T08:38:05Z
Duplicate of #66
We are aware that the contract allows users to use latent funds, although we disagree on it being an issue as no funds (ERC20 or native) should ever lay in the contract. To make sure that no value is ever kept by the diamond, we now provide refunds for outstanding user value (after bridges/swaps).
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/DexManagerFacet.sol#L62
The function batchRemoveDex will only remove the first dex index passed in argument and rest in _dexs array will never be removed. This is happening since the function is returning once a matching dex is found instead of breaking from loop
Since function will not revert any error, This can lead to non required dexes still be whitelisted even though owner beleives them to be removed
batchRemoveDex
Instead of return, kindly use break
if (s.dexs[j] == _dexs[i]) { _removeDex(j); break; }
#0 - H3xept
2022-04-11T11:24:04Z
Duplicate of #34
π Selected for report: WatchPug
Also found by: VAD37, catchup, csanuragjain, rayn
665.807 USDC - $665.81
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Libraries/LibAsset.sol#L68
It seems that the approveERC20 function is approving MAX_INT amount instead of the passed amount. This will allow users to spend more than what they are entitled for
SafeERC20.safeApprove(IERC20(assetId), spender, MAX_INT);
Change the function line 68 to below:
SafeERC20.safeApprove(IERC20(assetId), spender, amount);
#0 - H3xept
2022-04-08T10:31:06Z
As our contract communicates with the same dexs all the time we only want to approve each token once and all the other users don't have to pay for it again. As our contract should only hold the funds currently transferred no other tokens can be accessed.
#1 - gzeoneth
2022-04-16T17:01:22Z
Duplicate of #160
π Selected for report: hake
Also found by: 0v3rf10w, 0xDjango, 0xkatana, BouSalman, CertoraInc, Dravee, Hawkeye, IllIllI, JMukesh, Jujic, Kenshin, PPrieditis, Picodes, PranavG, Ruhum, SolidityScan, VAD37, WatchPug, aga7hokakological, catchup, csanuragjain, cthulhu_cult, defsec, dimitri, hickuphh3, hubble, hyh, kenta, kirk-baird, obront, peritoflores, rayn, robee, saian, samruna, shenwilly, shw, sorrynotsorry, tchkvsky, teryanarmen, ych18
113.5781 USDC - $113.58
uint256 toAmount = LibAsset.getOwnBalance(_swapData.receivingAssetId);
Change this to:
uint256 toAmount = LibAsset.getOwnBalance(_swapData.receivingAssetId) - msg.value;
π Selected for report: Dravee
Also found by: 0v3rf10w, 0xDjango, 0xNazgul, 0xkatana, ACai, CertoraInc, FSchmoede, Funen, Hawkeye, IllIllI, Jujic, Kenshin, PPrieditis, Picodes, SolidityScan, TerrierLover, Tomio, WatchPug, catchup, csanuragjain, defsec, dimitri, hake, hickuphh3, kenta, minhquanym, obront, peritoflores, rayn, rfa, robee, saian, samruna, tchkvsky, teryanarmen, ych18
61.9811 USDC - $61.98
It was observed that multiple loop conditions were using postfix increment instead of prefix increment. Kindly consider changing i++ to ++i in order to save gas
It was observed that while swapping operations in multiple facet it was not checked whether amount==0. If yes function should immediately return to save gas
#0 - H3xept
2022-04-11T12:07:10Z
We internally decided to avoid previx increments for now.