Redacted Cartel contest - 0xLad'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: 82/101

Findings: 2

Award: $41.25

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

25.3241 USDC - $25.32

Labels

bug
3 (High Risk)
satisfactory
edited-by-warden
duplicate-275

External Links

Lines of code

https://github.com/code-423n4/2022-11-redactedcartel/blob/main/src/vaults/PirexERC4626.sol#L60-L77 https://github.com/code-423n4/2022-11-redactedcartel/blob/main/src/vaults/PirexERC4626.sol#L80-L97

Vulnerability details

Impact

The user who deposits first can perform a "donation" attack on the user who deposits afterwards. The second user expects to get D shares for a deposit of D assets, but will get significantly less than D shares.

The issue is present in the deposit() and mint() functions of the PirexERC4626 contract. The issue is also present in depositGmx() and depositGlp()

Proof of Concept

  1. The first user to deposit into the vault (Alice) deposits 1 wei and receives a 1 wei of shares.
  2. The second user (Bob) sends a tx to deposit 100 * 1e18 assets into vault, and expects to receive 100 * 1e18 shares because the asset/share ratio is 1:1.
  3. Alice frontruns Bob and donates 51 * 1e18 - 1 assets to the vault. After Bob's transaction completes, he receives (100 * 1e18) * (1 / (51 * 1e18)) = 1 wei of shares.

Bob deposited for 66.2% (100 / 151) of the assets in the vault, but is only entitled to 50% (both he and Alice have 1 wei of shares). Bob can only withdraw 75.5 * 1e18 assets and has lost ~25% of his original deposit.

Add a minimum deposit size for the first deposit, or add "virtual" assets and shares when doing conversions. See YieldBox for an example.

#0 - c4-judge

2022-12-03T21:15:28Z

Picodes marked the issue as duplicate of #407

#1 - c4-judge

2023-01-01T11:07:00Z

Picodes marked the issue as satisfactory

#2 - C4-Staff

2023-01-10T21:53:51Z

JeeberC4 marked the issue as duplicate of #275

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#L242-L247 https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/PirexRewards.sol#L373

Vulnerability details

Impact

Vault rewards may be drained through a combination of claimRewards(), compound(), and uniswap trades by the attacker.

Proof of Concept

  1. Attacker calls claimRewards({producerToken: WETH, user: vault}) to get WETH into the vault.
  2. Attacker calls compound({fee: poolFee, amountOutMinimum: 1, sqrtPriceLimitX96: 0, optOutIncentive: true}) . The attacker sandwiches this transaction with two transactions which purchase and sell WETH.
  3. The vault loses most of its WETH rewards.

Only allow compound() to be called by trusted operators. Additionally, consider calculating amountOutMinimum based on chainlink oracle prices.

#0 - c4-judge

2022-12-03T18:49:15Z

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:13:14Z

Picodes marked the issue as satisfactory

#3 - c4-judge

2023-01-01T11:37:32Z

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