#46608 [SC-Medium] Any call to the repay function can potentially be front-run by a malicious actor, lead to prevent users from repaying on time.
Description
Brief/Intro
Vulnerability Details
function repay(string memory _loanId, uint256 repayAmt, uint256 removeCollateralAmt) external nonReentrant {
bytes32 loanId = _loanId.toBytes32();
LoanInfo memory loanInfo = loans[loanId];
loanInfo.repay(repayAmt);
if (removeCollateralAmt > 0) {
loanInfo.checkBorrower(loanId, msg.sender);
loanInfo.removeCollateral(removeCollateralAmt, _oracle);
}
IERC20(loanInfo.debtTokenAddr).safeTransferFrom(msg.sender, loanInfo.lender, repayAmt);
if (removeCollateralAmt > 0) {
IERC20(loanInfo.collateralTokenAddr).safeTransferFrom(
loanInfo.lender, loanInfo.borrower, removeCollateralAmt
);
}
if (loanInfo.debtData.debtAmt == 0 && loanInfo.debtData.collateralAmt == 0) {
delete loans[loanId];
} else {
loans[loanId] = loanInfo;
}
emit Repaid(loanId, repayAmt, removeCollateralAmt);
}
Impact Details
Recommend
Proof of Concept
Proof of Concept
Previous#46819 [SC-Critical] direct theft of users funds when expired loan get liquidatedNext#46903 [SC-Critical] malicious borrower can take theft of other borrower collateral
Was this helpful?