Skip to content
Business logic Audit finding Intermediate

A payment made towards multiple liens causes the borrower to lose funds to the payee

A bulk payment function for multiple liens incorrectly sends the entire payment amount to the first lien's payee, even if it exceeds that lien's amount, leaving other liens unpaid. The borrower loses funds to the payee.

0xRajeev Follow with obront, zzykxx and 1 other

Originally disclosed on Sherlock

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

Found by

0xRajeev, obront, zzykxx, Jeiwan

Summary

A payment made towards multiple liens is entirely consumed for the first one causing the borrower to lose funds to the payee.

Vulnerability Detail

A borrower can make a bulk payment against multiple liens for a collateral hoping to pay more than one at a time using makePayment (uint256 collateralId, uint256 paymentAmount) where the underlying _makePayment() loops over the open liens attempting to pay off more than one depending on the totalCapitalAvailable provided.

However, the entire totalCapitalAvailable is provided via paymentAmount in the call to _payment() in the first iteration which transfers that completely to the payee in its logic even if it exceeds that lien.amount. That total amount is returned as capitalSpent which makes the paymentAmount for next iteration equal to 0.

Impact

Only the first lien is paid off and the entire payment is sent to its payee. The remaining liens remain unpaid. The payment maker (i.e. borrower ) loses funds to the payee.

Code Snippet

  1. https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/LienToken.sol#L387-L389
  2. https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/LienToken.sol#L410-L424
  3. https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/LienToken.sol#L630-L645

Tool used

Manual Review

Recommendation

Add paymentAmount -= lien.amount in the else block of _payment().

Discussion

IAmTurnipBoy

Escalate for 1 USDC

Clear loss of funds. Should be high

sherlock-admin

Escalate for 1 USDC

Clear loss of funds. Should be high

You've created a valid escalation for 1 USDC!

To remove the escalation from consideration: Delete your comment. To change the amount you've staked on this escalation: Edit your comment (do not create a new comment).

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

Evert0x

Escalation accepted

sherlock-admin

Escalation accepted

This issue's escalations have been accepted!

Contestants' payouts and scores will be updated according to the changes made on this issue.

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 payment loop does not subtract the amount paid to each lien from the remaining payment amount, so the full amount is passed to the first lien and then zero remains for subsequent liens.

Impact

The borrower loses funds to the first lien's payee, and the remaining liens remain unpaid.

What the attacker needed

Borrower has multiple liens; borrower makes a bulk payment

The fix

The code should subtract the lien amount from the payment amount in the else block of _payment() to ensure only the necessary amount is sent to each lien.

How it was found

  1. Borrower calls makePayment with a paymentAmount covering multiple liens.
  2. The function loops over open liens, calling _payment with the full paymentAmount on the first iteration.
  3. _payment transfers the entire paymentAmount to the first lien's payee, even if it exceeds that lien's amount.
  4. The returned capitalSpent equals the full paymentAmount, so the next iteration's paymentAmount becomes zero.
  5. Remaining liens are not paid, and the borrower loses the excess funds.

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.

When a borrower tries to pay off several debts at once, the system mistakenly gives all the money to the first debt collector, even if that debt is smaller. The other debts don't get paid, and the borrower loses the extra money.

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

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.