Developer @ Aave here, good questions.
- It depends on your contract. But a simple one would be:
- Contract A has funds and the
executeOperation()
- Contract B calls
flashloan()
, passing in Contract A as the receiverAddress
- Contract A now executes
executeOperation()
- Contract A repays the flash loaned amount and debt as designed
The attack would be an attacker contract also passing in Contract A as the receiverAddress
.
- In the above example, if you are doing profitable arbitrage trades with flash loans, it is possible that you're leaving profits on Contract A. So the flash loaned amount is returned, but your profit remain in the contract (if you don't actively transfer them out).