code-423n4 / 2022-04-dualityfocus-findings

1 stars 0 forks source link

Consistently check account balance before and after transfers for Fee-On-Transfer discrepancies #45

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Lines of code

https://github.com/code-423n4/2022-04-dualityfocus/blob/main/contracts/vault_and_oracles/FlashLoan.sol#L57-L58

Vulnerability details

Impact

Wrong amountOwing approved

Proof of Concept

Arbitrary ERC20 tokens can be passed as assets[0]. With a transfer, the received amount should be calculated every time to take into consideration a possible fee-on-transfer or deflation. Also, it's a good practice for the future of the solution.

Recommended Mitigation Steps

Use the balance before and after the transfer to calculate the received amount instead of assuming that it would be equal to the amount passed as a parameter in the IERC20(assets[0]).transferFrom(address(LP_VAULT), address(this), amountOwing) call.

0xdramaone commented 2 years ago

If amountOwing is not returned to the FlashLoan.sol contract, it will revert since the Aave flashloan cannot be closed. Do not see risk here

kismet108 commented 2 years ago

Duplicate of #44