`LienToken.createLien` may prevent liens that satisfy their terms of `maxPotentialDebt`
The potentialDebt calculation in createLien incorrectly multiplies totalDebt by the duration, making the computed debt much higher than it should be. This causes valid lien creations to fail the maxPotentialDebt check and revert, resulting in a denial of service.
0xRajeev Follow with hansfriese
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/192
Found by
0xRajeev, hansfriese
Summary
The potentialDebt calculation in createLien is incorrect.
Vulnerability Detail
The calculated potentialDebt is effectively (impliedRate + totalDebt) * params.terms.duration because getImpliedRate() returns impliedRate = impliedRate.mulDivDown(1, totalDebt);. The calculated potentialDebt because of multiplying totalDebt by duration is significantly higher than it actually is and so will fail the params.terms.maxPotentialDebt check and revert.
Impact
This will cause DoS on valid lien creation.
Code Snippet
- https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/LienToken.sol#L256-L260
- https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/LienToken.sol#L526
Tool used
Manual Review
Recommendation
Have getImpliedRate() not do impliedRate = impliedRate.mulDivDown(1, totalDebt); and calculate potentialDebt as totalDebt * (1 + impliedRate * params.terms.duration * mulDivDown(1, INTEREST_DENOMINATOR).
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 getImpliedRate function divides the implied rate by totalDebt, and then potentialDebt is calculated by multiplying totalDebt by duration, leading to an incorrect large value.
Impact
This could cause a denial of service on valid lien creation, preventing users from creating liens that should satisfy the terms.
What the attacker needed
None
The fix
The getImpliedRate function should not divide by totalDebt, and potentialDebt should be calculated as totalDebt multiplied by (1 + impliedRate * duration / INTEREST_DENOMINATOR).
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 smart contract function that creates loans (liens) calculates a value called potentialDebt to check it against a maximum allowed by the loan terms. Because of a mistake in the calculation, the value becomes too large, so the check fails and the loan cannot be created even when it should be allowed. This blocks legitimate users from using the service.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.