Dopex - niki'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: 73/189

Findings: 2

Award: $142.58

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

Awards

96.3292 USDC - $96.33

Labels

bug
3 (High Risk)
satisfactory
upgraded by judge
sufficient quality report
edited-by-warden
duplicate-549

External Links

Lines of code

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

Vulnerability details

Impact

Always returning true even if the DpxethPrice is price is not above the upper peg

Proof of Concept

the Dpxeth is 18 decimals

Tools Used

Manual

  • _validate(getDpxEthPrice() > 1e18, 10);

Assessed type

Decimal

#0 - c4-pre-sort

2023-09-09T05:24:51Z

bytes032 marked the issue as duplicate of #549

#1 - c4-pre-sort

2023-09-12T05:19:53Z

bytes032 marked the issue as sufficient quality report

#2 - c4-judge

2023-10-20T18:27:47Z

GalloDaSballo marked the issue as satisfactory

#3 - c4-judge

2023-10-20T18:28:21Z

GalloDaSballo changed the severity to 3 (High Risk)

Awards

46.2486 USDC - $46.25

Labels

bug
2 (Med Risk)
downgraded by judge
satisfactory
sufficient quality report
duplicate-863

External Links

Lines of code

https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/perp-vault/PerpetualAtlanticVaultLP.sol#L282-L285 https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/perp-vault/PerpetualAtlanticVaultLP.sol#L118-L124

Vulnerability details

Impact

First depositor can break minting of shares

  1. Minting 1 wei shares
  2. Directly transferring assets into the contract to inflate the PerpetualAtlanticVaultLp - totalSupply to be increased
  3. Subsequent depositors deposit assets but are minted 0 shares due to precision loss

Proof of Concept

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

Upon first deposit, the supply will be 0. The attacker will transact with an amount = 1 wei to mint 1 wei of shares. Then the attacker will transfer some value of asset directly to the contract. For this example, the attacker transfers 10,000 tokens.

Next, a subsequent depositor attempts to mint shares with 5,000 tokens.

shares = 5000 tokens * 1 wei / 10,000 tokens = 0 due to precision loss.

it will return 0 the converToShares and it it will revert the function

The function will revert every time, except if the second depositor deposit more than the transferred tokens that first depositor transfer to the contract

Tools Used

Manual

Mint a certain number of shares and transfer them to address(0) within the constructor.

Assessed type

Token-Transfer

#0 - c4-pre-sort

2023-09-07T13:33:36Z

bytes032 marked the issue as duplicate of #863

#1 - c4-pre-sort

2023-09-11T09:10:41Z

bytes032 marked the issue as sufficient quality report

#2 - c4-judge

2023-10-18T12:41:47Z

GalloDaSballo changed the severity to 2 (Med Risk)

#3 - c4-judge

2023-10-18T12:53:35Z

GalloDaSballo marked the issue as satisfactory

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