-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ud/evm-event
- Loading branch information
Showing
7 changed files
with
450 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
316 changes: 316 additions & 0 deletions
316
...embeds/artifacts/contracts/TestInfiniteRecursionERC20.sol/TestInfiniteRecursionERC20.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "./IFunToken.sol"; | ||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
||
contract TestInfiniteRecursionERC20 is ERC20 { | ||
constructor(string memory name, string memory symbol, uint8 decimals_) | ||
ERC20(name, symbol) { | ||
_mint(msg.sender, 1000000 * 10**18); | ||
} | ||
|
||
function balanceOf(address who) public view virtual override returns (uint256) { | ||
// recurse through funtoken.balance(who, address(this)) | ||
address(FUNTOKEN_PRECOMPILE_ADDRESS).staticcall( | ||
abi.encodeWithSignature( | ||
"balance(address,address)", | ||
who, | ||
address(this)) | ||
); | ||
return 0; | ||
} | ||
|
||
function transfer(address to, uint256 amount) public override returns (bool) { | ||
// recurse through funtoken sendToBank | ||
FUNTOKEN_PRECOMPILE.sendToBank( | ||
address(this), | ||
amount, | ||
"nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl" // does not matter, it's not reached | ||
); | ||
return true; | ||
} | ||
|
||
function attackBalance() public { | ||
balanceOf(address(0)); | ||
} | ||
|
||
function attackTransfer() public { | ||
transfer(address(0), 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters