A reentrancy vulnerability exists within the deposit and withdraw functions of the StakingPool.sol contract. These functions perform external calls to untrusted strategy contracts without adequate reentrancy protection, potentially allowing attackers to manipulate balances and withdraw more funds than intended.
deposit FunctionExplanation:
The deposit function transfers tokens and interacts with external strategy contracts (_depositLiquidity) before updating the totalStaked state variable.
This order allows external contracts to call back into the deposit or withdraw functions before totalStaked is updated, enabling potential reentrancy attacks.
withdraw FunctionExplanation:
Similar to deposit, the withdraw function performs external calls (_withdrawLiquidity) before updating the totalStaked variable.
This arrangement permits malicious strategies to re-enter the withdraw function, potentially draining more funds than allowed.
Explanation:
The ReentrantStrategy contract implements the IStrategy interface.
Its deposit function maliciously re-enters the StakingPool's deposit method during its execution.
This re-entrance occurs before the totalStaked variable is updated, allowing the attacker to manipulate contract state and potentially withdraw excessive funds.
Financial Losses: Attackers can exploit the reentrancy vulnerability to withdraw more tokens than intended, leading to significant financial losses for users and the platform.
State Manipulation: Unauthorized manipulation of state variables like totalStaked can disrupt the integrity of the staking mechanism, causing inconsistencies and potential overflows.
Trust Erosion: Successful exploitation can undermine user trust in the platform's security, potentially affecting its reputation and user base.
Manual Review
Action:
Integrate OpenZeppelin's ReentrancyGuard and apply the nonReentrant modifier to critical functions.
Explanation:
The nonReentrant modifier prevents functions from being called recursively, effectively mitigating reentrancy attacks.
Action:
Rearrange the order of operations to update state variables before making external calls.
Explanation:
By updating totalStaked before external interactions, the contract minimizes the risk window where reentrancy could be exploited.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.