20,000 USDC
View results
Submission Details
Severity: medium

Reentrancy Vulnerability giveLoan function

Summary

The giveLoan function in the Lender.sol contract has a potential reentrancy vulnerability because it makes an external call to transfer tokens before updating its state variable loans.

Vulnerability Details

A reentrancy vulnerability occurs when a contract makes an external call to another contract before updating its state variables. This can allow an attacker to call the function again before its state is updated, potentially leading to unexpected behavior.

In the case of the giveLoan function, the function makes an external call to transfer tokens before updating the loans state variable. Specifically, the function updates the loans array by modifying the properties of the corresponding Loan.

Impact

If an attacker is able to exploit this vulnerability, they may be able to manipulate the state of this variable in unexpected ways, potentially leading to loss of funds or other unintended consequences.

Tools Used

Manual code review.

Recommendations

Use a reentrancy guard modifier such as the one provided by the OpenZeppelin library. The ReentrancyGuard contract can be inherited by other contracts to make the nonReentrant modifier available

Support

FAQs

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