Skip to content

Commit 0027465

Browse files
authored
feat: add fuzzing tests (#13)
1 parent 46fa1a5 commit 0027465

File tree

4 files changed

+1327
-2
lines changed

4 files changed

+1327
-2
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,43 @@ 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: |
73+
cargo build --release --package sigstore-conformance
74+
cargo build --release --example verify_bundle
7375
7476
- uses: sigstore/sigstore-conformance@main
7577
with:
7678
entrypoint: ./target/release/conformance
79+
80+
- name: Upload verify_bundle binary
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: verify_bundle
84+
path: target/release/examples/verify_bundle
85+
86+
mutation-tests:
87+
name: Mutation Fuzzing
88+
runs-on: ubuntu-latest
89+
needs: conformance
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- uses: actions/setup-python@v5
94+
with:
95+
python-version: '3.12'
96+
97+
- name: Download verify_bundle binary
98+
uses: actions/download-artifact@v4
99+
with:
100+
name: verify_bundle
101+
path: target/release/examples
102+
103+
- name: Make binary executable
104+
run: chmod +x target/release/examples/verify_bundle
105+
106+
- name: Clone sigstore-conformance test data
107+
run: git clone --depth 1 https://github.com/sigstore/sigstore-conformance.git
108+
109+
- name: Run mutation fuzzer
110+
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)