Skip to content
Access control Audit finding Intermediate

LiquidityProvider can also lend to PrivateVault

The lendToVault function only checked that a vault address existed in the vaults mapping, which also contains PrivateVaults, so any liquidity provider could deposit funds into a private vault. This let unexpected liquidity providers lend to private vaults, contrary to the documented design.

neila Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/141

Found by

neila

Summary

Insufficient access control for lending to PublicVault found by yawn-c111

Vulnerability Detail

Docs says as follows https://docs.astaria.xyz/docs/intro

Any strategists may provide their own capital to fund these loans through their own PrivateVaults, and whitelisted strategists can deploy PublicVaults that accept funds from other liquidity providers.

However, Liquidity Providers can also lend to PrivateVault.

This is because lendToVault function is controlled by mapping(address => address) public vaults, which are managed by _newVault function and include PrivateVaults

This leads to unexpected atttack.

Impact

Unexpected liquidity providers can lend to private vaults

Code Snippet

https://github.com/unchain-dev/2022-10-astaria-UNCHAIN/blob/main/src/AstariaRouter.sol#L324

Solidity
function lendToVault(IVault vault, uint256 amount) external whenNotPaused {
    TRANSFER_PROXY.tokenTransferFrom(
      address(WETH),
      address(msg.sender),
      address(this),
      amount
    );

    require(
      vaults[address(vault)] != address(0),
      "lendToVault: vault doesn't exist"
    );
    WETH.safeApprove(address(vault), amount);
    vault.deposit(amount, address(msg.sender));
  }

https://github.com/unchain-dev/2022-10-astaria-UNCHAIN/blob/main/src/AstariaRouter.sol#L500

Solidity
function _newVault(
    uint256 epochLength,
    address delegate,
    uint256 vaultFee
  ) internal returns (address) {
    uint8 vaultType;

    address implementation;
    if (epochLength > uint256(0)) {
      require(
        epochLength >= minEpochLength && epochLength <= maxEpochLength,
        "epochLength must be greater than or equal to MIN_EPOCH_LENGTH and less than MAX_EPOCH_LENGTH"
      );
      implementation = VAULT_IMPLEMENTATION;
      vaultType = uint8(VaultType.PUBLIC);
    } else {
      implementation = SOLO_IMPLEMENTATION;
      vaultType = uint8(VaultType.SOLO);
    }

    //immutable data
    address vaultAddr = ClonesWithImmutableArgs.clone(
      implementation,
      abi.encodePacked(
        address(msg.sender),
        address(WETH),
        address(COLLATERAL_TOKEN),
        address(this),
        address(COLLATERAL_TOKEN.AUCTION_HOUSE()),
        block.timestamp,
        epochLength,
        vaultType,
        vaultFee
      )
    );

    //mutable data
    VaultImplementation(vaultAddr).init(
      VaultImplementation.InitParams(delegate)
    );

    vaults[vaultAddr] = msg.sender;

    emit NewVault(msg.sender, vaultAddr);

    return vaultAddr;
  }

Tool used

Manual Review

Recommendation

create requirement to lend to only PublicVaults.

The original report as published on Sherlock, by neila. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the lendToVault function checked only that the vault was registered in the vaults mapping, which includes both public and private vaults, instead of restricting deposits to public vaults.

What the attacker needed

A registered PrivateVault address; funds to deposit

The fix

The lendToVault function should be changed to require that the target vault is a PublicVault before accepting a deposit.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A vault is a smart contract pool that holds money for lending. The project intended private vaults to be funded only by their owner, but the deposit function only checked that the vault was registered, not whether it was public, so anyone could put money into a private vault.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More from Astaria

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.