Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)
Description
Vulnerability Details
The unbounded Stake[] array in the Staking contract causes a grief vector that allows users or an attacker to trigger an out-of-gas (OOG) revert when a user tries to withdraw their funds. Withdraw logic loops over the entire array (_consumeUnlockedSharesOrRevert for regular withdraw and _removeAnySharesFor for emergency withdraw), which can be made arbitrarily large by repeatedly depositing tiny stakes.
Although the functions permit specifying an amount to withdraw (which can reduce iterations), an attacker can repeatedly deposit 1 wei (or other tiny amounts) under a victim's address. Because the data structure is FIFO and each deposit creates an entry, victims will either encounter OOG reverts on normal withdraws or be forced to withdraw in many very small recursive transactions to drain their funds.
Impact Details
Funds can become effectively locked in the contract for victims.
Out-of-gas reverts on withdraw attempts.
Grief attack where attacker need not profit but can lock other users' funds.
Mitigation
Enforce a whitelist for permitted depositors (per-user depositor whitelist).
Enforce a minimum stake amount so spam deposits are impractical.
Replace looping over the whole array with a start and end index (cursor-based processing) to allow incremental processing without iterating the entire array in a single transaction.
Do not add behavior that relies solely on gas costs or optimistic assumptions; prefer structural changes (minimum stake, indexed/bounded consumption).