Skip to content
Business logic Audit finding Intermediate

new loans "max duration" is not restricted

The PublicVault contract did not enforce the documented limit that new loan durations must not exceed the end of the next epoch. An attacker could create loans with durations longer than two epochs, violating the intended restriction.

bin2chen Follow

Originally disclosed on Sherlock

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

Found by

bin2chen

Summary

document : " Epochs PublicVaults operate around a time-based epoch system. An epoch length is defined by the strategist that deploys the PublicVault. The duration of new loans is restricted to not exceed the end of the next epoch. For example, if a PublicVault is 15 days into a 30-day epoch, new loans must not be longer than 45 days. " but more than 2 epoch's duration can be added

Vulnerability Detail

the max duration is not detected. add success when > next epoch

#AstariaTest#testBasicPublicVaultLoan

Solidity
  function testBasicPublicVaultLoan() public {

  IAstariaRouter.LienDetails memory standardLien2 =
    IAstariaRouter.LienDetails({
      maxAmount: 50 ether,
      rate: (uint256(1e16) * 150) / (365 days),
      duration: 50 days,  /****** more then 14 * 2 *******/
      maxPotentialDebt: 50 ether
    });    

    _commitToLien({
      vault: publicVault,
      strategist: strategistOne,
      strategistPK: strategistOnePK,
      tokenContract: tokenContract,
      tokenId: tokenId,
      lienDetails: standardLien2, /**** use standardLien2 ****/
      amount: 10 ether,
      isFirstLien: true
    });
  }

Impact

Too long duration

Code Snippet

https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/VaultImplementation.sol#L209

Tool used

Manual Review

Recommendation

PublicVault#_afterCommitToLien

Solidity
  function _afterCommitToLien(uint256 lienId, uint256 amount)
    internal
    virtual
    override
  {
    // increment slope for the new lien
    unchecked {
      slope += LIEN_TOKEN().calculateSlope(lienId);
    }

    ILienToken.Lien memory lien = LIEN_TOKEN().getLien(lienId);

    uint256 epoch = Math.ceilDiv(
      lien.start + lien.duration - START(),
      EPOCH_LENGTH()
    ) - 1;

+   require(epoch <= currentEpoch + 1,"epoch max <= currentEpoch + 1");

    liensOpenForEpoch[epoch]++;
    emit LienOpen(lienId, epoch);
  }


The original report as published on Sherlock, by bin2chen. 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 _afterCommitToLien function in PublicVault did not verify that the loan's end epoch was within the allowed limit.

Impact

Loans could be created with durations longer than the documented maximum, potentially locking funds for extended periods.

What the attacker needed

Access to the PublicVault contract

The fix

The code should be fixed by adding a require statement in _afterCommitToLien to ensure the calculated epoch is not greater than currentEpoch + 1.

How it was found

  1. Call _commitToLien with a lien duration of 50 days, which exceeds two epochs.
  2. Observe that the loan is successfully created despite the duration limit.

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 that pools money for lending. The documentation said loans could not last beyond the next epoch (a time period), but the code never checked this. So someone could take out a loan that lasted much longer than allowed.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by bin2chen

View all

139 more disclosed reports, best first.

More from Astaria

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.