-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #971 from lukso-network/test-lsp26-for-return-bomb…
…-attack test: add extreme case tests
- Loading branch information
Showing
4 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
packages/lsp26-contracts/contracts/mock/InfiniteLoopURD.sol
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,24 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.17; | ||
|
||
// interfaces | ||
import { | ||
ILSP1UniversalReceiver | ||
} from "@lukso/lsp1-contracts/contracts/ILSP1UniversalReceiver.sol"; | ||
|
||
contract InfiniteLoopURD is ILSP1UniversalReceiver { | ||
uint256 public counter; | ||
|
||
function supportsInterface(bytes4) external pure returns (bool) { | ||
return true; | ||
} | ||
|
||
function universalReceiver( | ||
bytes32, | ||
bytes memory | ||
) external payable returns (bytes memory) { | ||
while (true) { | ||
++counter; | ||
} | ||
} | ||
} |
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,26 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.17; | ||
|
||
// interfaces | ||
import { | ||
ILSP1UniversalReceiver | ||
} from "@lukso/lsp1-contracts/contracts/ILSP1UniversalReceiver.sol"; | ||
|
||
contract ReturnBomb is ILSP1UniversalReceiver { | ||
uint256 public counter; | ||
|
||
function supportsInterface(bytes4) external pure returns (bool) { | ||
return true; | ||
} | ||
|
||
function universalReceiver( | ||
bytes32, | ||
bytes memory | ||
) external payable returns (bytes memory) { | ||
++counter; | ||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
revert(0, 10000) | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/lsp26-contracts/contracts/mock/SelfDestructOnInterfaceCheck.sol
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,23 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.17; | ||
|
||
// interfaces | ||
import { | ||
ILSP1UniversalReceiver | ||
} from "@lukso/lsp1-contracts/contracts/ILSP1UniversalReceiver.sol"; | ||
|
||
contract SelfDestructOnInterfaceCheck is ILSP1UniversalReceiver { | ||
uint256 public counter; | ||
|
||
function supportsInterface(bytes4) external returns (bool) { | ||
selfdestruct(payable(msg.sender)); | ||
return true; | ||
} | ||
|
||
function universalReceiver( | ||
bytes32, | ||
bytes memory | ||
) external payable returns (bytes memory) { | ||
return ""; | ||
} | ||
} |
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