Skip to content

[test] add tbor sd fuzz targets - #682

Draft
David Zimmermann (zimmy87) wants to merge 3 commits into
user/v-davidz/add_tbor_cert_fuzzfrom
user/v-davidz/add_tbor_sd_fuzz
Draft

[test] add tbor sd fuzz targets#682
David Zimmermann (zimmy87) wants to merge 3 commits into
user/v-davidz/add_tbor_cert_fuzzfrom
user/v-davidz/add_tbor_sd_fuzz

Conversation

@zimmy87

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI lite review requested due to automatic review settings September 1, 2026 23:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are additive test/fuzz targets with only minor maintainability/lint nits (e.g., unused imports, naming schema limits) noted.

Pull request overview

Adds new libFuzzer targets for TBOR “security domain” (SD) DDI commands, expanding fuzz coverage of request encoding/dispatch through the existing azihsm_ddi_tbor_test_harness::TestCtx harness.

Changes:

  • Added 6 new TBOR SD fuzz targets (create peer/remote backup, reseal/restore backups, sealing-key generation).
  • Registered the new fuzz binaries in fuzz/Cargo.toml so they can be built/invoked as individual fuzz targets.
File summaries
File Description
fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_sealing_key_gen.rs New fuzz target for TborSdSealingKeyGenReq.
fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_create_peer_backup.rs New fuzz target for TborSdCreatePeerBackupReq.
fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_create_remote_backup.rs New fuzz target for TborSdCreateRemoteBackupReq.
fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_reseal_remote_backup.rs New fuzz target for TborSdResealRemoteBackupReq.
fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_restore_local_backup.rs New fuzz target for TborSdRestoreLocalBackupReq with bounded variable-length blobs.
fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_restore_peer_backup.rs New fuzz target for TborSdRestorePeerBackupReq.
fuzz/Cargo.toml Registers the new fuzz target binaries.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 6
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

use azihsm_ddi_tbor_types::ReportDescriptor;
use azihsm_ddi_tbor_types::SessionType;
use azihsm_ddi_tbor_types::TborSdCreatePeerBackupReq;
use libfuzzer_sys::arbitrary;
use azihsm_ddi_tbor_types::ReportDescriptor;
use azihsm_ddi_tbor_types::SessionType;
use azihsm_ddi_tbor_types::TborSdCreateRemoteBackupReq;
use libfuzzer_sys::arbitrary;
use azihsm_ddi_tbor_types::ReportDescriptor;
use azihsm_ddi_tbor_types::SessionType;
use azihsm_ddi_tbor_types::TborSdResealRemoteBackupReq;
use libfuzzer_sys::arbitrary;
Comment on lines +6 to +24
use azihsm_ddi_tbor_test_harness::TestCtx;
use azihsm_ddi_tbor_types::SessionType;
use azihsm_ddi_tbor_types::TborSdRestoreLocalBackupReq;
use libfuzzer_sys::arbitrary;
use libfuzzer_sys::arbitrary::Arbitrary;
use libfuzzer_sys::fuzz_target;

const CU: u8 = 1;
static CTX: std::sync::OnceLock<TestCtx> = std::sync::OnceLock::new();

fn bounded_pok(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Vec<u8>> {
let len = usize::arbitrary(u)? % (180 + 1);
Ok(u.bytes(len)?.to_vec())
}

fn bounded_sd_mk(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Vec<u8>> {
let len = usize::arbitrary(u)? % (164 + 1);
Ok(u.bytes(len)?.to_vec())
}
use azihsm_ddi_tbor_types::SD_MK_BACKUP_LEN;
use azihsm_ddi_tbor_types::SessionType;
use azihsm_ddi_tbor_types::TborSdRestorePeerBackupReq;
use libfuzzer_sys::arbitrary;
use azihsm_ddi_tbor_test_harness::TestCtx;
use azihsm_ddi_tbor_types::SessionType;
use azihsm_ddi_tbor_types::TborSdSealingKeyGenReq;
use libfuzzer_sys::arbitrary;
Copilot AI review requested due to automatic review settings September 1, 2026 23:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are additive fuzz targets with low risk to production code, and the only feedback is minor maintainability cleanup.

Review details

Suppressed comments (2)

fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_restore_local_backup.rs:19

  • Avoid hard-coded length bounds here; the maximum size for pok_local_backup is already defined as MASKED_SD_LEN in azihsm_ddi_tbor_types. Using the constant keeps the fuzz target aligned with the TBOR schema if the envelope size changes.
fn bounded_pok(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Vec<u8>> {
    let len = usize::arbitrary(u)? % (180 + 1);
    Ok(u.bytes(len)?.to_vec())
}

fuzz/fuzz_targets/ddi/tbor/fuzz_tbor_sd_restore_local_backup.rs:24

  • Avoid hard-coded length bounds here; sd_mk_backup's maximum size is already available as SD_MK_BACKUP_LEN in azihsm_ddi_tbor_types. Reusing it prevents this fuzzer from silently diverging from the schema.
fn bounded_sd_mk(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Vec<u8>> {
    let len = usize::arbitrary(u)? % (164 + 1);
    Ok(u.bytes(len)?.to_vec())
}
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants