transmissions11 / solmate

Modern, opinionated, and gas optimized building blocks for smart contract development.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(Multi)RolesAuthority | Auth.requiresAuth(): msg.sig value issue

Theo6890 opened this issue · comments

Context

Create a custom ERC721 from solmate library with RolesAuthority to add specific access & management rights upon the ERC721.
Public repository

Issue

msg.sig & function MUST be the same on order to allow the user to take action on this specific function

failure

As you can see minting fails to UNAUTHORIZED roles, which is all due to msg.sig.

Workaround

  • Use if(isAuthorized(msg.sender, bytes4(keccak256("funcSig")))) revert("UNAUTHORIZED")

This is not the best way as the modifier is there to avoid adding this line in any functions requiring specific rights.

Conclusion

This means msg.sig is not reliable at all when a function with is called from another contract even if the user has the rights.

Source

Ethereum stack exchange issue