On May-15–2022 08:22:49 PM +UTC, the FEG token has experienced a flurry of flashloan attacks on both Ethereum and BNBChain, leading to approximately $1.3M worth of assets loss. This vulnerability is due to a flaw in the “swapToSwap()” function that directly takes user input “path” as a trusted party yet without any data validation. Furthermore, the function will approve the unprotected “path” parameter to spend the asset in the current address. Therefore, by repeatedly calling “depositInternal()” and “swapToSwap()”, the attacker is able to launch an attack that gains unlimited allowance and thus drains all the assets within the contract.
One of the affected contract address: https://bscscan.com/address/0x818e2013dd7d9bf4547aaabf6b617c1262578bc7
Exploiter Address: https://bscscan.com/address/0x73b359d5da488eb2e97990619976f2f004e9ff7c
Sample exploit transaction: https://bscscan.com/tx/0x77cf448ceaf8f66e06d1537ef83218725670d3a509583ea0d161533fda56c063
Attacker fund transfer tracing: https://debank.com/profile/0x73b359d5da488eb2e97990619976f2f004e9ff7c/history
Attacker Address: https://bscscan.com/address/0x73b359d5da488eb2e97990619976f2f004e9ff7c
Attacker Exploit Contract: https://bscscan.com/address/0x9a843bb125a3c03f496cb44653741f2cef82f445
FEG Token Address: https://bscscan.com/token/0xacfc95585d80ab62f67a14c566c1b7a49fe91167
FEG Wrapped BNB (fBNB): https://bscscan.com/address/0x87b1acce6a1958e522233a737313c086551a5c76#code
The following attack flow is based on this exploit transaction.
This vulnerability is due to a flaw in the “swapToSwap()” function that directly takes user input “path” as a trusted party yet without any sanitations. Furthermore, the function will approve the unprotected “path” parameter to spend the asset in the current address. Therefore, by repeatedly calling “depositInternal()” and “swapToSwap()”, the attacker is able to launch an attack that gains unlimited allowance and thus drains all the assets within the contract.
As of May-15–2022 10:43 PM , the funds lies in the attacker wallet(0x73b359d5da488eb2e97990619976f2f0014e9ff7c) on both Ethereum and BSC chain.
Original Funds were from Tornado cash on Ethereum and BSC: https://etherscan.io/tx/0x0ff1b86c9e8618a088f8818db7d09830eaec42b82974986c855b207d1771fdbe
https://bscscan.com/tx/0x5bbf7793f30d568c40aa86802d63154f837e781d0b0965386ed9ac69a16eb6ab
The attacker attacked 13 FEGexPRO contracts. Here is the summary:
Would we spot the issue during the audit?
In an audit, auditors would notice that the untrusted “path” parameter is passed to the protocol and approved for spending assets of the contract. This would is dangerous and would be flagegd as “Major’ severity. Furthermore, if the auditors explored deeper they would discover the exploit scenario and highlight it.