Dopex - LFGSecurity's results

A rebate system for option writers in the Dopex Protocol.

General Information

Platform: Code4rena

Start Date: 21/08/2023

Pot Size: $125,000 USDC

Total HM: 26

Participants: 189

Period: 16 days

Judge: GalloDaSballo

Total Solo HM: 3

Id: 278

League: ETH

Dopex

Findings Distribution

Researcher Performance

Rank: 168/189

Findings: 2

Award: $0.05

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2023-08-dopex/blob/main/contracts/perp-vault/PerpetualAtlanticVaultLP.sol#L201

Vulnerability details

Impact

The subtractLoss() method can be blocked if an attacker transfers an amount of collateral token to the address, thus making (_totalCollateral - loss) not equal to collateral.balanceOf(address(this))

Proof of Concept

  1. Transfer some small amount of collateral token to the address of PerpetualAtlanticValultLP
  2. When the perpVault contract calls subtractLoss() with the right loss amount, the method will revert

Tools Used

Manual Review + Slither

Consider not using strict equality, but >= in the require statement

Assessed type

Token-Transfer

#0 - c4-pre-sort

2023-09-09T05:54:36Z

bytes032 marked the issue as duplicate of #619

#1 - c4-pre-sort

2023-09-11T16:13:59Z

bytes032 marked the issue as sufficient quality report

#2 - c4-judge

2023-10-20T19:35:07Z

GalloDaSballo marked the issue as satisfactory

Lines of code

https://github.com/code-423n4/2023-08-dopex/blob/main/contracts/core/RdpxV2Core.sol#L975

Vulnerability details

Impact

The totalWethDelegated storage variable is not updated when a delegate withdraws unused WETH. This will cause wrong accounting in the contract and unexpected behavior.

Proof of Concept

  1. Assume we start with totalWethDelegated == 0 and reserveAsset[reservesIndex["WETH"]].tokenBalance == 100 WETH.
  2. Deposit 100 WETH to the contract via addToDelegate() method. totalWethDelegated now equals 100 WETH.
  3. Withdraw the deposited WETH via withdraw() method
  4. Call sync() method. This will save 0 to reserveAsset[reservesIndex["WETH"]].tokenBalance

Tools Used

Manual Review

Consider updating totalWethDelegated when calling the withdraw() function

Assessed type

Other

#0 - c4-pre-sort

2023-09-08T13:27:31Z

bytes032 marked the issue as duplicate of #2186

#1 - c4-judge

2023-10-20T17:55:32Z

GalloDaSballo changed the severity to 2 (Med Risk)

#2 - c4-judge

2023-10-20T17:56:03Z

GalloDaSballo marked the issue as partial-50

#3 - c4-judge

2023-10-21T07:38:54Z

GalloDaSballo changed the severity to 3 (High Risk)

#4 - c4-judge

2023-10-21T07:46:01Z

GalloDaSballo marked the issue as partial-25

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