-
Notifications
You must be signed in to change notification settings - Fork 0
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
202409 Guardian Fuzzing Suite #105
base: main
Are you sure you want to change the base?
Conversation
@GuardianAudits is attempting to deploy a commit to the Foil team on Vercel, but is not a member of this team. To resolve this issue, you can:
To read more about collaboration on Vercel, click here. |
@@ -1,8 +1,13 @@ | |||
[profile.default] | |||
optimizer = true #optimizer was turned on to avoid stack too deep on setup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sunnyvempati @leomassazza do we want to keep this?
packages/protocol/package.json
Outdated
@@ -5,30 +5,32 @@ | |||
"version": "0.27", | |||
"scripts": { | |||
"dev": "cannon build --keep-alive --port 8545 --no-cors --write-deployments ./deployments/13370", | |||
"test": "cannon test cannonfile.test.toml -- -vv", | |||
"test": "forge build && cannon build --write-deployments ./deployments && cannon test", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to avoid this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, looks like this got mixed up in the Rebase. This is not necessary for the fuzz suite, removed.
packages/protocol/package.json
Outdated
"@types/chai": "^4.3.19", | ||
"@types/mocha": "^10.0.8", | ||
"@types/node": "^20.16.5", | ||
"@types/chai": "^4.3.16", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to keep latest deps throughout here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the package.json diff as it's unnecessary.
IFoilStructs.EpochParams memory epochParams | ||
) external nonReentrant override { | ||
IFoilStructs.EpochParams memory epochParams, | ||
address foil //@audit added by fuzzer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we keep this?
Overview
FOIL engaged the Guardian team for an in-depth security review of their Virtual Gas market. This comprehensive evaluation, conducted from August 26th to September 9th, 2024, included the development of a specialized fuzzing suite to uncover complex logical errors in various protocol states. This suite, an integral part of the audit, was created during the review period and successfully delivered upon the audit's conclusion.
Contents
This fuzzing suite was created for the scope below, and updated for remediations at September 16th, 2024. The fuzzing suite primarily targets the core functionality found in
ConfigurationModule.sol
,LiquidityModule.sol
,SettlementModule.sol
, andTradeModule.sol
.Due to the unstable nature of fork testing, and the need to adjust prices, mock versions of Uma Oracle, and Uniswap V3 local deployment were created to resolve these issues.
A mock lens contract was created to access the states of the FOIL market which was necessary for many invariants.
Logical coverage for the main structs allow the fuzzer to view position values, Uniswap ticks, and statuses of trades with additional details beyond line coverage.
All properties tested can be found below in this readme.
Setup
Install Echidna and follow the steps here using the latest master branch: Installation Guide
Install libraries
Usage
If Echidna throws error
VM failed for unhandled reason, BadCheatCode 0xc657c718
, just update echidna to the latest release.Scope
Repo: https://github.com/GuardianAudits/foil-fuzzing
Branch:
main
Commit:
bc80c3a7109299cfd43b9b116bdef6ccbb533200
Remediations:
4a00c554338ac660076a7fb491442c3506d5bce0
List of assertions
InsufficientBalance
error from the collateral token.Remediations
List of invariants changed:
Features
To reproduce with Foundry, set
FuzzStorageVariables::REPRO_MODE
to true. This switches the modifier to use only one actor in all calls.Coverage
This deployment includes stack-consuming Uniswap V3 deployment, so optimizer usage is needed. The optimizer negatively impacts coverage coloring, as it merges some repeated function usage, etc. As a workaround, we mocked state changes with
stateChangerVar
to show that all key functions were definitely covered.