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

Resolve Various Audit Findings, December 2024 #176

Merged
merged 10 commits into from
Dec 11, 2024

Conversation

rauljordan
Copy link
Contributor

@rauljordan rauljordan commented Dec 4, 2024

Description

This PR resolves audit findings from Open Zeppelin. It resolves:

  • H-01: potentially unreachable fallback function
  • H-02 falsely Restricted Definitions for Special Functions
  • L-04: multiple fallback and/or receive attributes are possible
  • L-05: incorrect dependency version in examples
  • N-03: missing Warnings for fallback and receive function names

Some notes on the changes

The router trait is changed to now include two methods for fallbacks: one with arguments and one without. The actual usage of the route function decides which method to call depending on the explanations here from the Solidity team:

The unnamed function commonly referred to as “fallback function” was split up into a new fallback function that is defined using the fallback keyword and a receive ether function defined using the receive keyword.

If present, the receive ether function is called whenever the call data is empty (whether or not ether is received). This function is implicitly payable.

The new fallback function is called when no other function matches (if the receive ether function does not exist then this includes calls with empty call data). You can make this function payable or not. If it is not payable then transactions not matching any other function which send value will revert. You should only need to implement the new fallback function if you are following an upgrade or proxy pattern.

The macro will ensure only function is marked as #[fallback] and ensures it falls into either of the two camps: with args or no args. Additionally, purity enforcement of fallback is now added if not marked as payable explicitly.

We also add proper receive method semantics to the router.

@rauljordan rauljordan marked this pull request as draft December 4, 2024 18:17
@rauljordan rauljordan marked this pull request as ready for review December 6, 2024 18:41
@gligneul gligneul self-requested a review December 9, 2024 17:28
stylus-sdk/src/abi/mod.rs Outdated Show resolved Hide resolved
stylus-proc/src/macros/public/types.rs Outdated Show resolved Hide resolved
Copy link

@gligneul gligneul left a comment

Choose a reason for hiding this comment

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

LGTM

@rauljordan rauljordan merged commit e54027e into develop Dec 11, 2024
10 checks passed
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.

2 participants