Dopex - mahdikarimi'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: 32/189

Findings: 3

Award: $648.93

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: LokiThe5th

Also found by: Nikki, __141345__, mahdikarimi, peakbolt, rvierdiiev, wintermute

Labels

bug
3 (High Risk)
low quality report
partial-50
duplicate-1584

Awards

631.6175 USDC - $631.62

External Links

Lines of code

https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/perp-vault/PerpetualAtlanticVault.sol#L315-L369 https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/perp-vault/PerpetualAtlanticVaultLP.sol#L145-L175

Vulnerability details

Summary

PerpetualAtlanticVaultLP share holder can front-run settlement and withdraw his funds from available collateral to escape loss after settlement.

Vulnerability Details

when a new option is created required collateral for settlement has been locked in PerpetualAtlanticVaultLP , although this ensures full settlement but malicious user can front-run settlement and withdraw from available collateral of PerpetualAtlanticVaultLP and escape loss , this loss amount is added to other vault share holders loss.

Impact

Malicious user escape from loss and add to vault share holders loss

Proof of Concept

Consider a scenario that there are 100 collateral and 10 shares in a PerpetualAtlanticVaultLP , 50 of collateral has been locked for settle option positions if required , and a user holds 5 shares in this vault. 1 - an option hits strike price and admin calls settle function . 2 - as 50 collateral is available in vault , malicious user front-runs settlement and withdraw 50 collateral ( for 5 shares ) , malicious user exited contract without loss 3 - then settlement happens and loss for other vault share holders doubles .

Tools Used

Manual Review

Consider lock user shares proportion to active collateral and total supply .

Assessed type

Other

#0 - c4-pre-sort

2023-09-10T07:26:26Z

bytes032 marked the issue as low quality report

#1 - bytes032

2023-09-10T07:26:42Z

The warden claims a malicious user can escape from loss, but doesn't show how.

#2 - GalloDaSballo

2023-10-16T08:57:16Z

I overall think these reports are wrong ITM -> You want settle OTM -> You cannot redeem

Missing proof for real damages

#3 - c4-judge

2023-10-16T08:57:22Z

GalloDaSballo marked the issue as unsatisfactory: Invalid

#4 - c4-judge

2023-10-20T19:05:36Z

GalloDaSballo marked the issue as duplicate of #1584

#5 - c4-judge

2023-10-20T19:05:43Z

GalloDaSballo marked the issue as partial-50

Lines of code

https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/perp-vault/PerpetualAtlanticVault.sol#L359-L361 https://github.com/code-423n4/2023-08-dopex/blob/eb4d4a201b3a75dd4bddc74a34e9c42c71d0d12f/contracts/perp-vault/PerpetualAtlanticVaultLP.sol#L200-L203

Vulnerability details

Summary

Attacker can perform inflation attack on PerpetualAtlanticVaultLP and force subtractLoss( used in settlement ) function to revert .

Vulnerability Details

Settle function in PerpetualAtlanticVault transfers collateral token from perpetual vault to rdpxV2Core then calls subtractLoss to report transfer to PerpetualAtlanticVaultLP , in subtractLoss there is a check that ensures token balance of contract is equal to _totalCollateral - loss (loss is reported transfer amount). require(collateral.balanceOf(address(this)) == _totalCollateral - loss,); however if someone transfer some collateral token to contract this check always reverts and settlements get blocked .

Impact

Positions can't be settled and assets will get stuck in Vault

Tools Used

Manual Review

You can check contract balance before transfer and track balance change .

Assessed type

Other

#0 - c4-pre-sort

2023-09-09T09:56:58Z

bytes032 marked the issue as duplicate of #619

#1 - c4-pre-sort

2023-09-11T16:14:29Z

bytes032 marked the issue as sufficient quality report

#2 - c4-judge

2023-10-20T19:31:45Z

GalloDaSballo marked the issue as partial-50

#3 - GalloDaSballo

2023-10-20T19:31:59Z

Low quality but valid

Consider: -> Writing short sentences -> Add code -> Write POC

Awards

17.313 USDC - $17.31

Labels

bug
3 (High Risk)
satisfactory
sufficient quality report
edited-by-warden
duplicate-867

External Links

Lines of code

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

Vulnerability details

Summary

Attacker can deposit and redeem in same transaction to steal funding payment

Vulnerability Details

when a user deposits into PerpetualAtlanticVaultLP ,deposit function calculates amount of shares to be minted based on total supply and total collateral then calls perpetualAtlanticVault.updateFunding() to calculate and transfer pending funding to PerpetualAtlanticVaultLP , as new collateral has been added to vault value of shares increased and if user redeems it instantly he will get more than deposit amount , for example if user has deposited as much as 50% of vault collateral he will get 50% of assest transferred via updateFunding so if he use flash loans he can take most of the fundings that has been paid to vault , this also can be used to take premium free options .

Impact

Attacker can steal funding payments made to PerpetualAtlanticVaultLP

Proof of Concept

Let's say there is 1000 collateral in vault with total supply of 1000 . 1 - Alice takes a flashloan of 10000 collateral . 2 - Alice deposits 10000 collateral to vault ( 10000 shares calculated to mint for alice ) . 3 - deposit function calls updateFunding which transferes ( for example ) 100 collateral as funding and adds value to each vault share . 4 - 10000 shares has been minted for alice . 5 - Alice redeems all of her 10000 shares ans she'll receive nearly 10100 collateral instantly .

Tools Used

Manual Review

Consider call perpetualAtlanticVault.updateFunding() before calculating shares .

Assessed type

Other

#0 - c4-pre-sort

2023-09-08T14:11:55Z

bytes032 marked the issue as duplicate of #867

#1 - c4-pre-sort

2023-09-11T09:08:07Z

bytes032 marked the issue as sufficient quality report

#2 - c4-judge

2023-10-20T19:25:38Z

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