fix: accept onlyDelegateCall as protected modifier in unprotected-upgrade#3014
Open
cats2101 wants to merge 1 commit intocrytic:masterfrom
Open
fix: accept onlyDelegateCall as protected modifier in unprotected-upgrade#3014cats2101 wants to merge 1 commit intocrytic:masterfrom
cats2101 wants to merge 1 commit intocrytic:masterfrom
Conversation
…rade The unprotected-upgrade detector whitelists `onlyProxy` initializers because the modifier prevents calling the implementation contract directly. `onlyDelegateCall` is a common community-defined synonym that provides the same protection (e.g. minimal-proxy / ERC-1167 templates) and was reported as a false positive in crytic#1136. Add `onlyDelegateCall` to the modifier whitelist alongside `onlyProxy` and extend the existing whitelisted.sol e2e fixtures across all solc versions to cover it. Closes crytic#1136
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
unprotected-upgradedetector currently whitelistsonlyProxyinitializers because that modifier prevents calling the implementation contract directly (the call must go throughdelegatecallvia the proxy). The same protection is commonly expressed by a customonlyDelegateCallmodifier, particularly in minimal-proxy (ERC-1167) templates and other non-UUPS upgradeability patterns.This PR extends the whitelist to also accept
onlyDelegateCall, which is the fix the maintainer suggested in #1136 (comment).Changes
slither/detectors/statements/unprotected_upgradeable.py: extract the whitelist into_WHITELISTED_MODIFIERS = {"onlyProxy", "onlyDelegateCall"}and rewrite_whitelisted_modifiersagainst it.whitelisted.solacross solc 0.4.25 / 0.5.16 / 0.6.11 / 0.7.6 / 0.8.15 now include a secondWhitelistedDelegateCallcontract usingonlyDelegateCall. TheOnlyDelegateCallhelper contract is added alongside the existingOnlyProxyone. Snapshot stays empty (no findings).Test plan
pytest tests/e2e/detectors/test_detectors.py -k UnprotectedUpgradeable— all 25 cases pass with the fix.WhitelistedDelegateCall.initialize()as unprotected.ruff check/ruff format --checkclean on the touched file.Closes #1136