The deposit function in the provided Solidity code is vulnerable to a front-running attack. Malicious actors can exploit this by transferring tokens to the contract, inflating the balance and causing the function to revert, leading to a Denial of Service (DoS).
https://github.com/Cyfrin/2024-09-stakelink/blob/main/contracts/core/StakingPool.sol#L111-L132
The vulnerability is exploited due to a check in the last part of the deposit function to assess if deposit was properly carried out and all intended assets were apppropiately deposited. The check however has a downside as it can be exploited by a malicous actor. The malicious actor can make a direct transfer to the contract, thereby inflating the contract balance and since the check expects the ending balance to be equal to the starting balance, the intending deposit by a legtimate user becomes unsuccessful.
Below is the function, check at the latter end of the function can be exploited by a malcious actor to cause Dos for legitmate stakers
medium
manual review
Protocol should remove or modify the "endingBalance > startingBalance" check
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.