Skip to content

Commit b7310bb

Browse files
committed
Update docs
1 parent 0ecec2b commit b7310bb

File tree

10 files changed

+263
-673
lines changed

10 files changed

+263
-673
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ doc_ref/
1717
*.so
1818
notes.md
1919
/reports/
20+
docs/interactions/
2021
docs/transport.md
2122
mcp_fuzzer/process_mgmt/
2223
servers

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ If your server conforms to the [MCP schema](https://github.com/modelcontextproto
3636
- Beautiful Output: Rich, colorized terminal output with detailed reporting
3737
- Flexible Configuration: CLI args, YAML configs, environment variables
3838
- Comprehensive Reporting: Multiple output formats (JSON, CSV, HTML, Markdown)
39-
- Production Ready: Environment detection and production-safe defaults
39+
- Production Ready: PATH shims, sandbox defaults, and CI-friendly controls
4040
- Intelligent Testing: Hypothesis-based data generation with custom strategies
4141

4242
### Extensibility for Contributors
@@ -187,7 +187,7 @@ mcp-fuzzer --timeout 120 --process-retry-count 5 --process-retry-delay 2.0
187187
|---------|-------------|
188188
| Two-Phase Fuzzing | Realistic testing + aggressive security testing |
189189
| Multi-Protocol Support | HTTP, SSE, Stdio, and StreamableHTTP transports |
190-
| Built-in Safety | Environment detection and system protection |
190+
| Built-in Safety | Pattern-based filtering, sandboxing, and PATH shims |
191191
| Intelligent Testing | Hypothesis-based data generation with custom strategies |
192192
| Rich Reporting | Detailed output with exception tracking and safety reports |
193193
| Multiple Output Formats | JSON, CSV, HTML, Markdown, and XML export options |

docs/architecture/architecture.md

Lines changed: 63 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ flowchart TB
5151
5252
subgraph Safety_System
5353
E1[SafetyFilter]
54-
E2[SystemBlocker]
54+
E2[SystemCommandBlocker]
5555
E3[Network Policy]
5656
end
5757
@@ -131,7 +131,7 @@ graph TD
131131
D --> E[create_safe_mock_response]
132132
C -->|No| F[Execute]
133133
134-
subgraph SystemBlocker
134+
subgraph CommandBlocker
135135
G[Intercept OS commands via PATH shims]
136136
end
137137
```
@@ -142,8 +142,6 @@ graph TD
142142
mcp_fuzzer/
143143
├── __init__.py # Package initialization and exports
144144
├── __main__.py # Entry point for module execution
145-
├── config_loader.py # Configuration loading utilities
146-
├── config.py # Configuration management
147145
├── exceptions.py # Custom exception classes
148146
├── types.py # Type definitions and protocols
149147
├── auth/ # Authentication system
@@ -160,7 +158,13 @@ mcp_fuzzer/
160158
│ ├── __init__.py
161159
│ ├── base.py # Main MCPFuzzerClient
162160
│ ├── protocol_client.py # Protocol-level client
163-
│ └── tool_client.py # Tool-level client
161+
│ ├── tool_client.py # Tool-level client
162+
│ └── utils.py # Shared utilities
163+
├── config/ # Configuration subsystem
164+
│ ├── __init__.py
165+
│ ├── constants.py # Default values and shared constants
166+
│ ├── loader.py # Config file/env loaders
167+
│ └── manager.py # Runtime config manager
164168
├── fuzz_engine/ # Core fuzzing engine
165169
│ ├── __init__.py
166170
│ ├── executor.py # Async execution framework
@@ -193,10 +197,20 @@ mcp_fuzzer/
193197
│ └── safety_reporter.py # Safety system reporting
194198
├── safety_system/ # Safety and protection
195199
│ ├── __init__.py
196-
│ ├── patterns.py # Safety pattern definitions
197200
│ ├── policy.py # Network policy and host normalization
198201
│ ├── safety.py # Core safety logic with SafetyProvider protocol
199-
│ └── system_blocker.py # System command blocking
202+
│ ├── blocking/ # PATH shim command blocking
203+
│ │ ├── __init__.py
204+
│ │ ├── command_blocker.py
205+
│ │ └── shims/
206+
│ ├── detection/ # Dangerous pattern detection
207+
│ │ ├── __init__.py
208+
│ │ ├── detector.py
209+
│ │ └── patterns.py
210+
│ └── filesystem/ # Filesystem sandboxing helpers
211+
│ ├── __init__.py
212+
│ ├── sandbox.py
213+
│ └── sanitizer.py
200214
└── transport/ # Transport layer implementations
201215
├── __init__.py
202216
├── base.py # Abstract transport protocol
@@ -330,7 +344,7 @@ The schema parser provides comprehensive support for parsing JSON Schema definit
330344

331345
The module supports both "realistic" and "aggressive" fuzzing strategies, where realistic mode generates valid data conforming to the schema, while aggressive mode intentionally generates edge cases and invalid data to test error handling.
332346

333-
### 5. Invariants System
347+
### 6. Invariants System
334348

335349
The invariants system provides comprehensive property-based testing capabilities to verify response validity, error type correctness, and prevention of unintended crashes or unexpected states during fuzzing.
336350

@@ -370,7 +384,7 @@ for idx, result in results.items():
370384

371385
These invariants serve as runtime assertions that validate the behavior of the server being tested, helping to identify potential issues that might not be caught by simple error checking.
372386

373-
### 6. Client Architecture
387+
### 7. Client Architecture
374388

375389
The client architecture provides specialized MCP client implementations for different fuzzing scenarios.
376390

@@ -388,29 +402,30 @@ The client architecture provides specialized MCP client implementations for diff
388402
- **Authentication Support**: Built-in authentication management
389403
- **Reporting Integration**: Automatic result collection and reporting
390404

391-
### 7. Safety System
405+
### 8. Safety System
392406

393407
The safety system provides multiple layers of protection against dangerous operations using a pluggable provider architecture.
394408

395409
**Key Components:**
396410

397-
- `safety.py`: Core safety logic with SafetyProvider protocol
398-
- `patterns.py`: Predefined dangerous pattern definitions
399-
- `policy.py`: Network policy and host normalization
400-
- `system_blocker.py`: System command blocking and PATH shimming
411+
- `safety.py`: Core safety logic with the `SafetyProvider` protocol
412+
- `policy.py`: Network policy enforcement and host normalization
413+
- `detection/patterns.py` & `detection/detector.py`: Dangerous pattern definitions and detection pipeline
414+
- `blocking/command_blocker.py`: `SystemCommandBlocker` PATH shim implementation plus shim templates
415+
- `filesystem/`: Filesystem sandbox (`sandbox.py`) and path sanitizer helpers
401416

402417
**Safety Features:**
403418

404419
- **Pluggable Safety Providers**: Protocol-based safety system allowing custom implementations
405420
- **Pattern-Based Filtering**: Comprehensive pattern matching for dangerous content
406421
- **SafetyFilter Class**: Main implementation with URL/command blocking
407-
- **System Command Blocking**: Prevents execution of dangerous commands (PATH shims)
422+
- **System Command Blocking**: The `SystemCommandBlocker` PATH shim prevents execution of dangerous commands
408423
- **Filesystem Sandboxing**: Confines file operations to specified directories
409424
- **Process Isolation**: Safe subprocess handling with timeouts
410425
- **Input Sanitization**: Filters potentially dangerous input
411426
- **Mock Response Generation**: Safe responses for blocked operations
412427

413-
### 8. Authentication System
428+
### 9. Authentication System
414429

415430
The authentication system provides comprehensive support for various authentication methods for MCP servers using a flexible provider-based architecture.
416431

@@ -478,19 +493,20 @@ auth:
478493
- **Provider Validation**: Runtime validation of authentication configurations
479494
- **Error Handling**: Graceful fallback for authentication failures
480495

481-
### 9. Configuration Management
496+
### 10. Configuration Management
482497

483498
The configuration system provides centralized configuration management with multiple loading strategies.
484499

485500
**Key Components:**
486501

487-
- `config.py`: Main configuration classes and validation
488-
- `config_loader.py`: Configuration loading utilities
502+
- `config/constants.py`: Shared defaults and global constant definitions
503+
- `config/loader.py`: Configuration discovery and parsing from files/env/CLI
504+
- `config/manager.py`: Runtime configuration manager exposed via `mcp_fuzzer.config`
489505

490506
**Configuration Sources:**
491507

492508
- **Environment Variables**: Runtime configuration via environment
493-
- **Configuration Files**: YAML/JSON configuration files
509+
- **Configuration Files**: YAML configuration files
494510
- **CLI Arguments**: Command-line argument overrides
495511
- **Default Values**: Sensible defaults for all settings
496512

@@ -501,7 +517,7 @@ The configuration system provides centralized configuration management with mult
501517
- **Runtime Settings**: Execution and concurrency settings
502518
- **Reporting Settings**: Output and logging configuration
503519

504-
### 9. Reporting System
520+
### 11. Reporting System
505521

506522
The reporting system provides centralized output management and comprehensive result reporting with multiple output formats and real-time progress tracking.
507523

@@ -514,20 +530,20 @@ The reporting system provides centralized output management and comprehensive re
514530

515531
**Reporting Features:**
516532

517-
- **Multi-Format Output**: Support for console, JSON, text, CSV, and XML formats
533+
- **Multi-Format Output**: Console summaries plus JSON, text, CSV, XML, HTML, and Markdown exports
534+
- **Standardized Artifacts**: Output protocol produces structured JSON bundles for fuzzing, safety, and error data
518535
- **Real-time Progress**: Live progress indicators and status updates during fuzzing
519536
- **Result Aggregation**: Comprehensive statistics, success rates, and performance metrics
520537
- **Safety Reporting**: Detailed breakdown of blocked operations, risk assessments, and security events
521538
- **Session Tracking**: Timestamped reports with unique session identification and metadata
522-
- **Configurable Retention**: Automatic cleanup of old reports based on time or size limits
523539

524540
**Output Formats:**
525541

526542
- **Console**: Interactive tables with colors, progress bars, and real-time updates
527-
- **JSON**: Machine-readable structured data for CI/CD integration and external analysis
528-
- **Text**: Human-readable summaries for documentation and sharing
529-
- **CSV**: Spreadsheet-compatible format for data analysis
530-
- **XML**: Enterprise-compatible format for integration with existing systems
543+
- **JSON/Text**: Machine-readable structured data plus readable summaries for doc handoffs
544+
- **CSV/XML**: Spreadsheet- and enterprise-friendly formats for data analysis
545+
- **HTML/Markdown**: Presentation-ready exports for reports and runbooks
546+
- **Standardized Output Protocol**: Currently persisted as JSON files regardless of `--output-format`; other values are reserved for future protocol encodings
531547

532548
**Report Types:**
533549

@@ -562,20 +578,20 @@ graph TD
562578

563579
```yaml
564580
output:
565-
format: "json" # json, yaml, csv, xml, console
581+
format: "json" # Standardized output protocol is JSON today
566582
directory: "./reports" # Output directory path
567-
compress: true # Enable compression for large reports
568-
types: # Specific report types to generate
583+
compress: true # Enable compression for standardized output
584+
types: # Specific standardized output types to generate
569585
- "fuzzing_results"
570586
- "error_report"
571587
- "safety_summary"
572588
- "performance_metrics"
573-
retention:
574-
days: 30 # Retain reports for N days
575-
max_size: "1GB" # Maximum total size before cleanup
576589
schema: "./custom_schema.json" # Custom output schema file
577590
```
578591

592+
CLI flags `--export-csv`, `--export-xml`, `--export-html`, and `--export-markdown`
593+
invoke the corresponding exporters on top of the standardized protocol output.
594+
579595
**Integration Features:**
580596

581597
- **CI/CD Integration**: JSON output for automated test pipelines
@@ -777,7 +793,7 @@ The system is designed for extensibility:
777793

778794
Safety is built into every layer:
779795

780-
- **Environment detection** prevents dangerous operations
796+
- **Danger pattern detection** blocks suspicious URLs, scripts, and command content
781797
- **Input sanitization** filters potentially dangerous data
782798
- **System command blocking** prevents command execution
783799
- **Filesystem sandboxing** confines file operations
@@ -810,8 +826,6 @@ export MCP_FUZZER_STDIO_TIMEOUT=30.0
810826

811827
# Safety configuration
812828
export MCP_FUZZER_FS_ROOT=~/.mcp_fuzzer
813-
export MCP_FUZZER_ENABLE_SAFETY=true
814-
export MCP_FUZZER_DANGEROUS_TESTS_DISABLED=false
815829
```
816830

817831
## Performance Considerations
@@ -841,11 +855,10 @@ Careful resource management ensures stability:
841855

842856
The architecture supports scaling:
843857

844-
- **Multiple worker processes**
845-
- **Distributed fuzzing** across machines
846-
- **Configurable concurrency limits**
847-
- **Resource usage monitoring**
848-
- **Batch operation execution**
858+
- **Configurable async concurrency limits** through AsyncFuzzExecutor semaphores
859+
- **Batch execution** for tool runs and protocol messages
860+
- **Watchdog performance metrics** to inform resource planning
861+
- **Standardized output artifacts** for CI/CD and fleet orchestration
849862

850863
## Security Considerations
851864

@@ -854,9 +867,9 @@ The architecture supports scaling:
854867
All input is validated and sanitized:
855868

856869
- **Argument validation** at CLI level
857-
- **Transport-level input sanitization**
858-
- **Safety system filtering**
859-
- **Environment variable validation**
870+
- **Transport-level JSON-RPC validation and serialization checks**
871+
- **Safety system filtering** via the `DangerDetector`
872+
- **Filesystem path sanitization** through the sandbox
860873
- **Host normalization** for network access control
861874

862875
### Access Control
@@ -866,7 +879,7 @@ The system implements access control:
866879
- **Filesystem sandboxing**
867880
- **Process isolation**
868881
- **System command blocking**
869-
- **Environment detection**
882+
- **Network policy enforcement** for redirects and outbound requests
870883

871884
### Audit Logging
872885

@@ -899,12 +912,12 @@ Comprehensive logging throughout:
899912

900913
### Health Checks
901914

902-
Built-in health monitoring:
915+
Operational status is surfaced through:
903916

904-
- **Transport connectivity checks**
905-
- **Server availability monitoring**
906-
- **Safety system status**
907-
- **Resource usage monitoring**
917+
- **ProcessWatchdog monitoring** for hung subprocesses and activity callbacks
918+
- **Reporter metadata** capturing session IDs, timestamps, and completion status
919+
- **SafetyReporter summaries** indicating whether safety filters are active
920+
- **Structured logging** of transport failures and retry attempts
908921

909922
## System Integration
910923

0 commit comments

Comments
 (0)