Redacted Cartel contest - wagmi'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: 100/101

Findings: 1

Award: $15.93

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

15.9293 USDC - $15.93

Labels

bug
2 (Med Risk)
satisfactory
duplicate-137

External Links

Lines of code

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

Vulnerability details

Impact

Function compound() is called in every deposit/withdraw in AutoPxGmx contract. It claim rewards in form of gmxBaseReward and swap them to gmx token. They used amountOutMinimum from input params

gmxAmountOut = SWAP_ROUTER.exactInputSingle(
    IV3SwapRouter.ExactInputSingleParams({
        tokenIn: address(gmxBaseReward),
        tokenOut: address(gmx),
        fee: fee,
        recipient: address(this),
        amountIn: gmxBaseRewardAmountIn,
        amountOutMinimum: amountOutMinimum,
        sqrtPriceLimitX96: sqrtPriceLimitX96
    })
);

However amountOutMinimum always has the value 1 when called by withdraw() or deposit() function.

function beforeDeposit(
    address,
    uint256,
    uint256
) internal override {
    compound(poolFee, 1, 0, true);
}

An attacker can front-run swap in Router before compound() to make a profit.

Proof of Concept

Please refer to yDai Incident to check the severity of a harvest function without slippage control.

Please refer to Mushrooms-finance-theft to check how likely this kind of attack might happen.

Consider adding using some fixed lowerbound rate (since it's trading from pxGMX to GMX so the rate should not be volatile)

#0 - c4-judge

2022-12-03T21:40:16Z

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-01T10:59:35Z

Picodes marked the issue as satisfactory

#3 - 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