Issue #497 'Add parameter to lender accept bid for MaxMarketFee' from previous audit is still present
Summary
Issue #497 from the previous Sherlock audit was not fixed in the current code and is still present.
Vulnerability Detail
The vulnerability is well explain in the mentionedl link above, essentially any market owner may change the marketplace fee while frontrunning a borrower and getting more funds in return.
A PR with the fix was mentioned in the comments but it was never merged.
From the docs, the issue is valid as long as there is not a won't fix label.
Impact
Borrower pays more marketplace fees than expected due to malicious market owner.
Code Snippet
function lenderAcceptBid(uint256 _bidId)
...
{
...
amountToMarketplace = bid.loanDetails.principal.percent(
marketRegistry.getMarketplaceFee(bid.marketplaceId)
...
}Tool used
Manual Review
Vscode
Recommendation
The recommendation from issue #497 are good:
Add a timelock delay for setMarketFeePercent/setProtocolFee
allow lenders to specify the exact fees they were expecting as a parameter to lenderAcceptBid