-
Notifications
You must be signed in to change notification settings - Fork 176
disable foundry (cheatcode) temporarily #564
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
a606b7c
disable foundry support
iamjacobjia 89144e0
disable foundry support
iamjacobjia dce90bb
disable foundry support
iamjacobjia 9b81378
disable foundry support
iamjacobjia e0a143e
update bsc rpc
iamjacobjia ab82ba2
update bsc rpc
iamjacobjia 3da588e
update bsc rpc
iamjacobjia b42c167
update bsc rpc
iamjacobjia e81ce23
update bsc rpc
iamjacobjia 6518554
update bsc rpc
iamjacobjia 9de8fd3
update bsc rpc
iamjacobjia a5430c5
update bsc rpc
iamjacobjia cdb43c0
update bsc rpc
iamjacobjia a1f3734
fix get abi from scan
iamjacobjia ce9ac2f
fix get abi from scan
iamjacobjia d7d25c1
fix get abi from scan
iamjacobjia 7dd7c98
fix get abi from scan
iamjacobjia 327ce73
debug uniswap pairs
iamjacobjia e89037c
debug uniswap pairs
iamjacobjia 39eb986
debug uniswap pairs
iamjacobjia 3d87d31
debug uniswap pairs
iamjacobjia 6a964cc
debug uniswap pairs
iamjacobjia cf330ae
debug uniswap pairs
iamjacobjia 457d413
debug uniswap pairs
iamjacobjia 07d29d1
debug uniswap pairs
iamjacobjia a4b905f
debug uniswap pairs
iamjacobjia 652a31e
fix eth_getCode
iamjacobjia 132786b
fix eth_getCode
iamjacobjia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,198 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| ItyFuzz is a blazing-fast hybrid fuzzer for EVM and MoveVM smart contracts that combines symbolic execution and fuzzing to find vulnerabilities. Built on LibAFL, it supports both offchain contract fuzzing and onchain fuzzing with chain forking. | ||
|
|
||
| ## Build & Development Commands | ||
|
|
||
| ### Prerequisites | ||
| - Rust nightly toolchain (2024-01-01): Install via `rustup toolchain install nightly-2024-01-01` | ||
| - The project uses a specific nightly version defined in `rust-toolchain.toml` | ||
|
|
||
| ### Building | ||
| ```bash | ||
| # Standard build | ||
| cargo build --release | ||
|
|
||
| # Debug build | ||
| cargo build | ||
|
|
||
| # Build with specific features | ||
| cargo build --release --features "cmp dataflow evm print_txn_corpus full_trace" | ||
| ``` | ||
|
|
||
| ### Running Tests | ||
| ```bash | ||
| # Run all unit tests | ||
| cargo test --verbose | ||
|
|
||
| # Run integration tests (offchain only) | ||
| python3 integration_test.py offchain | ||
|
|
||
| # Run integration tests (onchain - requires RPC and Etherscan API keys) | ||
| python3 integration_test.py onchain | ||
|
|
||
| # Run single offchain test manually | ||
| ./target/release/ityfuzz evm -t 'tests/evm/reentrancy/*' -f | ||
|
|
||
| # Run specific test with concolic execution | ||
| ./target/release/ityfuzz evm -t 'tests/evm/concolic-1/*' --concolic --concolic-caller | ||
| ``` | ||
|
|
||
| ### Code Quality | ||
| ```bash | ||
| # Format check | ||
| cargo fmt -- --check | ||
|
|
||
| # Apply formatting | ||
| cargo fmt | ||
|
|
||
| # Lint (optional, commented out in CI) | ||
| cargo clippy --all-features | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Core Structure | ||
|
|
||
| The codebase is organized around a generic VM abstraction: | ||
|
|
||
| - **`src/generic_vm/`**: Generic traits for any VM implementation | ||
| - `vm_executor.rs`: Executor trait abstraction | ||
| - `vm_state.rs`: State management abstraction | ||
|
|
||
| - **`src/evm/`**: EVM-specific implementation (primary focus) | ||
| - `vm.rs`: EVM execution engine built on `revm` | ||
| - `host.rs`: Host environment for EVM execution | ||
| - `input.rs`: EVM transaction input representation | ||
| - `contract_utils.rs`: Contract deployment and initialization | ||
|
|
||
| - **`src/move/`**: MoveVM implementation (requires `sui_support` feature) | ||
|
|
||
| - **`src/fuzzers/`**: Fuzzer orchestration | ||
| - `evm_fuzzer.rs`: Main EVM fuzzing logic | ||
| - `move_fuzzer.rs`: MoveVM fuzzing logic | ||
|
|
||
| ### Key Concepts | ||
|
|
||
| #### Middlewares (`src/evm/middlewares/`) | ||
| Middlewares are invoked for every opcode executed in REVM: | ||
| - **`coverage.rs`**: Instruction coverage tracking | ||
| - **`cheatcode/`**: Foundry cheatcode support for setup scripts | ||
| - **`reentrancy.rs`**: Reentrancy detection and exploitation | ||
| - **`sha3_bypass.rs`**: Symbolic SHA3 handling (enabled with `--sha3-bypass`) | ||
|
|
||
| #### Oracles (`src/evm/oracles/`) | ||
| Vulnerability detection modules: | ||
| - **`erc20.rs`**: ERC20 balance manipulation detection | ||
| - **`v2_pair.rs`**: Uniswap V2 pair price manipulation | ||
| - **`arb_call.rs`**: Arbitrary call detection | ||
| - **`reentrancy.rs`**: Reentrancy vulnerability oracle | ||
| - **`selfdestruct.rs`**: Selfdestruct vulnerabilities | ||
| - **`invariant.rs`**: Echidna-style invariant testing | ||
| - **`state_comp.rs`**: State comparison oracle | ||
| - **`typed_bug.rs`**: Type-specific bug patterns | ||
|
|
||
| #### Control Leak | ||
| When execution yields control to the caller mid-transaction (e.g., via external call), ItyFuzz saves the post-execution state. This enables fuzzing of reentrancy scenarios by continuing execution or injecting new transactions before the original transaction completes. | ||
|
|
||
| #### Onchain Support (`src/evm/onchain/`) | ||
| - **`endpoints.rs`**: Chain configuration and RPC endpoints | ||
| - Supports ETH, BSC, Polygon, Arbitrum, Optimism, Base, and many other chains | ||
| - Fetches bytecode and storage slots on-demand during fuzzing | ||
| - Requires chain-specific RPC URLs and Etherscan API keys | ||
|
|
||
| ### Execution Flow | ||
|
|
||
| 1. **Initialization**: | ||
| - Parse CLI arguments (`src/evm/mod.rs` - `EvmArgs`) | ||
| - Load contracts via `ContractLoader` (glob patterns, addresses, or Foundry setup) | ||
| - Extract constants from bytecode via `bytecode_analyzer.rs` | ||
| - Initialize corpus with default function calls | ||
|
|
||
| 2. **Fuzzing Loop** (LibAFL-based): | ||
| ``` | ||
| Input → REVM Execution → Outcome: | ||
| - Reverted → Discard | ||
| - Control Leak → Save post-execution state for reentrancy | ||
| - Success → Execute Producers → Run Oracles | ||
| ``` | ||
|
|
||
| 3. **Feedback Collection** (`src/feedback.rs`): | ||
| - Coverage feedback (branch, instruction) | ||
| - Comparison feedback (CMP instructions for input generation) | ||
| - State comparison feedback | ||
|
|
||
| 4. **Scheduling** (`src/scheduler.rs`): | ||
| - Infant scheduler: prioritizes recent interesting inputs | ||
| - Power scheduling: allocates more fuzzing time to promising paths | ||
|
|
||
| ## Feature Flags | ||
|
|
||
| Key features defined in `Cargo.toml`: | ||
|
|
||
| - **`evm`**: EVM support (default) | ||
| - **`cmp`**: Comparison feedback collection (default) | ||
| - **`dataflow`**: Dataflow analysis (default) | ||
| - **`print_txn_corpus`**: Print transaction corpus (default) | ||
| - **`full_trace`**: Full execution traces (default) | ||
| - **`force_cache`**: Force caching of onchain data (default) | ||
| - **`sui_support`**: Enable MoveVM/Sui support (optional) | ||
| - **`deployer_is_attacker`**: Treat deployer as attacker | ||
| - **`print_logs`**: Enable debug logging | ||
| - **`flashloan_debug`**: Debug flashloan logic | ||
| - **`no_etherscan`**: Disable Etherscan integration | ||
|
|
||
| ## Common Workflows | ||
|
|
||
| ### Fuzzing a Local Contract | ||
| ```bash | ||
| # Compile Solidity contract | ||
| solc contracts/Target.sol -o out/ --bin --abi --overwrite | ||
|
|
||
| # Fuzz it | ||
| ./target/release/ityfuzz evm -t 'out/*' -f | ||
| ``` | ||
|
|
||
| ### Fuzzing Onchain Contracts | ||
| ```bash | ||
| # Set RPC URL | ||
| export ETH_RPC_URL="https://eth.llamarpc.com" | ||
|
|
||
| # Fuzz deployed contract with flashloan | ||
| ./target/release/ityfuzz evm \ | ||
| -t 0xTargetAddress \ | ||
| -c eth \ | ||
| -b 18000000 \ | ||
| --flashloan \ | ||
| --onchain-etherscan-api-key YOUR_KEY | ||
| ``` | ||
|
|
||
| ### Foundry Invariant Testing | ||
| ```bash | ||
| # Replace: forge test --mc test/Invariant.sol:Invariant | ||
| ./target/release/ityfuzz evm -m test/Invariant.sol:Invariant -- forge test | ||
| ``` | ||
|
|
||
| ## Dependencies | ||
|
|
||
| ### Critical External Dependencies | ||
| - **`revm`**: Custom fork at `fuzzland/revm` - EVM execution engine with no gas metering and memory limits | ||
| - **`libafl` v0.11.2**: Fuzzing framework (exact version required) | ||
| - **`z3`**: SMT solver for symbolic execution (static-link-z3 feature) | ||
| - **`ethers`**: Ethereum utilities and RPC client | ||
| - **`foundry-cheatcodes`**: Foundry compatibility layer | ||
|
|
||
| ### Move/Sui Dependencies (optional) | ||
| All Move-related crates are from `fuzzland/ityfuzz-sui-fork`, enabled only with `sui_support` feature. | ||
|
|
||
| ## Important Notes | ||
|
|
||
| - The project requires Rust nightly with specific unstable features: `downcast_unchecked`, `let_chains`, `unchecked_math`, `trait_alias` | ||
| - Sentry error tracking is initialized by default (`init_sentry()` in `main.rs`) | ||
| - Git version info is embedded at build time via `build.rs` | ||
| - The `/cache` directory is populated from GitHub releases for integration tests | ||
| - Integration tests use `timeout`/`gtimeout` to prevent hangs (30s for offchain, 5m for onchain) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[nitpick] The addition of
CLAUDE.mddocumentation file appears unrelated to the PR's stated purpose of disabling cheatcode functionality. While documentation improvements are valuable, this should be in a separate PR to maintain focused, reviewable changes.