This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
0x52 - Tokens that are both bribes and StakeDao gauge rewards will cause loss of funds #182
Labels
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
High
A valid High severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
0x52
high
Tokens that are both bribes and StakeDao gauge rewards will cause loss of funds
Summary
When SdtStakingPositionService is pulling rewards and bribes from buffer, the buffer will return a list of tokens and amounts owed. This list is used to set the rewards eligible for distribution. Since this list is never check for duplicate tokens, a shared bribe and reward token would cause the token to show up twice in the list. The issue it that _sdtRewardsByCycle is set and not incremented which will cause the second occurrence of the token to overwrite the first and break accounting. The amount of token received from the gauge reward that is overwritten will be lost forever.
Vulnerability Detail
In L559 of SdtStakingPositionService it receives a list of tokens and amount from the buffer.
SdtBuffer.sol#L90-L168
SdtBuffer#pullRewards returns a list of tokens that is a concatenated array of all bribe and reward tokens. There is not controls in place to remove duplicates from this list of tokens. This means that tokens that are both bribes and rewards will be duplicated in the list.
SdtStakingPositionService.sol#L561-L577
When storing this list of rewards, it overwrites _sdtRewardsByCycle with the values from the returned array. This is where the problem arises because duplicates will cause the second entry to overwrite the first entry. Since the first instance is overwritten, all funds in the first occurrence will be lost permanently.
Impact
Tokens that are both bribes and rewards will be cause tokens to be lost forever
Code Snippet
SdtStakingPositionService.sol#L550-L582
Tool used
Manual Review
Recommendation
Either sdtBuffer or SdtStakingPositionService should be updated to combine duplicate token entries and prevent overwriting.
The text was updated successfully, but these errors were encountered: