Platform: Code4rena
Start Date: 02/06/2023
Pot Size: $100,000 USDC
Total HM: 15
Participants: 75
Period: 7 days
Judge: Picodes
Total Solo HM: 5
Id: 249
League: ETH
Rank: 4/75
Findings: 3
Award: $6,173.12
🌟 Selected for report: 1
🚀 Solo Findings: 1
🌟 Selected for report: etherhood
6119.6969 USDC - $6,119.70
https://github.com/code-423n4/2023-06-stader/blob/main/contracts/StaderOracle.sol#L270 https://github.com/code-423n4/2023-06-stader/blob/main/contracts/StaderOracle.sol#L285
Corruption of oracle data
Block for lastReportedSDPriceData = 7200 Let current block = 21601 Now StaderOracle will have data for 14400 and 21600 both blocks being pushed by nodes and in prices array it will be all mixed up. Also, As soon as 14400 block is finalised data for block 21600 is all lost as well.
add if (_sdPriceData.reportingBlockNumber == getSDPriceReportableBlock())
to ensure it is always latest reportable block data
add mapping(uint256 => uint256[]) blockPrices
to store prices array separately for each block being reported to avoid mixing and corruption of data
or have uint256 currentEpochBlock
so that when new block data is pushed, previous data is deleting before pushing new data
if(_sdPriceData.reportingBlockNumber!=currentEpochBlock){ delete prices; } ## Assessed type Oracle
#0 - manoj9april
2023-06-20T06:58:58Z
Sure we will fix this.
#1 - c4-sponsor
2023-06-20T06:59:07Z
manoj9april marked the issue as sponsor confirmed
#2 - c4-judge
2023-07-02T10:44:13Z
Picodes marked the issue as satisfactory
#3 - sanjay-staderlabs
2023-07-13T04:19:45Z
This is fixed
🌟 Selected for report: Madalad
Also found by: Aymen0909, Bauchibred, Breeje, DadeKuma, Hama, LaScaloneta, Madalad, MohammedRizwan, bin2chen, dwward3n, erictee, etherhood, kutugu, peanuts, piyushshukla, rvierdiiev, saneryee, tallo, turvy_fuzz, whimints
31.7954 USDC - $31.80
https://github.com/code-423n4/2023-06-stader/blob/main/contracts/StaderOracle.sol#L637
Stale data of exchange rate data being used protocol, resulting in loss in terms of ETHX being minted at stale exchange rate (which won't have accounted for new reward)
Check lastUpdatedAt timestamp and that it is within acceptable range of data update frequency when PORFeed is being used
Other
#0 - c4-judge
2023-06-10T14:44:55Z
Picodes marked the issue as duplicate of #15
#1 - c4-judge
2023-07-02T10:49:25Z
Picodes marked the issue as satisfactory
🌟 Selected for report: JCN
Also found by: 0x70C9, 0xSmartContract, 0xWaitress, 0xhacksmithh, DavidGiladi, K42, LaScaloneta, Rageur, Raihan, SAAJ, SAQ, SM3_SS, Sathish9098, Tomio, bigtone, c3phas, ernestognw, etherhood, koxuan, matrix_0wl, mgf15, naman1778, niser93, petrichor, piyushshukla, sebghatullah, shamsulhaq123
21.6219 USDC - $21.62
staderConfig.getStakePoolManager()
is being called again after calling same function and checking if vault is healthy, this line can be bumped before that check, poolManager
being used in check statement directly will save gas cost for calling same function again ~ 1300 gastotalEthRequestedForWithdraw
can be calculated and summed in loop and then subtracted at end of loop, rather than writing to storage during each iteration, it would (n-1)*100 gastotalOperatorETHRewardsRemaining,totalOperatorSDRewardsRemaining
is being read 3 times from storage and then incremented, which can instead be cached and then post update stored in storage variables, would save 400 gas.staderConfig
is being read from storage for more than 2 times at a lot functions across different files, where it can be cached in memory and used instead of reading repeatedly from storage, would save lot of gas. Eg. https://github.com/code-423n4/2023-06-stader/blob/main/contracts/SocializingPool.sol#L61, https://github.com/code-423n4/2023-06-stader/blob/main/contracts/PoolSelector.sol#L76, etcINodeRegistry((staderConfig).getPermissionlessNodeRegistry()).POOL_ID()
in memory or storage during initialization instead of calling each time in loop in https://github.com/code-423n4/2023-06-stader/blob/main/contracts/PermissionlessPool.sol#L96handleInvalidSignature
function, where instead it is being called for each key in loop costing 3k gas in each call#0 - c4-judge
2023-06-14T05:35:20Z
Picodes marked the issue as grade-b