Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: high
Invalid

Potential Reentrancy Vulnerability in Deposit Function Due to External Token Transfer

Summary

The depositfunction does not strictly follow the Checks-Effects-Interactions (CEI) pattern, which is a common best practice in Solidity to prevent reentrancy attacks

Vulnerability Details

  • In the deposit function, token.safeTransferFrom(msg.sender, address(this), _amount) is an external call that transfers tokens from the sender to the contract.

  • If msg.sender is a malicious contract, it might execute code upon receiving this transfer, potentially calling back into the deposit function before state changes are finalized.

function deposit(address _account, uint256 _amount) external onlyPriorityPool {
require(strategies.length > 0, "Must be > 0 strategies to stake");
token.safeTransferFrom(msg.sender, address(this), _amount);
depositLiquidity();
_mint(_account, _amount);
totalStaked += _amount;
}

Impact

  • An attacker could repeatedly call the deposit function before the state changes are finalized, allowing them to manipulate their balance or the total staked amount.

Tools Used

Manual Review

Recommendations

  • Implement the nonReentrant modifier from OpenZeppelin to provide a simple and comprehensive safeguard against reentrant calls throughout the function. or change the lines

function deposit(address _account, uint256 _amount) external onlyPriorityPool {
require(strategies.length > 0, "Must be > 0 strategies to stake");
// Effect: Update the state before making any external calls
_mint(_account, _amount);
totalStaked += _amount;
// Interaction: Perform the external call after state changes
token.safeTransferFrom(msg.sender, address(this), _amount);
// Interaction: Call depositLiquidity after state changes
depositLiquidity(); }
Updates

Lead Judging Commences

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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