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: 101/101
Findings: 1
Award: $15.93
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: deliriusz
Also found by: 0x52, 0xLad, 0xbepresent, Englave, R2, Ruhum, cccz, gzeon, hihen, keccak123, ladboy233, pashov, pedroais, perseverancesuccess, rbserver, rvierdiiev, simon135, unforgiven, wagmi, xiaoming90
15.9293 USDC - $15.93
An attacker can systematically steal all rewards from the autoPxGMX vault as soon as the contract has balance.
The autoPxGMX vault stores pxGMX tokens and auto compounds the base rewards received in WETH by swapping them back to GMX and depositing them in pirex to get PxGMX.
The compound function can be called by anyone and will swap the whole WETH balance for GMX in uniswap V3. The function has a minimum amount out parameter that is freely set by anyone who calls it.
An attacker can systematically steal all WETH rewards from the contract by buying a huge amount of GMX from the pool, calling compound(), and selling the GMX for profit. The compound function, if called with a minimum amount out of 1 will sell WETH for GMX at any price.
If the attacker buys almost all GMX from the pool and then calls compound the contract will receive almost no GMX for the sold WETH. This sandwich attack can be done systematically and without frontrunning, since anyone can call the compound function. A contract can be created that does swap, compound, and swap all in one transaction. This can be done systematically, each time the contract has some WETH it can be fully stolen by a malicious actor. A bot could be created to wipe out the vault's reward balance each time rewards are received.
Either make the compound function only owner so a trusted actor will set the minimum amount out or use a time-weighted average price oracle to determine a minimum price.
#0 - c4-judge
2022-12-03T19:23:28Z
Picodes marked the issue as duplicate of #183
#1 - c4-judge
2022-12-30T20:53:41Z
Picodes marked the issue as duplicate of #185
#2 - c4-judge
2023-01-01T11:12:39Z
Picodes marked the issue as satisfactory
#3 - c4-judge
2023-01-01T11:37:22Z
Picodes changed the severity to 2 (Med Risk)
#4 - C4-Staff
2023-01-10T22:10:37Z
JeeberC4 marked the issue as duplicate of #137