20,000 USDC
View results
Submission Details
Severity: medium
Valid

Transaction revert if the baseToken does not support 0 value transfer when charging fee

Summary

When calling the functions, the caller needs to the pay the fee on the baseToken transfer. If the fee amount is 0, the code below would revert if the ERC20 token does not support 0 value transfer as according to https://github.com/d-xo/weird-erc20#revert-on-zero-value-transfers

Impact

Transaction revert if the baseToken does not support 0 value transfer when charging fee

Proof Of Concept

File: Lender.sol
267: IERC20(loan.loanToken).transfer(feeReceiver, fees);

https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L267

File: Lender.sol
563: IERC20(loan.collateralToken).transfer(feeReceiver, govFee);

https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L563

File: Lender.sol
651: IERC20(loan.loanToken).transfer(feeReceiver, fee);

https://github.com/Cyfrin/2023-07-beedle/tree/main/src/Lender.sol#L651

Recommended Mitigation Steps

It is recommended for the protocol to check if the fee amount is 0 before performing transfer, i.e.

if(fees > 0) {
IERC20(loan.loanToken).transfer(feeReceiver, fees);
}

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.