An attacker can brick the staking pool by calling the `donateTokens` function immediately after deployment. This action would result in a scenario where `totalShares = 0` and `totalStaked > 0`, preventing any subsequent normal deposits from being processed. All future attempts to deposit from the priority pool will fail due to a reversion in the minting process, effectively disabling the staking pool for all users.
The vulnerability occurs due to the following flow:
1. The attacker calls the `donateTokens` function immediately after the staking pool is deployed. This increases `totalStaked` but does not mint any shares (because donations do not mint new shares), leaving `totalShares = 0`.
2. Subsequent deposit attempts from the priority pool revert when minting new shares. Since `totalShares = 0`, the function `getSharesByStake` will return 0 shares for any deposit amount, causing the `_mintShares` function to revert due to an underflow.
Next
- The calculation for shares in `getSharesByStake` will return 0 because the formula relies on `totalShares`:
- When attempting to mint shares in `_mintShares`, the system attempts to subtract `DEAD_SHARES` from the mint amount, which results in an underflow:
3. The underflow occurs when `_amount - DEAD_SHARES` results in a negative value (e.g., 0 - 1000). This reverts the transaction, preventing any future deposits from being accepted by the staking pool.
4. As a result, the staking pool becomes permanently bricked, and no normal deposits can be made, rendering the system unusable for all users.
- **Complete Denial-of-Service (DoS) Attack**: The staking pool becomes permanently bricked, preventing any future deposits from the priority pool. This renders the staking pool unusable for all users and disrupts the entire staking process.
- **Unrecoverable State**: Since the system cannot handle deposits after `totalShares = 0` and `totalStaked > 0`, this leads to a state where normal operations cannot resume without manual intervention or redeployment.
Manual Review
1. **Revert `donateTokens` if `totalStaked == 0`**: To prevent the bricking of the staking pool by an initial donation, the contract should revert any `donateTokens` call if `totalStaked == 0`. This ensures that the staking process begins with a valid deposit, ensuring shares are minted correctly from the start.
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.