Submitted by zhaojie, also found by minhquanym
The attackers make it impossible for borrowers to repay their debts, and the collateral is liquidated when the debts mature.
repayLoan needs to check the loanId; if the id is inconsistent it will revert.
The problem is that _loans[_loanId] can change; for example, when mergeTranches deletes the old loanId and writes the new one:
An attacker can use the front-running attack method. When repayLoan is called, execute the mergeTranches function in advance, and make the id in _loans updated. In this case, the repayLoan execution will fail due to inconsistent _loanId.
If the attacker keeps using this attack, the borrowers debt will not be repaid; eventually causing the collateral to be liquidated.
In addition to the mergeTranches function, the attacker can also call addNewTranche, and the borrower can also call the refinance-related function, again causing _loanId to be updated.
An attacker can also use the same method to attack refinance related functions, making refinance unable to execute. An attacker can also use the same method to attack the liquidateLoan function, making it impossible for debts to be cleared.
VScode
Do not delete _loanId.
DoS
0xA5DF (judge) commented:
0xend (Gondi) confirmed and commented:
0xA5DF (judge) decreased severity to Low and commented:
0xend (Gondi) commented:
zhaojie (warden) commented:
0xA5DF (judge) increased severity to High and commented:
0xend (Gondi) commented:
