Stakers lose their commission if they unstake as they cannot claim their pending rewards anymore after unstaking
The claimCommission function is restricted to current stakers, so once a staker unstakes or is removed, they can no longer claim their previously accrued commissions. This results in a permanent loss of unclaimed rewards.
0xStalin Follow with mstpr-brainbot, n4nika and 4 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-08-morphl2-judging/issues/168
Found by
0xStalin, mstpr-brainbot, n4nika, p0wd3r, sammy, underdog, zraxx
Summary
Once a staker unstakes or gets removed, they permanently lose access to all their accrued commissions.
This is a problem as it can either happen mistakenly or if the staker gets removed by an admin or slashed. However even in that case, they should still be able to claim their previously accrued rewards since they did not act negatively during that period.
Root Cause
L2Staking.sol::claimCommission has the onlyStaker modifier, making it only callable by stakers.
Internal pre-conditions
None
External pre-conditions
None
Attack Path
Issue path in this case
- Staker stakes and accrues commissions over a few epochs
- Now either the staker unstakes or gets removed forcibly by the admin
- The staker has now lost access to all previously accrued rewards
Impact
Loss of unclaimed rewards
PoC
No response
Mitigation
Consider removing the onlyStaker modifier and allow anyone to call it. This should not be a problem since normal users do not have any claimable commission anyways except if they were a staker before.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/morph-l2/morph/pull/516
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
Impact
Stakers permanently lose unclaimed rewards if they unstake or are removed.
What the attacker needed
Staker has accrued commissions; staker unstakes or is removed
The fix
The protocol team fixed this issue by removing the onlyStaker modifier, allowing anyone to call claimCommission.
How it was found
- Staker stakes and accrues commissions over a few epochs
- Staker unstakes or gets removed forcibly by the admin
- Staker loses access to all previously accrued 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 a staking system, people lock tokens and earn rewards called commissions. The function to collect these rewards only works while you are still staking. If you stop staking or are removed, you cannot collect what you already earned, so that money is lost.
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.