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

fix[codegen]: fix false positive in risky call detection #4160

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

charles-cooper
Copy link
Member

the potential_overlap and read_write_overlap() functions use contains_risky_call to detect if there is potential for reentrancy. however, when the target is a precompile, there is no chance for reentrancy, so we filter them out of the detector.

What I did

How I did it

How to verify it

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

the `potential_overlap` and `read_write_overlap()` functions use
`contains_risky_call` to detect if there is potential for reentrancy.
however, when the target is a precompile, there is no chance for
reentrancy, so we filter them out of the detector.
@charles-cooper charles-cooper changed the title fix[codegen]: fix false positive in contains_risky_call fix[codegen]: fix false positive in risky call detection Jun 20, 2024
---------

Co-authored-by: Hubert Ritzdorf <[email protected]>
Co-authored-by: trocher <[email protected]>
@charles-cooper charles-cooper marked this pull request as ready for review June 20, 2024 10:50
@@ -13,6 +13,8 @@
from vyper.semantics.types import VyperType
from vyper.utils import VALID_IR_MACROS, ceil32

PRECOMPILE_RANGE = (1, 10)
Copy link
Collaborator

Choose a reason for hiding this comment

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

might not be true for some L2s

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 thought about this (see also eip-7587) but i think it's ok.

  1. we can't predict every precompile that will be in use by an L2
  2. precompiles could have arbitrary effects
  3. our main goal here is to protect against precompiles which could be generated in the compiler. user-generated calls to precompiles are fair game (we can consider them "unsafe")

Copy link

codecov bot commented Jun 20, 2024

Codecov Report

Attention: Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.

Project coverage is 43.85%. Comparing base (4594f8b) to head (48132c9).

Files Patch % Lines
vyper/codegen/ir_node.py 63.63% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4160       +/-   ##
===========================================
- Coverage   91.34%   43.85%   -47.50%     
===========================================
  Files         109      109               
  Lines       15606    15616       +10     
  Branches     3432     3434        +2     
===========================================
- Hits        14256     6849     -7407     
- Misses        920     8251     +7331     
- Partials      430      516       +86     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@charles-cooper charles-cooper marked this pull request as draft June 20, 2024 17:14
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.

None yet

2 participants