Redacted Cartel contest - pedroais's results

Boosted GMX assets from your favorite liquid token wrapper, Pirex - brought to you by Redacted Cartel.

General Information

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

Redacted Cartel

Findings Distribution

Researcher Performance

Rank: 101/101

Findings: 1

Award: $15.93

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

15.9293 USDC - $15.93

Labels

bug
2 (Med Risk)
downgraded by judge
satisfactory
duplicate-137

External Links

Lines of code

https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/vaults/AutoPxGmx.sol#L244

Vulnerability details

Impact

An attacker can systematically steal all rewards from the autoPxGMX vault as soon as the contract has balance.

Proof of Concept

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

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter