Skip to content

Commit c0fe5a5

Browse files
authored
Clean up warnings and reduce readme (#46)
1 parent ded535a commit c0fe5a5

5 files changed

Lines changed: 164 additions & 312 deletions

File tree

README.md

Lines changed: 51 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ SSV (Secret Shared Validator) is a protocol that enables the distributed control
1313
- Message receiving pipeline
1414

1515
### Differential Fuzzing
16-
**Critical for network security**: Compares behavior between Go and Rust SSV implementations to identify discrepancies that could cause:
17-
- **Network splits** due to consensus disagreements
18-
- **Chain forks** from encoding/validation differences
19-
- **Validator penalties** from inconsistent message handling
16+
Critical for network security: Compares behavior between Go and Rust SSV implementations to identify discrepancies that could cause:
17+
- Network splits due to consensus disagreements
18+
- Chain forks from encoding/validation differences
19+
- Validator penalties from inconsistent message handling
2020

21-
See [`diff_fuzzing/README.md`](diff_fuzzing/README.md) for detailed information about differential fuzzing targets, risk assessment, and implementation roadmap.
21+
Check out [TROPHY.md](TROPHY.md) to see real bugs and discrepancies discovered through differential fuzzing that have been fixed in both implementations.
2222

2323
## Prerequisites
2424

@@ -117,60 +117,54 @@ cargo afl build --bin diff_fuzz_split
117117

118118
## Fuzzing Targets
119119

120-
This project includes two categories of fuzzing targets:
121-
122-
### 📋 Standard Fuzzing Targets (Traditional Component Testing)
123-
1. **validate_ssv_message**: Tests SSVMessage validation against malformed messages
124-
2. **qbft_target**: Tests the QBFT consensus mechanism with arbitrary messages
125-
3. **receive_target**: Tests the message receiving pipeline
126-
4. **custom_ssz**: Tests SSZ encoding/decoding implementations
127-
5. **combine_signatures**: Tests BLS signature combination functionality
128-
6. **fuzz_key_id_try_from**: Tests KeyId conversion operations
129-
130-
### 🔄 Differential Fuzzing Targets (Go vs Rust Comparison)
131-
132-
**High Priority Network Split Risk Targets:**
133-
7. **diff_fuzz_ssv_message_encode_decode**: SSVMessage encoding/decoding comparison between Go and Rust
134-
8. **diff_fuzz_qbft_message_encode_decode**: QBFT message serialization comparison
135-
9. **diff_fuzz_message_id_generation**: MessageID construction and parsing comparison
136-
137-
**Medium Priority Validator/Committee Issues:**
138-
10. **diff_fuzz_signed_ssv_msg_decode_encode**: Differential fuzzing for message decode/encode operations
139-
11. **diff_fuzz_structured_signed_ssv_msg_decode_encode**: Differential fuzzing for structured message operations
140-
12. **diff_fuzz_split**: Differential fuzzing for key splitting implementations
141-
13. **diff_fuzz_partial_signature_validation**: Partial signature validation comparison
142-
14. **diff_fuzz_committee_quorum_calculation**: Committee quorum calculation comparison
143-
15. **diff_fuzz_message_validation_state**: Message validation state comparison
144-
145-
**Lower Priority Performance/Edge Cases:**
146-
16. **diff_fuzz_round_change_handling**: Round change handling comparison
147-
17. **diff_fuzz_justification_validation**: Justification validation comparison
148-
149-
> **Note**: Differential fuzzing targets compare behavior between Go (ssv-spec) and Rust (Anchor) implementations to identify discrepancies that could cause network splits or consensus failures.
120+
### Standard Targets (Component Testing)
121+
- `validate_ssv_message` - SSVMessage validation
122+
- `qbft_target` - QBFT consensus mechanism
123+
- `custom_ssz` - SSZ encoding/decoding
124+
- `receive_target` - Message receiving pipeline
125+
- `combine_signatures` - BLS signature combination
126+
- `fuzz_key_id_try_from` - KeyId conversion
127+
- `fuzz_database_states` - Database states consistency
128+
129+
### Differential Targets (Go vs Rust Comparison)
130+
131+
High Priority (Network Split Risk):
132+
- `diff_fuzz_qbft` - QBFT consensus state machine
133+
- `diff_fuzz_ssv_message_encode_decode` - SSVMessage serialization
134+
- `diff_fuzz_complete_message_validation` - Complete validation pipeline
135+
- `diff_fuzz_message_id_generation` - MessageID construction
136+
- `diff_fuzz_validator_consensus_data_decode_encode` - Validator consensus data
137+
138+
Medium Priority (Validator/Committee Issues):
139+
- `diff_fuzz_signed_ssv_msg_decode_encode` - Basic signed message encoding
140+
- `diff_fuzz_structured_signed_ssv_msg_decode_encode` - Structured message parsing
141+
- `diff_fuzz_split` - Key splitting
142+
- `diff_fuzz_partial_signature_validation` - Partial signature validation
143+
- `diff_fuzz_committee_quorum_calculation` - Quorum calculation
144+
- `diff_fuzz_message_validation_state` - Message validation state
145+
146+
Lower Priority (Performance/Edge Cases):
147+
- `diff_fuzz_round_change_handling` - Round change mechanism
148+
- `diff_fuzz_justification_validation` - Justification validation
150149

151150
## Running Fuzz Tests
152151

153-
### 🚀 Interactive Fuzzing Script (Recommended)
152+
### Interactive Fuzzing Script (Recommended)
154153

155-
The **run_fuzzer.sh** script is the primary interface for all fuzzing operations and includes enhanced capabilities:
154+
The `run_fuzzer.sh` script is the primary interface for all fuzzing operations:
156155

157156
```bash
158157
./run_fuzzer.sh
159158
```
160159

161-
**🎯 Complete Fuzzing Workflow:**
162-
- **Target Selection**: Interactive menu with all 17+ fuzzing targets (standard + differential)
163-
- **Integrated Corpus Generation**: Built-in option to generate optimized test cases using the intelligent corpus generator
164-
- **Built-in Crash Analysis**: Analyze and debug crashes found during fuzzing sessions
165-
- **Build Management**: Handles AFL++ instrumentation and compilation
166-
- **Session Management**: Seamless resuming of previous fuzzing sessions
167-
- **Real-time Monitoring**: Built-in statistics and progress tracking
168-
- **Smart Setup**: Creates proper directory structure and dependencies
169-
170-
**Key Features:**
171-
- **Integrated corpus generation**: Access to corpus generation directly from the fuzzing script menu
172-
- **Crash debugging support**: Integrated tools for analyzing discovered crashes and implementation discrepancies
173-
- **One-stop fuzzing**: Everything from setup to analysis in a single interactive interface
160+
Features:
161+
- Target selection with interactive menu
162+
- Integrated corpus generation
163+
- Built-in crash analysis
164+
- Build management with AFL++ instrumentation
165+
- Session management and resuming
166+
- Real-time monitoring and statistics
167+
- Automatic directory structure setup
174168

175169
### Manual Setup (Optional)
176170

@@ -193,64 +187,25 @@ cargo afl fuzz -i afl_workdir/validate_ssv_message/input -o afl_workdir/validate
193187

194188
## Corpus Generation
195189

196-
### Integrated Corpus Generation
197-
198-
The **run_fuzzer.sh** script includes corpus generation as a built-in option, providing easy access to the intelligent corpus generator:
199-
200-
- **Menu-driven corpus generation**: Select corpus generation from the script's interactive menu
201-
- **Target-specific optimization**: Generate test cases tailored for specific fuzzing targets
202-
- **Structural variation strategy**: Maximize AFL coverage with high-quality, non-redundant test cases
203-
- **Efficiency optimization**: Achieve 20-75% efficiency (unique files after afl-cmin)
204-
- **Seamless integration**: No need to leave the fuzzing script to generate corpus
190+
The `run_fuzzer.sh` script includes built-in corpus generation accessible from the menu. It provides target-specific optimization and structural variation for maximum AFL coverage.
205191

206-
### Manual Corpus Generator (Optional)
207-
208-
For advanced users who want manual control over corpus generation:
192+
For manual control:
209193

210194
```bash
211195
cd corpus_generator
212-
cargo run # Interactive mode - shows all available targets
213-
cargo run -- <target_name> # Generate corpus for specific target
196+
cargo run # Interactive mode
197+
cargo run -- <target_name> # Generate for specific target
214198
```
215199

216-
**Supported targets:**
217-
- `diff_fuzz_ssv_message_encode_decode`
218-
- `diff_fuzz_qbft_message_encode_decode`
219-
- `diff_fuzz_message_id_generation`
220-
- `diff_fuzz_signed_ssv_msg_decode_encode`
221-
- `diff_fuzz_structured_signed_ssv_msg_decode_encode`
222-
- `diff_fuzz_split`
223-
- `diff_fuzz_partial_signature_validation`
224-
- `diff_fuzz_committee_quorum_calculation`
225-
- `diff_fuzz_message_validation_state`
226-
- `diff_fuzz_round_change_handling`
227-
- `diff_fuzz_justification_validation`
228-
229-
> **Note**: Manual corpus generation is only needed for specialized testing scenarios. The run_fuzzer.sh script provides corpus generation as an integrated option.
230-
231200
## Advanced Usage
232201

233202
### Corpus Management
234203

235-
The fuzzing script automatically handles:
236-
- **Resuming sessions**: Detects existing fuzzing results and offers to resume
237-
- **Input generation**: Creates basic test cases for new targets automatically
238-
- **Directory management**: Sets up proper input/output directory structure
204+
The fuzzing script automatically handles session resuming, input generation, and directory management.
239205

240206
For manual corpus management:
241-
- **Generate optimized corpus**: Use the corpus generator (see above) before fuzzing
242-
- **Minimize corpus**: Use `afl-cmin -i afl_workdir/<target>/output/queue -o minimized_corpus -- target/debug/<target>`
243-
- **View statistics**: Use `cargo afl whatsup -s afl_workdir/<target>/output` or select option 2 in the fuzzing script
244-
245-
### Fuzzing Script Features
246-
247-
The `run_fuzzer.sh` script provides:
248-
- **Interactive menu**: Easy target selection from all available fuzzing targets
249-
- **Automatic setup**: Creates input/output directories and basic test cases
250-
- **Smart resuming**: Detects previous sessions and offers to continue
251-
- **Build integration**: Automatically builds targets with AFL instrumentation
252-
- **Statistics viewing**: Built-in stats display for monitoring progress
253-
- **Error handling**: Validates dependencies and project structure
207+
- Minimize corpus: `afl-cmin -i afl_workdir/<target>/output/queue -o minimized_corpus -- target/debug/<target>`
208+
- View statistics: `cargo afl whatsup -s afl_workdir/<target>/output`
254209

255210
## Project Structure
256211

TROPHY.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Trophy Case
2+
3+
This document tracks bugs and implementation discrepancies discovered through differential fuzzing between the Anchor (Rust) and SSV (Go) implementations.
4+
5+
**Note**: This is an ongoing effort. The issues listed here are current findings, and more discrepancies are likely to be discovered as fuzzing continues.
6+
7+
## Discovered Issues
8+
9+
### Anchor (Rust) Implementation
10+
11+
1. **Bump round on future justified proposal** ([PR #529](https://github.com/sigp/anchor/pull/529))
12+
- Issue: Incorrect round handling when receiving justified proposals from future rounds
13+
- Impact: Could cause validators to remain stuck in old rounds
14+
15+
2. **Allow reaching consensus in PREPARE state** ([PR #527](https://github.com/sigp/anchor/pull/527))
16+
- Issue: Consensus logic prevented valid state transitions from PREPARE
17+
- Impact: Potential liveness issues in certain consensus scenarios
18+
19+
3. **Validation for prepared round changes before insertion** ([PR #528](https://github.com/sigp/anchor/pull/528))
20+
- Issue: Missing validation before inserting prepared round change messages
21+
- Impact: Could allow invalid messages into the state machine
22+
23+
4. **Store messages without full data** ([PR #538](https://github.com/sigp/anchor/pull/538))
24+
- Issue: Message storage logic required unnecessary full data
25+
- Impact: Memory inefficiency and potential state inconsistencies
26+
27+
5. **Partial roundchange quorum** ([PR #541](https://github.com/sigp/anchor/pull/541))
28+
- Issue: Incorrect quorum calculation for partial round change sets
29+
- Impact: Could prevent or incorrectly trigger round changes
30+
31+
6. **COMMIT and PREPARE must be of the exact current round** ([PR #530](https://github.com/sigp/anchor/pull/530))
32+
- Issue: Accepted COMMIT and PREPARE messages from incorrect rounds
33+
- Impact: State machine could process out-of-order messages incorrectly
34+
35+
7. **Check round change quorum disregarding root** ([PR #571](https://github.com/sigp/anchor/pull/571))
36+
- Issue: Round change quorum logic incorrectly considered root values
37+
- Impact: Could prevent legitimate round changes from completing
38+
39+
### SSV (Go) Implementation
40+
41+
1. **Threshold key split validation of 0** ([PR #2466](https://github.com/ssvlabs/ssv/pull/2466))
42+
- Issue: Missing validation for zero threshold in key splitting
43+
- Impact: Could create invalid key shares with zero threshold
44+
45+
2. **Redundant Round-Change message** ([Issue #579](https://github.com/ssvlabs/ssv-spec/issues/579))
46+
- Issue: Implementation sent redundant round change messages
47+
- Impact: Network bandwidth waste and potential confusion in consensus
48+
49+
3. **Comparison mismatched** ([Issue #580](https://github.com/ssvlabs/ssv-spec/issues/580))
50+
- Issue: Inconsistent comparison logic between implementations
51+
- Impact: Could cause different validation results for the same input
52+
53+
4. **Add message validation rule** ([Issue #582](https://github.com/ssvlabs/ssv-spec/issues/582))
54+
- Issue: Missing validation rule that Rust implementation enforced
55+
- Impact: Could accept invalid messages that should be rejected
56+
57+
## Contributing
58+
59+
If you discover additional issues through fuzzing:
60+
1. Verify the discrepancy is reproducible
61+
2. Create a minimal test case
62+
3. Report to the relevant implementation team
63+
4. Submit a PR adding the issue to this trophy case

corpus_generator/src/generators/message_validation_state.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ impl SSVMessageBuilder {
372372
msg.signatures = vec![vec![1; 256]]; // Only one signature
373373
msg
374374
}
375+
"round_change" => {
376+
// RoundChange messages are critical for consensus liveness
377+
self.create_consensus_message(rng, QBFTMsgType::RoundChangeMsgType)
378+
}
375379
_ => self.create_consensus_message(rng, QBFTMsgType::ProposalMsgType),
376380
}
377381
}
@@ -510,6 +514,12 @@ impl MessageValidationStateGenerator {
510514
CorpusUtils::save_corpus_file(output_dir, "validation_sig_mismatch", &mismatch_data)?;
511515
count += 1;
512516

517+
// RoundChange message case
518+
let round_change_msg = builder.create_edge_case_message(rng, "round_change");
519+
let round_change_data = create_corpus_entry_with_context(20, 300, 9, &round_change_msg);
520+
CorpusUtils::save_corpus_file(output_dir, "validation_round_change", &round_change_data)?;
521+
count += 1;
522+
513523
Ok(count)
514524
}
515525

0 commit comments

Comments
 (0)