Lender can reject closing a position
The lender can reject the closing of a credit line by reverting the token transfer when the credit token is native ETH or an ERC-777 token with receiver hooks. This prevents the borrower from closing the credit line, which blocks migration to a new line, releasing a spigot, and sweeping remaining tokens.
berndartmueller Follow with R2, minhquanym and 3 others
Originally disclosed on Code4rena
Submitted by berndartmueller, also found by R2, minhquanym, Jeiwan, ayeslick, and 0xdeadbeef0x
A credit line can be closed by using the LineOfCredit.depositAndClose() or LineOfCredit.close. The remaining funds deposited by the lender (credit.deposit) and the accumulated and paid interest are transferred to the lender.
However, if the used credit token credit.token is native ETH (or an ERC-777 token with receiver hooks, and under the assumption that the oracle supports this asset in the first place), the lender can reject the closing of the credit by reverting the token transfer.
Impact
The lender can prevent the borrower from closing the credit line. This leads to the following consequences:
- Migrating (rollover) to a new line is not possible (it requires all credits to be closed, see SecuredLine.sol#L55)
- Releasing a spigot and transferring ownership to the borrower is not possible (see SpigotedLineLib.sol#L195)
- Sweeping remaining tokens (e.g. revenue tokens) in the Spigot to the borrower is not possible (see SpigotedLineLib.sol#L220)
Proof of Concept
modules/credit/LineOfCredit.sol#L489-L493
function _close(Credit memory credit, bytes32 id) internal virtual returns (bool) {
if(credit.principal > 0) { revert CloseFailedWithPrincipal(); }
// return the Lender's funds that are being repaid
if (credit.deposit + credit.interestRepaid > 0) {
LineLib.sendOutTokenOrETH(
credit.token,
credit.lender,
credit.deposit + credit.interestRepaid
);
}
delete credits[id]; // gas refunds
// remove from active list
ids.removePosition(id);
unchecked { --count; }
// If all credit lines are closed the the overall Line of Credit facility is declared 'repaid'.
if (count == 0) { _updateStatus(LineLib.STATUS.REPAID); }
emit CloseCreditPosition(id);
return true;
}
Recommended Mitigation Steps
Consider using a pull-based pattern to allow the lender to withdraw the funds instead of sending them back directly.
kibagateaux (Debt DAO) confirmed
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 contract sends funds directly to the lender during closing, and the lender can revert the transfer if the token is native ETH or an ERC-777 token with receiver hooks.
Impact
The lender can prevent the borrower from closing the credit line, which blocks migration to a new line, releasing a spigot, and sweeping remaining tokens.
What the attacker needed
Credit token is native ETH or ERC-777 with hooks; oracle supports the asset; lender is malicious or able to revert
The fix
The report recommends using a pull-based pattern so the lender withdraws funds instead of receiving them directly during closing.
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 smart contract, when a function sends ETH or certain tokens to another address, that address can run code that refuses the payment. Here, the lender uses that ability to make the closing function fail, so the borrower cannot finish closing the credit line.
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.