Virgin stake can claim all drops
The drip mechanism in the wxETH contract accrues rewards independently of the total staked supply, so if drip is enabled before any staker deposits, the first staker can immediately unstake the entire accumulated balance. This allows the first staker to claim all previously dripped rewards.
d3e4 Follow with ronnyx2017
Originally disclosed on Code4rena
Submitted by d3e4, also found by ronnyx2017
If wxETH drips when nothing is staked, then the first staker can claim every drop.
Proof of Concept
Suppose drip is enabled when totalSupply() == 0. At least one block passes and the first staker stakes, just 1 xETH is enough. This mints her 1 wxETH. This also calls _accrueDrip() (by the drip modifier) which drips some amount of xETH. Note that _accrueDrip() is independent of totalSupply(), so it doesn’t matter how little she stakes. cashMinusLocked is now 1 plus the amount dripped. Naturally, since she owns the entire supply she can immediately unstake the entire cashMinusLocked. Specifically, the exchangeRate() is now (cashMinusLocked * BASE_UNIT) / totalSupply() and she gets (totalSupply() * exchangeRate()) / BASE_UNIT = cashMinusLocked.
The issue is simply that drip is independent of staked amount; especially since it may drip even when nothing is staked, which enables the above attack.
Recommended Mitigation Steps
Note what happens when totalSupply() > 0. Then drops will fall on existing wxETH, and any new staker will trigger a drip before having to pay the new exchange rate which includes the extra drops. So a new staker, in this case, cannot unstake more than they staked; all drops go to previous holders. Therefore, do not drip when totalSupply == 0; in _accrueDrip():
-if (!dripEnabled) return;
+if (!dripEnabled || totalSupply() == 0) return;
Assessed type
MEV
vaporkane (xETH) disagreed with severity
kirk-baird (judge) decreased severity to Medium and commented:
It is true that the first staker may claim all previous dripped rewards. I consider this a medium severity issue as the likelihood is very low since it only occurs for the first staker and only if the strip was started before any stakers deposited.
Add a
totalSupplycheck.PR: https://github.com/code-423n4/2023-05-xeth/commit/aebc3244cbb0deb67f3cdef160b390da27888de7
Status: Not fully mitigated. Full details in reports from ronnyx2017, bin2chen and d3e4, and also included in the Mitigation Review section below.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The drip accrual function does not check whether the total supply of wxETH is zero, so rewards can accumulate with no stakers and be captured by the first staker.
Impact
The first staker could claim all rewards that dripped before any stake existed, but this only happens if drip is enabled before any staker deposits and is considered low likelihood.
What the attacker needed
Drip enabled before any staker; at least one block passes; attacker is first staker
The fix
The drip function should not accrue rewards when totalSupply() is zero; a check was added but the mitigation was not fully effective.
How it was found
- Enable drip when totalSupply() is zero.
- Wait at least one block.
- Stake a minimal amount (e.g., 1 xETH) to mint wxETH and trigger _accrueDrip().
- Unstake the entire cashMinusLocked balance, which includes the dripped rewards.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In this staking contract, rewards (called 'drips') are added to the pool over time. If rewards start accumulating before anyone has staked, the first person to stake a tiny amount can immediately withdraw all those rewards because they temporarily own the entire pool. This is unfair to later stakers and to the protocol.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.