Arbitrary ERC20 tokens can be passed as loanAssetContractAddress.
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 ERC20(loanAssetContractAddress).safeTransferFrom() function.
Lines of code
https://github.com/code-423n4/2022-04-backed/blob/main/contracts/NFTLoanFacilitator.sol#L155 https://github.com/code-423n4/2022-04-backed/blob/main/contracts/NFTLoanFacilitator.sol#L159 https://github.com/code-423n4/2022-04-backed/blob/main/contracts/NFTLoanFacilitator.sol#L203
Vulnerability details
Impact
Wrong amount calculated for
facilitatorTake
Proof of Concept
Arbitrary ERC20 tokens can be passed as
loanAssetContractAddress
. 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
ERC20(loanAssetContractAddress).safeTransferFrom()
function.