Skip to content
Business logic Audit finding Intermediate

At claimDefaulted, the lender may not receive the token because the Unclaimed token is not processed

The claimDefaulted function deletes loan data without first processing any unclaimed tokens, so the lender cannot later retrieve those tokens. An attacker could call claimDefaulted while unclaimed tokens exist, causing the lender to lose access to them.

0xMAKEOUTHILL Follow with Chinmay, Negin and 7 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-08-cooler-judging/issues/119

Found by

0xMAKEOUTHILL, Chinmay, Negin, banditx0x, deadrxsezzz, jkoppel, klaus, mahdikarimi, pengun, xAlismx

claimDefaulted does not handle loan.unclaimed . This preventing the lender from receiving the debt repayment.

Vulnerability Detail

Solidity
function claimDefaulted(uint256 loanID_) external returns (uint256, uint256, uint256) {
  Loan memory loan = loans[loanID_];
  delete loans[loanID_];

Loan data is deletead in claimDefaulted function. loan.unclaimed is not checked before data deletead. So, if claimDefaulted is called while there are unclaimed tokens, the lender will not be able to get the unclaimed tokens.

Impact

Lender cannot get unclaimed token.

Code Snippet

https://github.com/sherlock-audit/2023-08-cooler/blob/6d34cd12a2a15d2c92307d44782d6eae1474ab25/Cooler/src/Cooler.sol#L318-L320

Tool used

Manual Review

Recommendation

Process unclaimed tokens before deleting loan data.

Diff
function claimDefaulted(uint256 loanID_) external returns (uint256, uint256, uint256) {
+   claimRepaid(loanID_)
    Loan memory loan = loans[loanID_];
    delete loans[loanID_];

Discussion

0xRusowsky

jkoppel

Fix approved.

The original report as published on Sherlock, by 0xMAKEOUTHILL. 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 claimDefaulted function deletes the loan data without first calling claimRepaid to process unclaimed tokens.

Impact

The lender cannot get the unclaimed tokens, resulting in a loss of funds for the lender.

What the attacker needed

Unclaimed tokens exist for the loan

The fix

The fix should process unclaimed tokens (e.g., by calling claimRepaid) before deleting the loan data; the text indicates a fix was approved.

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.

In a lending contract, a lender may have tokens that are owed to them but not yet withdrawn. The function that handles a defaulted loan deletes the loan record without first paying out those owed tokens. Once the record is gone, the lender has no way to claim them.

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 0xMAKEOUTHILL

View all

4 more disclosed reports, best first.

More from Cooler Update

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.