User can forfeit other user rewards
The getReward function allowed any caller to specify another user's account and an arbitrary start index, causing the contract to mark that user's rewards as claimed from epoch zero up to the returned index. An attacker could therefore forfeit other users' unclaimed rewards by calling getReward on their behalf with a higher start index.
Originally disclosed on Code4rena
Submitted by csanuragjain
ExtraRewardsDistributor.sol#L127
User can forfeit other user rewards by giving a higher _startIndex in getReward function.
Proof of Concept
- Assume User B has not received any reward yet so that his userClaims[_token][User B]=0
- User A calls getReward function with _account as User B and _startIndex as 5
- This eventually calls _allClaimableRewards at ExtraRewardsDistributor.sol#L213 which computes epochIndex =5>0?5:0 = 5
- Assuming tokenEpochs is 10 and latestEpoch is 8, so reward will computed from epoch 5 till epoch index 7 and _allClaimableRewards will return index as 7
- _getReward will simply update userClaims[_token][User B] with 7
- This is incorrect because as per contract User B has received reward from epoch 0-7 even though he only received reward for epoch 5-7
Recommended Mitigation Steps
Do not allow users to call getReward function for other users.
0xMaharishi (Aura Finance) confirmed, but disagreed with severity and commented:
This is a valid report, however, considering it is only related to the distribution of reward tokens, I have a hard time classifying this as high risk.
I agree with the high risk rating on this one. A third party could cause significant loss of expected reward funds for users across the entire protocol if so inclined.
0xMaharishi (Aura Finance) resolved:
code4rena aurafinance/aura-contracts#84 All code4rena fixes code-423n4/2022-05-aura#6
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
Likely the getReward function did not restrict the _account parameter to the caller, and it trusted a caller-supplied _startIndex when updating the user's claimed-reward marker.
Impact
A third party could cause significant loss of expected reward funds for users across the entire protocol.
What the attacker needed
Attacker has a funded account; victim has unclaimed rewards
How it was found
- Assume User B has not received any reward yet, so their userClaims entry is zero.
- User A calls getReward with _account set to User B and _startIndex set to 5.
- The call reaches _allClaimableRewards, which computes the epoch index from the supplied start index.
- With tokenEpochs at 10 and latestEpoch at 8, rewards are computed from epoch 5 to epoch 7 and the returned index is 7.
- _getReward updates userClaims for User B to 7, marking epochs 0 to 7 as claimed even though only 5 to 7 were paid.
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 keeps track of which reward payments each user has already collected. The function that pays out rewards let anyone name another person and say 'start counting from a later point', so the contract recorded that the victim had already been paid for earlier periods they never received. The attacker gains nothing directly, but the victim loses rewards they were owed.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.