You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function _acceptBidWithRepaymentListener(uint256_bidId) internal {
ITellerV2(TELLER_V2).lenderAcceptBid(_bidId); //this gives out the funds to the borrower// @audit repayment listener is set after the ERC777 token is transferred from the borrowerILoanRepaymentCallbacks(TELLER_V2).setRepaymentListenerForBid(
_bidId,
address(this)
);
In case an ERC777 token is used as collateral/principal, the borrower can re-enter during the token deposit/token receival, and repay the loan
function deployAndDeposit(uint256_bidId) external onlyTellerV2 {
if (isBidCollateralBacked(_bidId)) {
(addressproxyAddress, ) =_deployEscrow(_bidId);
_escrows[_bidId] = proxyAddress;
for (
uint256 i;
i < _bidCollaterals[_bidId].collateralAddresses.length();
i++
) {
// @audit re-enter here and repay loan_deposit(
_bidId,
_bidCollaterals[_bidId].collateralInfo[
_bidCollaterals[_bidId].collateralAddresses.at(i)
]
When a loan is repaid, the repayLoanCallback function is supposed to be invoked in-order to increment the totalPrincipalTokensRepaid failure to do which will result in that much tokens forever being considered as still lended
Since in this case repayment listener has not been setup, the totalPrincipalTokensRepaid won't be incremented. This will cause these tokens to forever be non-lendable
Internal pre-conditions
ERC777 should be used as a collateral
External pre-conditions
No response
Attack Path
Pool is created with an ERC777 collateral and has 100 tokens balance
Attacker calls acceptSmartCommitmentWithRecipient in the SmartCommitmentForwarder with 100 as the bid amount
Attacker re-enters when transferring the token and invokes repayLoanFullWithoutCollateralWithdraw
Net result:
totalPrincipalTokensLended == 100
totalPrincipalTokensRepaid == 0
Even though 100 amount has been repaid, causing this amount to be forever non-lendable
Impact
Attacker can cause assets of pool to be non-lendable
PoC
No response
Mitigation
Add nonReentrant modifier in repay functions and lenderAcceptBid function
The text was updated successfully, but these errors were encountered:
Dandy Caramel Tortoise
Medium
ERC-777 reentrancy will allow an attacker to permenantly cause some assets to be non-loanable in a LenderGroup
Summary
ERC-777 reentrancy will allow an attacker to permenantly cause some assets to be non-loanable in a LenderGroup
Root Cause
In the readme the team has mentioned that they would like to know if any wierd token breaks their contract pools.
The
repaymentListener
is set after the loan is acceptedIn case an ERC777 token is used as collateral/principal, the borrower can re-enter during the token deposit/token receival, and repay the loan
When a loan is repaid, the repayLoanCallback function is supposed to be invoked in-order to increment the
totalPrincipalTokensRepaid
failure to do which will result in that much tokens forever being considered asstill lended
Since in this case repayment listener has not been setup, the
totalPrincipalTokensRepaid
won't be incremented. This will cause these tokens to forever be non-lendableInternal pre-conditions
External pre-conditions
No response
Attack Path
acceptSmartCommitmentWithRecipient
in the SmartCommitmentForwarder with 100 as the bid amountrepayLoanFullWithoutCollateralWithdraw
Net result:
totalPrincipalTokensLended == 100
totalPrincipalTokensRepaid == 0
Even though 100 amount has been repaid, causing this amount to be forever non-lendable
Impact
Attacker can cause assets of pool to be non-lendable
PoC
No response
Mitigation
Add nonReentrant modifier in repay functions and lenderAcceptBid function
The text was updated successfully, but these errors were encountered: