Skip to content

Conversation

ernestognw
Copy link
Member

@ernestognw ernestognw commented Sep 18, 2023

Admin functions in the AccessManager restricted with the onlyAuthorized modifier were not callable via execute. This was because _canCallExtended ignored the case where caller == this. This is particularly important for GovernorTimelockAccess, which assumes that anything with restricted access can be invoked through execute and always does so.

_canCallExtended is also refactored slightly to separate the logic for target == this.

This PR does not include tests for the fix because we're cherry picking fixes done in the middle of a test refactor, but they are included in #4613.

@changeset-bot
Copy link

changeset-bot bot commented Sep 18, 2023

⚠️ No Changeset found

Latest commit: 8007c3a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ernestognw ernestognw requested review from Amxx and frangio September 18, 2023 16:00
@frangio
Copy link
Contributor

frangio commented Sep 18, 2023

Can we make this PR focused exclusively on the refactor of _canCallExtended and the fix to the onlyAuthorized issue?

It will be better to review it on its own, and we don't need to include the other changes in the first release candidate.

* In addition to the access rules defined by each target's functions being assigned to roles, then entire target can
* be "closed". This "closed" mode is set/unset by the admin using {setTargetClosed} and can be used to lock a contract
* while permissions are being (re-)configured.
* By default every address is member of the `PUBLIC_ROLE` and every contract allows public access until configured otherwise.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not sure that "every contract allows public access". If that is the case, it sounds like a huge risk.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the docs discussion in #4613

* Emits a {RoleAdminChanged} event
* Emits a {RoleAdminChanged} event.
*
* NOTE: Setting the admin role as the `PUBLIC_ROLE` is allowed, but it will effectively allow
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to prevent that ? (same question for _setRoleGuardian)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd personally prevent both because I don't see why anyone would do that but we need to analyze a bit better.
We can do it in the tests PR #4613

@ernestognw ernestognw force-pushed the access-manager/coverage-review branch from 62ff89b to b62e39b Compare September 18, 2023 22:14
@ernestognw
Copy link
Member Author

Can we make this PR focused exclusively on the refactor of _canCallExtended and the fix to the onlyAuthorized issue?

It will be better to review it on its own, and we don't need to include the other changes in the first release candidate.

Sure thing, just updated and also submitted #4613 with the tests WIP

@ernestognw ernestognw requested a review from Amxx September 18, 2023 22:18
@ernestognw ernestognw changed the title AccessManager _canCallSelf and _canCallExecuting AccessManager _canCallSelf and _canCallExecuting Sep 18, 2023
Copy link
Contributor

@frangio frangio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Minor comments:

@frangio frangio changed the title AccessManager _canCallSelf and _canCallExecuting Fix AccessManager's onlyAuthorized functions when called via execute Sep 19, 2023
@frangio frangio changed the title Fix AccessManager's onlyAuthorized functions when called via execute Fix AccessManager._checkAuthorized in execute context Sep 19, 2023
ernestognw and others added 2 commits September 19, 2023 08:11
Co-authored-by: Francisco <fg@frang.io>
Co-authored-by: Francisco <fg@frang.io>
@ernestognw ernestognw requested a review from frangio September 19, 2023 14:11
Copy link
Collaborator

@Amxx Amxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@frangio frangio merged commit 64da2c1 into OpenZeppelin:feat/access-manager Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants