Astaria contest - Breeje's results

On a mission is to build a highly liquid NFT lending market.

General Information

Platform: Code4rena

Start Date: 05/01/2023

Pot Size: $90,500 USDC

Total HM: 55

Participants: 103

Period: 14 days

Judge: Picodes

Total Solo HM: 18

Id: 202

League: ETH

Astaria

Findings Distribution

Researcher Performance

Rank: 68/103

Findings: 1

Award: $69.09

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: adriro

Also found by: Breeje, JC, JTs, Josiah, ast3ros, bin2chen, eierina, obront, rbserver, yongskiws

Labels

bug
3 (High Risk)
satisfactory
duplicate-588

Awards

69.0905 USDC - $69.09

External Links

Lines of code

https://github.com/code-423n4/2023-01-astaria/blob/main/src/PublicVault.sol#L251-L265 https://github.com/AstariaXYZ/astaria-gpl/blob/4b49fe993d9b807fe68b3421ee7f2fe91267c9ef/src/ERC4626-Cloned.sol#L112

Vulnerability details

Description

The first deposit with a totalSupply of zero shares will mint shares equal to the deposited amount.

File: lib/gpl/src/ERC4626-Cloned.sol

112:     return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets());

Link to Code

File: PublicVault.sol

    function deposit(uint256 amount, address receiver)
      public
      override(ERC4626Cloned)
      whenNotPaused
      returns (uint256)
    {
      VIData storage s = _loadVISlot();
      if (s.allowListEnabled) {
        require(s.allowList[receiver]);
      }

      uint256 assets = totalAssets();

      return super.deposit(amount, receiver);
    }

Link to Code

Problems with the code:

  1. Integer division negatively affect the user.
  2. Can be manipulated to cause a large loss, specifically for first victim.

Impact

It can lead to some part of Fund getting stolen from First Depositor (which will be the LP Provider).

Proof of Concept

Consider the following situation:

  1. Attacker deposits 1 wei of WETH.
  2. Next, Attacker transfers 100 WETH to the contract.
  3. Victim deposits 200 WETH.
  4. Attacker withdraws 1 share.

Here is the Detail analysis of the above PoC done by Spearbit.

This analysis confirms this clear Path of attack which can be used by the attacker.

Tools Used

Manual Review

  1. Need to Enforce a minimum deposit that can't be withdrawn.
  2. So, mint some of the initial amount to the zero address.
  3. Most legit first depositors will mint thousands of shares, so not a big cost.

#0 - c4-judge

2023-01-23T16:16:20Z

Picodes marked the issue as primary issue

#1 - c4-judge

2023-01-23T16:20:53Z

Picodes marked the issue as duplicate of #588

#2 - c4-judge

2023-02-24T10:22:17Z

Picodes 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