When a private vault offers a loan in ERC777 tokens, the private vault can refuse to receive repayment in the safeTransferFrom callback to force liquidation of the borrower’s collateral
When a private vault lends ERC777 tokens, the vault owner can refuse to receive repayment in the token's transfer callback, preventing the borrower from repaying. The borrower's collateral can then be liquidated when the loan expires.
cccz Follow with KIntern_NA and cccz
Originally disclosed on Code4rena
Submitted by cccz, also found by KIntern_NA and cccz
When the borrower calls LienToken.makePayment to repay the loan, safeTransferFrom is used to send tokens to the recipient of the vault, which in the case of a private vault is the owner of the private vault.
s.TRANSFER_PROXY.tokenTransferFrom(stack.lien.token, payer, payee, amount);
...
function tokenTransferFrom(
address token,
address from,
address to,
uint256 amount
) external requiresAuth {
ERC20(token).safeTransferFrom(from, to, amount);
}
...
function recipient() public view returns (address) {
if (IMPL_TYPE() == uint8(IAstariaRouter.ImplementationType.PublicVault)) {
return address(this);
} else {
return owner();
}
}
If the token for the loan is an ERC777 token, a malicious private vault owner can refuse to receive repayment in the callback, which results in the borrower not being able to repay the loan and the borrower’s collateral being auctioned off when the loan expires.
Proof of Concept
https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/LienToken.sol#L849-L850 https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/TransferProxy.sol#L28-L35 https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/LienToken.sol#L900-L909 https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/VaultImplementation.sol#L366-L372
Recommended Mitigation Steps
For private vaults, when the borrower repays, sending tokens to the vault, and the private vault owner claims it later.
androolloyd (Astaria) acknowledged and commented via duplicate issue #248:
ERC777 issues can be quite problematic, the procotol isn’t designed to work with 777, fee on transfer tokens, rebasing tokens.
Flagging as duplicate of this issue all findings related to the lack of ERC777 support.
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 repayment path sends tokens directly to the vault owner using safeTransferFrom, which triggers the ERC777 recipient hook, and a revert in that hook blocks repayment.
Impact
The borrower cannot repay and their collateral could be auctioned off when the loan expires; the protocol is not designed to support ERC777 tokens.
What the attacker needed
Loan in an ERC777 token; private vault controlled by attacker; borrower attempts repayment
The fix
For private vaults, repayment should send tokens to the vault itself, with the owner claiming them later.
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.
Some tokens (ERC777) let the receiver run code when they get a payment. A lender can use that code to reject the repayment, so the borrower cannot pay back the loan. The borrower then loses their collateral when the loan is due.
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.