Closed code423n4 closed 1 year ago
Related to issue #271 and also a centralization issue.
drahrealm marked the issue as disagree with severity
Although I do agree with the warden's mitigation that it'd be interesting for users to have the option to claim only for the token he chooses, currently the call to claimUserReward
does not revert if the token address is incorrect, so the call would not revert. Duplicate #271 with partial credit as the warden identified the weak point but the scenario described are very unlikely or do not work
Picodes marked the issue as duplicate of #271
Picodes marked the issue as partial-50
Lines of code
https://github.com/code-423n4/2022-11-redactedcartel/blob/9e9bb60f117334da7c5d851646a168ca271575fc/src/PirexRewards.sol#L373
Vulnerability details
Proof of Concept
The
claim
method inPirexRewards
iterates over therewardTokens
array for aproducerToken
. Now this array is completely managed by the contract’sowner
who can calladdRewardToken
which pushes a new value in that array, as many times as he decides with whatever value he decides.Let’s look at the following scenario:
addRewardToken
a huge amount of times, which results in therewardTokens
array being hugeclaim
the code will take a crazy amount of gas, because it has to iterate over the wholerewardTokens
array. Since the amount of gas will possibly be more than the block gas limit, this results in a DoS and the user won’t be able to claim.Or this scenario:
addRewardToken
with an address that is not really a tokenclaim
the code will try to do a call toproducer.claimUserReward
giving the address of therewardToken
, but since it is not really a token (or maybe it is just a random address with no bytecode) the call will revert. Actually it will always revert, which is a DoS state.Impact
This is a centralisation vulnerability allowing the owner to stop the user rewards anytime. Since it requires a malicious/compromised owner it is Medium severity
Recommendation
Add a way for the user to claim rewards only from a token he chooses, not to have to go through all reward tokens on each claim.