The flashLoan() function enables users to access instant liquidity from asset reserves or by directly minting usdm tokens. An external call is made to a recipient contract which adheres to the IERC3156FlashBorrower interface before transferring the amount and fee back to the contract. As a result, there may be unintended consequences if a user could reenter and effectively receive more tokens than they need to transfer back to the contract. Currently, this is not exploitable but an alternative attack vector may enable an attacker to steal funds.
Handle
leastwood
Vulnerability details
Impact
The
flashLoan()
function enables users to access instant liquidity from asset reserves or by directly mintingusdm
tokens. An external call is made to a recipient contract which adheres to theIERC3156FlashBorrower
interface before transferring the amount and fee back to the contract. As a result, there may be unintended consequences if a user could reenter and effectively receive more tokens than they need to transfer back to the contract. Currently, this is not exploitable but an alternative attack vector may enable an attacker to steal funds.Proof of Concept
https://github.com/code-423n4/2021-10-mochi/blob/main/projects/mochi-core/contracts/vault/MochiVault.sol#L356-L373 https://github.com/code-423n4/2021-10-mochi/blob/main/projects/mochi-core/contracts/assets/usdm.sol#L59-L76
Tools Used
Manual code review
Recommended Mitigation Steps
Consider utilising OpenZeppelin's
ReentrancyGuard
library to prevent users from reentering theflashLoan()
function.