No check for existing extraRewards during push
The reward pool contract allows the same extra reward token address to be added multiple times without a duplicate check. If a reward manager mistakenly adds the same address twice, a user who stakes and later withdraws will receive double the linked rewards, taking funds from other depositors.
Submitted by cryptphi, also found by csanuragjain
https://github.com/code-423n4/2022-05-vetoken/blob/main/contracts/VE3DRewardPool.sol#L138
https://github.com/code-423n4/2022-05-vetoken/blob/main/contracts/VE3DLocker.sol#L156
Impact
Similar to a report I submitted for BaseRewardPool.sol (https://github.com/code-423n4/2022-05-vetoken/blob/main/contracts/BaseRewardPool.sol#L126)
When adding extraRewards to the extra reward pool in https://github.com/code-423n4/2022-05-vetoken/blob/main/contracts/VE3DRewardPool.sol#L138 , there’s no check for already existing address.
Assume a particular address takes up 2 slots out of 3, and a user withdraws staked extra rewards, the user will receive double the amount requested in https://github.com/code-423n4/2022-05-vetoken/blob/main/contracts/VE3DRewardPool.sol#L257-L258
Proof of Concept
- Assume
rewardManagerhad mistakenly added the same address twice inaddExtraReward() - A user calls
stake(), linked rewards is staked twice to the same address (unexpected behaviour I guess but not severe issue) - Now, user calls
withdraw()to withdraw linked rewards (this is already 2x in step 2) - User will receive double the linked rewards due to the iteration in
https://github.com/code-423n4/2022-05-vetoken/blob/main/contracts/VE3DRewardPool.sol#L257-L258
Recommended Mitigation Steps
Guess a check for an already existing extraRewards can be added before Line 138
Similar issue
https://github.com/code-423n4/2022-05-vetoken/blob/main/contracts/VE3DLocker.sol#L156 - not so sure of the severity for this.
https://github.com/code-423n4/2022-05-vetoken/blob/main/contracts/BaseRewardPool.sol#L126 - reported in a seperate report
jetbrain10 (veToken Finannce) confirmed
Alex the Entreprenerd (judge) commented:
The warden has shown how, due to a misconfiguration error, a leak of value can happen, and other depositors (late withdrawers) would lose the rewards that they are entitled to.
Mitigation seems to be straightforward (add a duplicate check, or use a enumerableMap), that said, because of the risk of loss contingent on configuration, I agree with Medium Severity.
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
If a reward manager mistakenly adds the same extra reward address twice, a user could withdraw double the linked rewards, causing other depositors to lose rewards they are entitled to; the issue depends on that configuration mistake.
What the attacker needed
Reward manager adds same address twice
The fix
A duplicate check should be added before adding an extra reward, or an enumerable map should be used to prevent duplicate entries.
How it was found
- The reward manager mistakenly adds the same address twice via addExtraReward().
- A user calls stake(), and linked rewards are staked twice to the same address.
- The user calls withdraw() to withdraw linked rewards.
- The user receives double the linked rewards due to iteration over the duplicate entries.
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.
A smart contract lets people stake tokens and earn extra rewards. The person managing rewards can add extra reward tokens, but the contract does not check if the same token was already added. If the manager adds the same token twice by mistake, a user can withdraw twice as many rewards as they should, leaving less for everyone else.
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.