fuzz/ directory and utilizes libfuzzer-sys to perform coverage-guided fuzzing against various system components.
Overview of Fuzz Targets
Palyra implements nine distinct fuzz targets, each targeting a specific entry point where untrusted or complex data enters the system.| Target Name | Target Component | Description |
|---|---|---|
config_path_parser | palyra-common | Validates TOML configuration path resolution and migration logic. |
a2ui_json_parser | palyra-a2ui | Fuzzes the JSON-to-UI patch protocol and Canvas rendering instructions. |
webhook_payload_parser | palyra-connectors | Tests inbound webhook parsing for Discord, Slack, and Telegram. |
workspace_patch_parser | palyra-common | Validates the safety of apply_workspace_patch against malicious diffs. |
process_runner_input_parser | palyra-common | Fuzzes the ProcessRunnerToolInput JSON deserializer. |
auth_profile_registry_parser | palyra-auth | Tests the registry that manages identity and profile persistence. |
redaction_routines | palyra-common | Ensures sensitive data markers (tokens/keys) are correctly identified and scrubbed. |
channel_payload_validation | palyra-connectors | Validates internal message routing between the daemon and connectors. |
webhook_replay_verifier | palyra-connectors | Tests the cryptographic signature verification for replayed webhook events. |
Implementation Details
Fuzz targets are implemented as standalone binaries using thefuzz_target! macro. They typically ingest a raw byte slice (&[u8]) and attempt to exercise a specific library function.
Example: Process Runner Input Fuzzing
Theprocess_runner_input_parser target exercises the parse_process_runner_tool_input function crates/palyra-common/src/process_runner_input.rs#26-31. It enforces a maximum input size of 32 KB to prevent excessive memory consumption during the campaign.
Example: Workspace Patch Fuzzing
Theworkspace_patch_parser target tests the multi-step process of applying diffs to a filesystem. It uses a OnceLock to create a sandboxed temporary directory for operations fuzz/fuzz_targets/workspace_patch_parser.rs#12-19. The fuzzer passes a WorkspacePatchRequest with dry_run: true to test the logic without side effects while respecting WorkspacePatchLimits fuzz/fuzz_targets/workspace_patch_parser.rs#29-40.
Data Flow: Natural Language to Code Entity Space
The following diagram illustrates how the fuzzing harness bridges the gap between raw input and the internal palyra-common logic.
“Fuzzing Data Flow: Workspace Patching”
Sources: fuzz/fuzz_targets/workspace_patch_parser.rs#21-41, crates/palyra-common/src/workspace_patch.rs#1-50
Redaction Routine Fuzzing
Theredaction_routines target is critical for security, as it ensures that palyra-daemon logs do not leak credentials. It targets palyra-common/src/redaction.rs, specifically testing:
is_sensitive_key: Identification of markers likeapi_keyorbearercrates/palyra-common/src/redaction.rs#25-28.redact_url: Stripping userinfo and sensitive query parameters from URLs crates/palyra-common/src/redaction.rs#63-86.redact_auth_error: Scrubbing tokens from complex error messages crates/palyra-common/src/redaction.rs#89-111.
Running Fuzzing Campaigns
Prerequisites
Fuzzing requires the Nightly Rust toolchain and thecargo-fuzz sub-command.
Executing a Target
To run a specific campaign (e.g., the workspace patch parser):- Navigate to the root of the repository.
- Run the following command:
Managing Artifacts
When a fuzzer finds a crash, it saves the input tofuzz/artifacts/<target_name>/. These files can be used to reproduce the failure by passing them back to the target: