
On July 12th, 2024, Dough Finance suffered a significant security breach, falling victim to a flash loan attack that resulted in a loss of approximately $1.8 million. This analysis delves into the details of the exploit, examining the vulnerability within the smart contract and outlining mitigation strategies to prevent future attack
Dough Exploiter 3: 0x34611
Dough Exploiter 4: 0x932e7
Dough Exploiter 5: 0xBA256
Dough Finance’s Contract: 0x9f54e
Attack Transaction: 0x92cdc
The root cause of the vulnerability was found in the ConnectorDeleverageParaswap contract, which failed to validate flash loan callback data properly. This oversight led to the unauthorized transfer of WETH (Wrapped Ether).
function deloopAllCollaterals(bytes[] memory multiTokenSwapData) private {
FlashloanVars memory flashloanVars;
for (uint i = 0; i < multiTokenSwapData.length;) {
// Deloop
(flashloanVars.srcToken, flashloanVars.destToken, flashloanVars.srcAmount, flashloanVars.destAmount, flashloanVars.paraSwapContract, flashloanVars.tokenTransferProxy, flashloanVars.paraswapCallData) = _getParaswapData(multiTokenSwapData[i]);
// using ParaSwap
IERC20(flashloanVars.srcToken).safeIncreaseAllowance(flashloanVars.tokenTransferProxy, flashloanVars.srcAmount);
(flashloanVars.sent, ) = flashloanVars.paraSwapContract.call(flashloanVars.paraswapCallData);
if (!flashloanVars.sent) revert CustomError("ParaSwap deloop failed");
unchecked { i++; }
}
}The deloopAllCollaterals function did not verify the parameters extracted by _getParaswapData, allowing the attacker to craft malicious multiTokenSwapData containing an attacker-controlled tokenTransferProxy address.
During loop execution, the contract used safeIncreaseAllowance to increase the allowance for the attacker's address instead of the intended ParaSwap proxy.
The attacker leveraged this increased allowance to transfer tokens from the contract’s balance to their own address.
As illustrated in the attack flow image above, the contract's original intention was to call ParaSwap. However, due to the vulnerability, the transferFrom method was called instead, resulting in a loss of nearly 608 ETH or $1.8 million.
The attacker subsequently transferred the stolen funds to Tornado Cash, a service often used to obscure transaction trails. In response, DoughFina's team issued an on-chain ultimatum (0xa5eed) to the attacker, seeking to negotiate the return of the stolen funds.

To prevent such exploits in the future, the following best practices should be implemented:
Comprehensive Validation Checks: Ensure all transaction callbacks include thorough validation checks for calldata and sender authenticity, allowing only authorized transactions to proceed.
Read more About Pike Finance Exploit $1.6 million
Author : Piyush shukla