Dopex - pks_'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: 184/189

Findings: 1

Award: $0.01

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

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

Vulnerability details

Impact

Function PerpetualAtlanticVaultLP#subtractLoss is used to adjust totalCollateral parameter and called by PerpetualAtlanticVault#settle() function, which is used to settle options by admin. When adjust the totalCollateral, it require collateral.balanceOf(address(this)) == _totalCollateral - loss to satisfy the condition. But a malicious user can transfer collateral token to PerpetualAtlanticVault contract directly to break the condition. Such that, protocol settle options function would dos.

Proof of Concept

Below is the Poc to show protocol would dos directly, just insert such code into tests/rdpxV2-core/Integration.t.sol#testIntegration test case:

--- a/tests/rdpxV2-core/Integration.t.sol
+++ b/tests/rdpxV2-core/Integration.t.sol
@@ -116,6 +116,14 @@ contract Integration is ERC721Holder, Setup {
     );
     rdpxPriceOracle.updateRdpxPrice(2 * 1e7);
 
+    // transfer to vaultLp directly
+    address attacker = address(100);
+    console.log("attacker: ", attacker);
+    weth.mint(attacker, 1);
+    vm.startPrank(attacker);
+    weth.transfer(address(vaultLp), 1);
+    vm.stopPrank();
+
     // settle options
     uint256[] memory ids = new uint256[](6);
     ids[0] = 2;

Test result: [FAIL. Reason: Not enough collateral was sent out] testIntegration() (gas: 6085101).

Tools Used

vscode, manual review

Use gt instead of equal operator.

    require(
        collateral.balanceOf(address(this)) >= _totalCollateral - loss,
        "Not enough collateral was sent out"
    );

Assessed type

DoS

#0 - c4-pre-sort

2023-09-09T09:54:58Z

bytes032 marked the issue as duplicate of #619

#1 - c4-pre-sort

2023-09-11T16:14:25Z

bytes032 marked the issue as sufficient quality report

#2 - c4-judge

2023-10-20T19:31:15Z

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