20,000 USDC
View results
Submission Details
Severity: medium

Use safeTransfer instead of transfer

Summary

Use safeTransfer instead of transfer for transactions in the Lender.sol contract to avoid failed transaction issues

Vulnerability Details

Tokens not compliant with the ERC20 specification could return false from the transfer function call to indicate the transfer fails, while the calling contract would not notice the failure if the return value is not checked. Checking the return value is a requirement, as written in the EIP-20 specification:
"Callers MUST handle false from returns (bool success). Callers MUST NOT assume that false is never returned!"

Impact

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L159
https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L203
and other 10 instances in the Lender.sol contract

Tools Used

Solidity, Hardhat

Recommendations

Use the SafeERC20 library implementation from OpenZeppelin and call safeTransfer or safeTransferFrom when transferring ERC20 tokens.

Support

FAQs

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