✅Truster
Description
More and more lending pools are offering flash loans. In this case, a new pool has launched that is offering flash loans of DVT tokens for free.
The pool holds 1 million DVT tokens. You have nothing.
To pass this challenge, take all tokens out of the pool. If possible, in a single transaction.
TL;DR
The flashLoan() contains RCE bug where we can call arbitrary function on behalf of the pool. Just call approve() to give ourselves unlimited allowance then withdraw all the tokens.
Code Audit
Our objective is to drain the pool via flash loan within one transaction. Check out the flashLoan() function:
The external call target.functionCall(data) looks suspicious. What is this functionCall() thing? It is a utility function defined in OpenZeppelin contract, nasically it is a safe wrapper of the low-level call:
There are many things that we can do in this external call. For example, we can set target == damnValuableToken and call approve() to approve the attacker to handle all the fund in this pool. If we specify amount == 0, then there is no flash loan needs to be paid. In the attack contract, the call to flashLoan() looks like the following:
Building PoC
Approve attack for unlimited amount via the RCE and transfer out all the dvt tokens:

Last updated

