Processes refinance operations may call malicious code by re-created refinancer contract #23
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Lines of code
https://github.com/maple-labs/loan/blob/main/contracts/MapleLoanInternals.sol#L258-L261
Vulnerability details
Impact
When an attacker (borrower) proposes a new term, the attacker can let a lender accept the malicious term which the lender doesn't expect.
It uses delegatecall in
_acceptNewTerms
of MapleLoanInternals.sol. Though a lender can manually check refinancer contract before callingacceptNewTerms
, the attacker (borrower) can still re-create a malicious contract on same address before the lender is callingacceptNewTerms
, and trigger malicious code by delegatecall in_acceptNewTerms
.Proof of Concept
In summary, an attacker can use CREATE2 to re-create a new malicious contract on same address. Here is CREATE2 exploit example: https://x9453.github.io/2020/01/04/Balsn-CTF-2019-Creativity/
proposeNewTerms
, specifying a refinancer contract, and monitoracceptNewTerms
in Mempool.acceptNewTerms
, then quickly pack these transactions:acceptNewTerms
Tools Used
ethers.js
Recommended Mitigation Steps
Also check refinancer contract bytecodes in
_getRefinanceCommitment
:The text was updated successfully, but these errors were encountered: