Skip to content

Commit 8cb9346

Browse files
committed
add fuzzing tests
1 parent 46fa1a5 commit 8cb9346

File tree

4 files changed

+1325
-2
lines changed

4 files changed

+1325
-2
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,41 @@ jobs:
6868

6969
- uses: dtolnay/[email protected]
7070

71-
- name: Build conformance binary
72-
run: cargo build --release --package sigstore-conformance
71+
- name: Build binaries
72+
run: cargo build --release --package sigstore-conformance --example verify_bundle
7373

7474
- uses: sigstore/sigstore-conformance@main
7575
with:
7676
entrypoint: ./target/release/conformance
77+
78+
- name: Upload verify_bundle binary
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: verify_bundle
82+
path: target/release/examples/verify_bundle
83+
84+
mutation-tests:
85+
name: Mutation Fuzzing
86+
runs-on: ubuntu-latest
87+
needs: conformance
88+
steps:
89+
- uses: actions/checkout@v4
90+
91+
- uses: actions/setup-python@v5
92+
with:
93+
python-version: '3.12'
94+
95+
- name: Download verify_bundle binary
96+
uses: actions/download-artifact@v4
97+
with:
98+
name: verify_bundle
99+
path: target/release/examples
100+
101+
- name: Make binary executable
102+
run: chmod +x target/release/examples/verify_bundle
103+
104+
- name: Clone sigstore-conformance test data
105+
run: git clone --depth 1 https://github.com/sigstore/sigstore-conformance.git
106+
107+
- name: Run mutation fuzzer
108+
run: python3 tests/mutation_fuzzer.py --verifier-type rust

crates/sigstore-bundle/src/validation.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ fn validate_v0_1(bundle: &Bundle, options: &ValidationOptions) -> Result<()> {
5353
));
5454
}
5555

56+
// Validate inclusion proofs if present (v0.1 may have both promise and proof)
57+
validate_inclusion_proofs(bundle)?;
58+
5659
// Common validation
5760
validate_common(bundle, options)
5861
}

crates/sigstore-verify/src/verify.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,20 @@ impl Verifier {
364364
}
365365
}
366366
}
367+
368+
// For MessageSignature bundles, verify the messageDigest matches the artifact
369+
if let SignatureContent::MessageSignature(msg_sig) = &bundle.content {
370+
if let Some(ref digest) = msg_sig.message_digest {
371+
let artifact_hash = compute_artifact_digest(&artifact);
372+
373+
// Compare the digest in the bundle with the computed artifact hash
374+
if digest.digest.as_bytes() != artifact_hash.as_bytes() {
375+
return Err(Error::Verification(
376+
"message digest in bundle does not match artifact hash".to_string(),
377+
));
378+
}
379+
}
380+
}
367381
// Note: For hashedrekord (MessageSignature), the signature verification
368382
// is performed in step (8) by verify_hashedrekord_entries, which properly
369383
// handles prehashed signatures.

0 commit comments

Comments
 (0)