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.
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
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
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);
}
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
- Call _commitToLien with a lien duration of 50 days, which exceeds two epochs.
- 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.