Skip to main content
The Fuzzing Harness provides a suite of automated testing targets designed to identify edge-case crashes, memory safety issues, and logic errors by providing semi-randomized input to critical parsers and validation routines. Palyra utilizes cargo-fuzz (based on LLVM’s libFuzzer) to stress-test components that handle untrusted data from external sources, such as webhooks, configuration files, and AI-generated patches.

Fuzzing Architecture

The fuzzing infrastructure is centralized in the /fuzz directory, which acts as a dedicated workspace for fuzz targets. Each target is a standalone binary that exercises a specific library function or module.

Data Flow: External Input to Fuzz Target

The following diagram illustrates how external, potentially malicious data is routed through the fuzzing harness to validate internal logic. Fuzzing Input Pipeline Sources: fuzz/Cargo.toml#10-16, fuzz/fuzz_targets/workspace_patch_parser.rs#21-41

Fuzz Targets

Palyra maintains several high-priority fuzz targets targeting parsers and security-sensitive routines.
Target NameFile PathComponent TestedPurpose
config_path_parserfuzz/fuzz_targets/config_path_parser.rspalyra-commonValidates configuration file path resolution and sanitization.
a2ui_json_parserfuzz/fuzz_targets/a2ui_json_parser.rspalyra-a2uiTests the Agent-to-UI JSON protocol parser for malformed envelopes.
webhook_payload_parserfuzz/fuzz_targets/webhook_payload_parser.rspalyra-connectorsExercises Discord/Slack/Telegram webhook ingestion logic.
workspace_patch_parserfuzz/fuzz_targets/workspace_patch_parser.rspalyra-commonStress-tests the apply_workspace_patch logic against malformed diffs.
process_runner_input_parserfuzz/fuzz_targets/process_runner_input_parser.rspalyra-commonValidates parse_process_runner_tool_input for palyra.process.run.
redaction_routinesfuzz/fuzz_targets/redaction_routines.rspalyra-commonEnsures sensitive data masking does not crash on complex strings.
webhook_replay_verifierfuzz/fuzz_targets/webhook_replay_verifier.rspalyra-commonTests the cryptographic signature and replay protection logic.
Sources: fuzz/Cargo.toml#18-79, fuzz/fuzz_targets/process_runner_input_parser.rs#1-13, fuzz/fuzz_targets/workspace_patch_parser.rs#1-41

Implementation Details

Workspace Patch Fuzzing

The workspace_patch_parser target is particularly critical as it simulates AI-generated file modifications. It uses a temporary directory via fuzz_workspace_root to safely execute apply_workspace_patch calls. It enforces WorkspacePatchLimits to prevent the fuzzer from consuming excessive system resources during a campaign. Code Entity Mapping: Workspace Patching Sources: fuzz/fuzz_targets/workspace_patch_parser.rs#12-19, fuzz/fuzz_targets/workspace_patch_parser.rs#29-40

Process Runner Input Validation

The process_runner_input_parser target exercises the parse_process_runner_tool_input function in palyra-common. This function uses serde_json with #[serde(deny_unknown_fields)] to ensure strict schema adherence for tool execution requests. Code Entity Mapping: Tool Input Parsing Sources: fuzz/fuzz_targets/process_runner_input_parser.rs#8-13, crates/palyra-common/src/process_runner_input.rs#5-17, crates/palyra-common/src/process_runner_input.rs#26-31

Build and Execution

The project provides automation for building fuzz targets via the Makefile and justfile.

Building Targets

To compile all fuzz targets and ensure they are compatible with the current workspace:
make fuzz-build
# OR
just fuzz-build
This command checks for the presence of cargo-fuzz and builds the entire suite including config_path_parser, a2ui_json_parser, and webhook_payload_parser. Sources: Makefile#147-160, justfile#154-167

Running a Campaign

To start a fuzzing campaign for a specific target:
cd fuzz
cargo fuzz run <target_name>
Example: cargo fuzz run workspace_patch_parser.

CI/CD Integration

Fuzzing is integrated into the Palyra Security SDLC baseline. The pipeline is configured to:
  1. Compile on PR: Ensure that changes to the codebase do not break the fuzzing harness.
  2. Nightly Campaigns: Run extended fuzzing sessions to discover deep logic bugs that require millions of iterations.
Sources: infra/ci/security.yml#19-22, infra/ci/security.yml#24-35