Open sherlock-admin opened 1 year ago
1 comment(s) were left on this issue during the judging contest.
panprog commented:
borderline low/medium, vault.claimReward will indeed revert if any market reward is not set, but this can also be thought of as an admin error choosing incorrect markets
This is one of many configuration gotchas present in the Vault -- it is valid, however unsure if this qualifies as a medium, especially since it only affects an admin helper function (claimReward()
).
bin2chen
medium
vault.claimReward() If have a market without reward token, it may cause all markets to be unable to retrieve rewards.
Summary
In
vault.claimReward()
, it will loop through allmarket
ofvault
to executeclaimReward()
, and transferrewards
tofactory().owner()
. If one of the markets does not haverewards
, that is,rewardToken
is not set,Token18 reward = address(0)
. Currently, the loop does not make this judgmentreward != address(0)
, it will also executemarket.claimReward()
, and the entire method willrevert
. This leads to other markets withrewards
also being unable to retrieverewards
.Vulnerability Detail
The current implementation of
vault.claimReward()
is as follows:We can see that the method loops through all the
market
and executesmarket.claimReward()
, andreward().push()
.The problem is, not every market has
rewards
tokens.market.sol
'srewards
are not forcibly set ininitialize()
. The market'smakerRewardRate.makerRewardRate
is also allowed to be 0.This means that
market.sol
can be withoutrewards token
.If there is such a market, the current
vault.claimReward()
willrevert
, causing other markets withrewards
to also be unable to retrieverewards
.Impact
If the
vault
contains markets withoutrewards
, it will cause other markets withrewards
to also be unable to retrieverewards
.Code Snippet
https://github.com/sherlock-audit/2023-10-perennial/blob/main/perennial-v2/packages/perennial-vault/contracts/Vault.sol#L209-L214
Tool used
Manual Review
Recommendation