Open code423n4 opened 1 year ago
Picodes marked the issue as primary issue
SantiagoGregory marked the issue as sponsor confirmed
Picodes marked the issue as selected for report
Picodes changed the severity to 3 (High Risk)
Picodes marked the issue as satisfactory
Lines of code
https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/LienToken.sol#L849 https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/LienToken.sol#L642-L643
Vulnerability details
If a lender offers a loan denominated in an ERC20 token that blocks transfers to certain addresses (for example, the USDT and USDC blocklist), they may collude with a liquidator (or act as the liquidator themselves) to prevent loan payments, block all bids in the liquidation auction, and seize the borrower's collateral by transferring a
LienToken
to a blocked address.LienTokens
act as bearer assets: if a lender transfers their lien token to another address, the lien's new payee will be theownerOf
the token:LienToken#_getPayee
The payee address returned by
_getPayee
is used as the recipient address of loan repayments viamakePayment
:LienToken#_payment
...as well as post-liquidation payments from the clearinghouse via
payDebtViaClearingHouse
:LienToken#_paymentAH
If an adversary tranfers their
LienToken
to an address that causes these attempted transfers to revert, like an address on the USDC blocklist, the borrower will be unable to make payments on their lien, the loan will eventually qualify for liquidation, and all bids in the Seaport auction will revert when they attempt to send payment to the blocklisted address.Following the failed auction, the liquidator can call
CollateralToken#liquidatorNFTClaim
, which callsClearingHouse#settleLiquidatorNFTClaim
and settles the loan for zero payment, claiming the "liquidated" collateral token for free:ClearingHouse#settleLiquidatorNFTClaim
The lender will lose the amount of their lien, but can seize the borrower's collateral, worth more than their individual lien. Malicious lenders may offer small loans with attractive terms to lure unsuspecting borrowers. Note also that the lender and liquidator can be one and the same—they don't need to be different parties to pull off this attack! A clever borrower could potentially perform this attack as well, by acting as borrower, lender, and liquidator, and buying out one of their own liens by using loaned funds.
(The failed auction liquidation logic above strikes me as a little odd as well: consider whether the liquidator should instead be required to pay a minimum amount covering the bad debt in order to claim the collateral token, rather than claiming it for free).
Impact
Recommendation
This may be difficult to mitigate. Transferring a lien to a blocklisted address is one mechanism for this attack using USDT and USDC, but there are other ways arbitrary ERC20s might revert. Two potential options:
Test case
This test case needs some additional setup: a
CensorableMockERC20
simulating a blocklist, and a few test helpers modified to handle arbitrary ERC20s instead of WETH: