slither
slither copied to clipboard
update: improve unhandled initializers in unprotected-upgrade detector
What PR for
unprotected-upgrade
only detects function name initialize
as initializer. It will increase false negatives because of missing proper initializers.
What PR does
- Count any function with an
initializer
orreinitializer
modifier as aninitializer
. - Remove ambiguous relation between
_is_upgradeable
and_is_upgradeable_proxy
. The_is_upgradeable
should not be excluded by_is_upgradeable_proxy
. For example, just because the contract name hasproxy
in its name, detectors should not miss the bug (false negative).
Summary by CodeRabbit
-
New Features
- Introduced new smart contracts
AnyInitializer
andReinitializer
with initialization and self-destruct functionalities across various versions. - Added
reinitializer
modifier toInitializable
contract to handle versioned reinitialization.
- Introduced new smart contracts
-
Bug Fixes
- Modified
_initialize_functions
to filter functions with specific modifiers for enhanced security.
- Modified
-
Tests
- Added new test scenarios for
UnprotectedUpgradeable
detectors to validate the security of upgradeable contracts.
- Added new test scenarios for
I just added: Remove ambiguous relation between _is_upgradeable
and _is_upgradeable_proxy
.
The _is_upgradeable
should not be excluded by _is_upgradeable_proxy
. For example, just because the contract name has proxy
in its name, detectors should not miss the bug (false negative).
hi there, any update? @@ sorry to ping reviewers @montyly @0xalpharush @smoelius
Walkthrough
Walkthrough
The recent updates involve modifications and additions across multiple files related to the Slither framework and test environments for detecting vulnerabilities in upgradeable smart contracts. Changes include altering the initialization and protection mechanisms of smart contracts, refining detection capabilities for unprotected upgradeable functions, and introducing new test cases and contracts to enhance the robustness of security assessments.
Changes
File Path | Change Summary |
---|---|
slither/core/declarations/contract.py |
Removed conditional check for is_upgradeable_proxy in is_upgradeable method. |
slither/detectors/statements/unprotected_upgradeable.py |
Modified _initialize_functions to filter functions by initializer or reinitializer modifiers. |
Various tests/e2e/detectors/snapshots/ files |
Introduced new test files for AnyInitializer and Reinitializer contracts across different Solidity versions, highlighting the lack of protection in initialize functions and potential for unauthorized deletion. |
Various tests/e2e/detectors/test_data/unprotected-upgrade/ files across versions |
Added and modified contracts AnyInitializer and Reinitializer with initialization and self-destruct functions, alongside the addition of reinitializer modifiers in Initializable contracts. |
tests/e2e/detectors/test_detectors.py |
Added tests for UnprotectedUpgradeable detector with various contracts and versions. |
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>.
-
Generate unit testing code for this file.
-
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitai
in a new review comment at the desired location with your query. Examples:-
@coderabbitai generate unit testing code for this file.
-
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitai
in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai generate interesting stats about this repository and render them as a table.
-
@coderabbitai show all the console.log statements in this repository.
-
@coderabbitai read src/utils.ts and generate unit testing code.
-
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
-
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
-
@coderabbitai pause
to pause the reviews on a PR. -
@coderabbitai resume
to resume the paused reviews. -
@coderabbitai review
to trigger a review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai resolve
resolve all the CodeRabbit review comments. -
@coderabbitai help
to get help.
Additionally, you can add @coderabbitai ignore
anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml
)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yaml
file to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.