Closed sherlock-admin3 closed 4 months ago
This is not a real bug. The reward debt is updated in that function, several lines below:
remove:
https://github.com/sherlock-audit/2024-06-allora/blob/4e1bc73db32873476f8b0a88945815d3978d931c/allora-chain/x/emissions/keeper/keeper.go#L1002-L1005 https://github.com/sherlock-audit/2024-06-allora/blob/4e1bc73db32873476f8b0a88945815d3978d931c/allora-chain/x/emissions/keeper/keeper.go#L1052
add:
https://github.com/sherlock-audit/2024-06-allora/blob/4e1bc73db32873476f8b0a88945815d3978d931c/allora-chain/x/emissions/keeper/keeper.go#L820-L827 https://github.com/sherlock-audit/2024-06-allora/blob/4e1bc73db32873476f8b0a88945815d3978d931c/allora-chain/x/emissions/keeper/keeper.go#L847
Invalid as reward debt is indeed updated
pks_
High
Malicious delegators can get more rewards than they should
Summary
The
RemoveDelegateStake
andAddDelegateStake
actions in theemissions
module don't update thedelegatedStakePlacement.RewardDebt
to record the claimed reward after sending the pending reward to the delegators.Vulnerability Detail
When delegators remove their stake, emissions
keeper#RemoveDelegateStake
calculate their pending reward then send the rewards to the delegators:However, the function don't update the
delegatedStakePlacement.RewardDebt
to record the claimed reward after sending the pending reward. This means that the delegators can claim the reward multiple times by removing their stake multiple times with littlemsg.amount
every time.Same issue also exists in
AddDelegateStake
action.Impact
The delegators can get more rewards than they should.
Code Snippet
https://github.com/sherlock-audit/2024-06-allora/blob/main/allora-chain/x/emissions/keeper/keeper.go#L974-L995
https://github.com/sherlock-audit/2024-06-allora/blob/main/allora-chain/x/emissions/keeper/keeper.go#L782-L811
Tool used
vscode, Manual Review
Recommendation
Record the claimed reward after sending the reward to delegator as
msg_server_stake#RewardDelegateStake
did.