Closed sherlock-admin2 closed 1 year ago
1 comment(s) were left on this issue during the judging contest.
Kral01 commented:
low severity
1 comment(s) were left on this issue during the judging contest.
Kral01 commented:
low severity
agree with low/info severity
Escalate:
extraRewards
array is shared by the contract which can support multiple pools. this array will not delete item. If there is a new extra reward token, mint/burn will internally push it into extraRewards
.extraRewards.length
is safe. pendingRewards
is called, it will traverse extraRewards
to calculate the reward that each rewarder should distribute to the caller. So, this has a potential OOG risk. valid M.
Escalate:
- The
extraRewards
array is shared by the contract which can support multiple pools. this array will not delete item. If there is a new extra reward token, mint/burn will internally push it intoextraRewards
.- The rewardManager from external protocol can add/delete extra reward token. In the long run, no one can guarantee that
extraRewards.length
is safe.- Every time
pendingRewards
is called, it will traverseextraRewards
to calculate the reward that each rewarder should distribute to the caller.So, this has a potential OOG risk. valid M.
You've created a valid escalation!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
I think this is just a low because the risk of OOG is pretty off and I will give you my opinion on it :
extraRewards
will grow very big only if the protocol interacts with most of the existing pool on aura protocol_syncExtraReward
, since it will happen only for new rewardsextraRewards
array, and we can make some calculations considering the gas cost of the opcodes from the Istanbul fork. Let's presume that the array has 20 items in it, which means that the protocol needs to interact with a lot of different pools already. Every SSLOAD done on a untouched storage slot cost 2100 gas, which means that in the first iteration the whole reading from the array will cost around 42000 gas, but the second iteration that can happen only in some cases, the whole SSLOAD's will cost only 100 gas per item, because the storage slot was already touched by the first iteration so that means another 2000 gas, 44000 gas in total from the iterations, and that's only considering worst cases scenario. Even if other functionalities are happening which also cost gas, I think the risk of OOG from this code alone is very low and negligible.For #68 and #66, my main point is that reward manager from external protocols can add new reward tokens via addExtraReward
. We cannot assume that new rewards will never be added. The current code implementation does have potential risks.
For #68 and #66, my main point is that reward manager from external protocols can add new reward tokens via
addExtraReward
. We cannot assume that new rewards will never be added. The current code implementation does have potential risks.
Yes , I'm on the same page as you here, it does have potential risks, but personally I don't consider those medium, I tend more towards the low since there are many if's and presumptions and if we consider strictly the data that we have right now about aura/convex pools, the issues presented by the sherlock are low/informational. But we will let final judges decide 👍
For #68 and #66, my main point is that reward manager from external protocols can add new reward tokens via
addExtraReward
. We cannot assume that new rewards will never be added. The current code implementation does have potential risks.Yes , I'm on the same page as you here, it does have potential risks, but personally I don't consider those medium, I tend more towards the low since there are many if's and presumptions and if we consider strictly the data that we have right now about aura/convex pools, the issues presented by the sherlock are low/informational. But we will let final judges decide 👍
I agree with this reasoning. Tending towards low.
@securitygrid agree with the above reasoning, do you have additional reasoning with the current data of pools that this is a possible scenario?
The number of extra rewards in the current aura/convex pool is generally 0-2. If the ability of reward manager to add new reward tokens is not considered and the protocol only plans to interact with a few pools, then OOG will not happen.
Result: Low Unique
nobody2018
medium
The WAuraPools/WConvexPools.extraRewards array does not delete items, which may cause OOG in the long run
Summary
Both WAuraPools/WConvexPools have a state variable called [extraRewards](https://github.com/sherlock-audit/2023-07-blueberry/blob/main/blueberry-core/contracts/wrapper/WAuraPools.sol#L58), which is an array that stores the addresses of all extra rewards contracts. In [mint](https://github.com/sherlock-audit/2023-07-blueberry/blob/main/blueberry-core/contracts/wrapper/WAuraPools.sol#L339-L351)/[burn](https://github.com/sherlock-audit/2023-07-blueberry/blob/main/blueberry-core/contracts/wrapper/WAuraPools.sol#L386-L395), [_syncExtraReward](https://github.com/sherlock-audit/2023-07-blueberry/blob/main/blueberry-core/contracts/wrapper/WAuraPools.sol#L435-L440) will be called to synchronize this array. The
extraRewards
array is shared by the contract which can support multiple pools. A pool corresponds to anauraRewarder
, which can have up to [12](https://github.com/aurafinance/convex-platform/blob/816cbfd551a80bb4768f9168144dadbd3e35bd13/contracts/contracts/BaseRewardPool.sol#L130) extra reward tokens. However, this array will not delete item. In this way, it may grow larger and larger over time. The [burn](https://github.com/sherlock-audit/2023-07-blueberry/blob/main/blueberry-core/contracts/wrapper/WAuraPools.sol#L360-L363) function will traverseextraRewards
internally, where call [_getPendingReward](https://github.com/sherlock-audit/2023-07-blueberry/blob/main/blueberry-core/contracts/wrapper/WAuraPools.sol#L296) for every rewarder to calculate the amount of rewards. IfextraRewards.length
is big enough, tx will revert due to out of gas.Vulnerability Detail
When the user opens a position in AuraSpell,
WAuraPools.mint
will be called. If a newextraRewarder
appears, it will be pushed to theextraRewards
array.By look at the code of WAuraPools/WConvexPools contracts, we can know that the
extraRewarder
array only pushes item and does not pop item. As time goes by, this array gets bigger and bigger.The
burn
function will callpendingRewards
to get allrewardTokens
andrewards
.pendingRewards
will traverseextraRewards
to calculate the reward that each rewarder should distribute to the caller.From L271,
extraRewardsCount
is set toextraRewards.length
.From L289-306, The
for
loop processes eachextraRewards[i]
, although someextraRewards[i]
do not belong to the pool specified by the caller.After the
pendingRewards
function returns, there is another piece of code that traverses the array again.L386,
extraRewardsCount
is theextraRewardsLength
of the pool specified by the currentburn
, and it does not exceed 12.L397, when
extraRewards
grows over time, it's length will be greater than 12. SohasDiffExtraRewards
is true.Therefore, L404-410, the
for
loop will be executed. This is the second traversal ofextraRewards
.Impact
If
extraRewards.length
is big enough, WAuraPools/WConvexPools.burn will revert due to out of gas. This will result in users being unable to close or increase existing position.Code Snippet
https://github.com/sherlock-audit/2023-07-blueberry/blob/main/blueberry-core/contracts/wrapper/WAuraPools.sol#L289-L302
https://github.com/sherlock-audit/2023-07-blueberry/blob/main/blueberry-core/contracts/wrapper/WConvexPools.sol#L210-L223
Tool used
Manual Review
Recommendation
It is recommended to change
address[] public extraRewards
tomapping(uint256 => addresss[]) public extraRewards
, the purpose is Mapping from token id to extra rewards addresses, which is safe. The reasons are as following:extraRewards[tokenId]
array can only be less than 12.extraRewards[tokenId]
array can only be less than 12.