Contract fails to deliver promised returns, but doesn't lose value
The contract loses the penalty funds too
Description
Brief/Intro
When a user invokes an emergency withdrawal they can bypass fees by withdrawing small amounts continuously.
Vulnerability Details
In Staking.sol there is an internal function called _emergencyWithdraw which external functions such as emergencyRedeem and emergencyWithdraw call to make instant withdrawals. Emergency withdrawals attract a penalty. However, attackers can bypass this penalty by repeatedly withdrawing small amounts until they reach the desired total, avoiding the intended penalty on the full amount.
Example: If penalty is set to 1000 BPS (10%), an attacker can withdraw 10 assets 100 times to obtain 1000 assets while skipping the 10% penalty that would apply if withdrawing 1000 at once.
Impact Details
The contract fails to retain or forward the intended penalty amount when an emergency withdrawal is invoked repeatedly by an attacker.