Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LSP6] Add REENTRANCYBOOLEAN to AllowedCalls #138

Open
skimaharvey opened this issue Nov 19, 2022 · 1 comment
Open

[LSP6] Add REENTRANCYBOOLEAN to AllowedCalls #138

skimaharvey opened this issue Nov 19, 2022 · 1 comment

Comments

@skimaharvey
Copy link
Member

skimaharvey commented Nov 19, 2022

Withexecute(...):

All reentrant calls will happen in the context of a call so in order to be successful contracts with REENTRANT permission will also need to have some AllowedCalls permissions.

if a contract has:

  • REENTRANT permission
  • list of multiple allowed calls (one call that will mint and another one that will approve for example)

At the moment I cannot limit the reentrancy to a specific call (for example approve call).

WithexecuteRelayCall(...):

If a signer has the reentrancy permission. All his signed payload could possibly be used in a reentrancy context. However With the below solution we can also limit it to signer + specific allowed calls

Solution

I think we could modify our allowed call standard and append it by 1 byte related to Reantrancy.

The new standard could be:
Standard:Address:Function:ReentrancyBool

Implementation

When verifying AllowedCalls, since we know whether the call is a reentrant call, we can add a bool isReentrantCallparameters to _verifyAllowedCall(...) and check if this particular call is allowed as a reentrant call.

        function _verifyAllowedCall(..., bool isReentrantCall) internal view {
        ...
        bool isAllowedReentrant = true;

        for (uint256 ii = 0; ii < allowedCallsLength; ii += 30) {

            bytes memory chunk = BytesLib.slice(allowedCalls, ii + 1, 29);
            ...
            //if isReentrantCall is true, we check that the last byte value is FF
            if(isReentrantCall && bytes1(bytes29(chunk) << 224) != 0xFF) {
                isAllowedReentrant = false;
            }

            if (isAllowedStandard && isAllowedAddress && isAllowedFunction && isAllowedReentrant) return;
        }

        revert NotAllowedCall(from, to, selector);
    }
@CJ42
Copy link
Member

CJ42 commented Oct 17, 2023

Should we add it to the callTypes when checking the Allowed Calls?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants