cargo-fuzz and libfuzzer-sys, targeting various subsystems including configuration parsers, protocol decoders, and redaction routines fuzz/Cargo.toml#1-11.
Fuzzing Architecture and Data Flow
The fuzzing harness operates by providing pseudo-random byte streams to specialized “fuzz targets.” These targets map the raw input to specific internal functions, often with size constraints to prevent resource exhaustion during campaigns.System-to-Code Mapping: Fuzz Targets
| Fuzz Target Name | Code Entity Targeted | Purpose |
|---|---|---|
config_path_parser | ConfigPath | Validates file path resolution and sandbox escape prevention in configuration. |
a2ui_json_parser | palyra_a2ui | Tests the resilience of the Agent-to-User Interface JSON Patch parser. |
webhook_payload_parser | WebhookEnvelope | Ensures external webhook signatures and payloads are handled safely. |
workspace_patch_parser | apply_workspace_patch | Validates the logic for applying file diffs within the workspace sandbox. |
process_runner_input_parser | parse_process_runner_tool_input | Hardens the parser for tool execution payloads. |
redaction_routines | redaction.rs | Ensures sensitive data (keys, tokens) is correctly identified and masked. |
webhook_replay_verifier | WebhookReplay | Tests protection against replay attacks for external triggers. |
Fuzzing Data Flow Diagram
The following diagram illustrates how raw fuzzer input is transformed and routed to the internal logic of thepalyra-common and palyra-daemon components.
“Fuzzing Data Flow”
Sources: fuzz/fuzz_targets/process_runner_input_parser.rs#8-13, fuzz/fuzz_targets/workspace_patch_parser.rs#21-41, crates/palyra-common/src/process_runner_input.rs#26-31, crates/palyra-common/src/redaction.rs#31-63
Key Fuzzing Targets
Workspace Patch Parser
Theworkspace_patch_parser targets the apply_workspace_patch function. This is critical because it handles file modifications requested by agents. The fuzzer ensures that even with malicious patch data, the parser respects WorkspacePatchLimits, such as max_patch_bytes (16 KB) and max_files_touched (32) fuzz/fuzz_targets/workspace_patch_parser.rs#10-39.
Process Runner Input
Theprocess_runner_input_parser targets the tool input for palyra.process.run. It uses serde_json with deny_unknown_fields to ensure strict schema adherence crates/palyra-common/src/process_runner_input.rs#5-7. The fuzzer attempts to break the parser by providing malformed JSON or unexpected types to the ProcessRunnerToolInput struct fuzz/fuzz_targets/process_runner_input_parser.rs#8-13.
Redaction Routines
Theredaction_routines target exercises the logic in crates/palyra-common/src/redaction.rs. This subsystem is responsible for scrubbing secrets from logs and UI outputs.
The redaction engine uses SENSITIVE_KEY_MARKERS to identify potential secrets:
- Markers:
access_token,api_key,authorization,client_secret,password,secret, etc. crates/palyra-common/src/redaction.rs#5-22 - Functions:
redact_headercrates/palyra-common/src/redaction.rs#49,redact_urlcrates/palyra-common/src/redaction.rs#63, andredact_auth_errorcrates/palyra-common/src/redaction.rs#89.
Running Fuzz Campaigns
Fuzzing is performed using thecargo fuzz toolchain. Campaigns should be run periodically or after significant changes to parsing logic.
Prerequisites
- Nightly Rust compiler.
cargo-fuzzinstalled (cargo install cargo-fuzz).