-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat: test for reentrancy in invariant tests #1578
Comments
Was this solved? |
There's a simple version of reentrancy invariant testing that @joshieDo added and is currently off by default, but the approach isn't perfect (not sure any approach will be though). IMO worth keeping this open just to track the idea / as a place to drop any ideas on the best way(s) to do this |
Here's a sample on how reentrancy can be tested in invariants (adapted from https://github.com/rappie/echidna-rari-hack): https://github.com/grandizzy/foundry-rari-hack @mds1 do we need more of these or OK to close ticket for now and improve as we go? (would probably make sense to follow up with more testing with |
From a quick read of that repo it seems it manually sets up a handler for reentrancy testing. If that's the approach we want to recommend (since I don't think |
Yeah, had some testing for same scenario with Agree, let's keep this one to make |
Component
Forge
Describe the feature you would like
In #1572 invariant testing will be added to forge. This basically executes a sequence of random calls in attempt to break some invariant.
This is really valuable but it can't test reentrancy, which is common class of vulnerabilities. @brockelmore had an idea for testing this, which is:
One downside is that each of these contracts would have no state in the system until its first call, which isn't always ideal. One way to resolve this is to generate a single contract that can call all methods with any calldata, and randomly choose which it will reenter. That contract will more frequently be the caller and likely to have state in the system than if we generated many contracts.
In general, there's many variants of reentrancy vulns and the above won't cover all of them. This is very much a work-in-progress idea that we'd need to spec out more before implementing, but wanted to open this issue so we don't lose track of it. Ideas welcome 🙂
Additional context
No response
The text was updated successfully, but these errors were encountered: