Skip to content
DoS Audit finding Intermediate

`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

  1. https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/LienToken.sol#L256-L260
  2. 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).

The original report as published on Sherlock, by 0xRajeev. 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 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.

More by 0xRajeev

View all

61 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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.