prePO contest - wuwe1's results

Gain exposure to pre-IPO companies & pre-token projects.

General Information

Platform: Code4rena

Start Date: 17/03/2022

Pot Size: $30,000 USDC

Total HM: 8

Participants: 43

Period: 3 days

Judge: gzeon

Total Solo HM: 5

Id: 100

League: ETH

prePO

Findings Distribution

Researcher Performance

Rank: 37/43

Findings: 1

Award: $50.85

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Awards

50.8486 USDC - $50.85

Labels

bug
QA (Quality Assurance)
disagree with severity

External Links

Lines of code

https://github.com/code-423n4/2022-03-prepo/blob/main/contracts/core/Collateral.sol#L61

Vulnerability details

Proof of Concept

https://github.com/code-423n4/2022-03-prepo/blob/main/contracts/core/Collateral.sol#L61

uint256 _amountToDeposit = _baseToken.balanceOf(address(this));

Amount to deposit is balance of the contract.

  1. Alice --- transfer 100 usdc ---> Collateral
  2. bob --- deposit(0) ---> Collateral

Consider use calldata amount instead of _baseToken.balanceOf(address(this))

function deposit(uint256 _amount)
    external
    override
    nonReentrant
    returns (uint256)
{
    require(_depositsAllowed, "Deposits not allowed");
    _baseToken.safeTransferFrom(msg.sender, address(this), _amount);
    // Record deposit before fee is taken
    if (address(_depositHook) != address(0)) {
        _depositHook.hook(msg.sender, _amount, _amount);
    }
    /**
     * Add 1 to avoid rounding to zero, only process deposit if user is
     * depositing an amount large enough to pay a fee.
     */
    uint256 _fee = (_amount * _mintingFee) / FEE_DENOMINATOR + 1;
    require(_amount > _fee, "Deposit amount too small");
    _baseToken.safeTransfer(_treasury, _fee);
    _amount -= _fee;

    uint256 _valueBefore = _strategyController.totalValue();
    _baseToken.approve(address(_strategyController), _amount);
    _strategyController.deposit(_amount);
    uint256 _valueAfter = _strategyController.totalValue();
    _amount = _valueAfter - _valueBefore;

    uint256 _shares = 0;
    if (totalSupply() == 0) {
        _shares = _amount;
    } else {
        /**
         * # of shares owed = amount deposited / cost per share, cost per
         * share = total supply / total value.
         */
        _shares = (_amount * totalSupply()) / (_valueBefore);
    }
    _mint(msg.sender, _shares);
    return _shares;
}

#0 - ramenforbreakfast

2022-03-22T23:44:45Z

This is a documentation issue. We intended our vault to follow this convention to allow contracts to atomically batch a transfer of assets to the contract and call deposit, instead of approving and having their assets transferFrom'd.

#1 - gzeoneth

2022-04-03T14:02:55Z

Not an issue if fund is donated to the contract, downgrading to Low/QA. Treating this as user's QA Report.

#2 - JeeberC4

2022-04-12T18:29:03Z

Per judge downgrading to QA Report, preserving original title: _baseToken sent directly to Collateral contract can be took by anyone

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