Skip to content

fix: audit parser hardness — bounded sections, x509, DSSE fuzz#98

Merged
avrabe merged 1 commit into
mainfrom
fix/audit-parser-hardness-2026-04-30
Apr 30, 2026
Merged

fix: audit parser hardness — bounded sections, x509, DSSE fuzz#98
avrabe merged 1 commit into
mainfrom
fix/audit-parser-hardness-2026-04-30

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Apr 29, 2026

Summary

Closes 4 parser-hardness findings from the 2026-04-30 audit.

ID File Fix
H-1 src/lib/src/wasm_module/mod.rs SectionsIterator now caps total emitted sections at MAX_SECTIONS=4096 and returns WSError::TooManySections when exceeded.
H-2 src/lib/src/signature/keyless/format.rs KeylessSignature::verify_cert_chain rejects chains deeper than MAX_CHAIN_DEPTH=8 before invoking x509_parser / WebPKI; new WSError::ChainTooDeep variant.
H-6 src/attestation/src/dsse.rs:29 PAYLOAD_TYPE_SLSA corrected from application/vnd.in-toto+json (collision with PAYLOAD_TYPE_INTOTO) to application/vnd.slsa.provenance+json.
H-7 fuzz/fuzz_targets/fuzz_dsse_envelope.rs (new), fuzz/Cargo.toml New libFuzzer target for wsc::dsse::DsseEnvelope JSON parsing. Oracle is parse + serialize + re-parse equality, not just no-panic.

Constant choices

  • MAX_SECTIONS = 4096 — generous vs. the ~100-section legitimate ceiling but bounds adversarial inputs declaring millions of empty sections. No prior ELF constant to align with.
  • MAX_CHAIN_DEPTH = 8 — industry-standard ceiling. Real Fulcio chains are 2–3 deep; commercial CAs ship at most 4–5; 8 leaves comfortable headroom while rejecting heap-exhaustion-class adversarial chains.

Tests added

  • wasm_module::tests::test_sections_iterator_max_sections_cap — feeds MAX_SECTIONS+1 empty Type sections, asserts the iterator yields exactly MAX_SECTIONS then errors with TooManySections.
  • signature::keyless::format::tests::test_verify_cert_chain_rejects_too_deep — 100-cert synthetic chain rejected with ChainTooDeep(MAX_CHAIN_DEPTH).
  • signature::keyless::format::tests::test_verify_cert_chain_at_max_depth_proceeds_to_parser — chain at exactly MAX_CHAIN_DEPTH is not depth-rejected (proves the bound is at MAX_CHAIN_DEPTH+1, not below).

Test plan

  • cargo build --workspace --release passes.
  • cargo test --workspace passes (732 lib tests + downstream).
  • New unit tests pass (test_sections_iterator_max_sections_cap, test_verify_cert_chain_rejects_too_deep, test_verify_cert_chain_at_max_depth_proceeds_to_parser).
  • cd fuzz && cargo build --bin fuzz_dsse_envelope compiles and links the new target.
  • CI green.

Out of scope

  • Files reserved for parallel PRs (signer/oidc/rekor_verifier, verus_proofs, lean, artifacts, README, docs, .github/workflows) untouched.
  • No version bump.

Fixes: H-1, H-2, H-6, H-7
Verifies: CR-8 (bounded resource consumption)

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

… mime-type

Closes 4 findings from the 2026-04-30 audit:
  H-1 — bound WASM SectionsIterator at MAX_SECTIONS=4096
  H-2 — bound x509 chain depth at MAX_CHAIN_DEPTH=8
  H-6 — PAYLOAD_TYPE_SLSA → application/vnd.slsa.provenance+json
  H-7 — add fuzz_dsse_envelope target with round-trip oracle

Fixes: H-1, H-2, H-6, H-7
Verifies: CR-8 (bounded resource consumption)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 94.91525% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lib/src/signature/keyless/format.rs 93.10% 2 Missing ⚠️
src/lib/src/wasm_module/mod.rs 96.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@avrabe avrabe merged commit ae3a0a0 into main Apr 30, 2026
21 checks passed
@avrabe avrabe deleted the fix/audit-parser-hardness-2026-04-30 branch April 30, 2026 05:14
avrabe added a commit that referenced this pull request Apr 30, 2026
Bumps Cargo.toml, MODULE.bazel, src/cli/BUILD.bazel, and Cargo.lock
to 0.8.1. Adds CHANGELOG.md (new file, repo did not have one) with
the full release notes.

This release closes 26 of 33 findings from the 2026-04-30
14-perspective audit. Specific fix-PRs are #96 (STPA-Sec / docs),
#97 (hygiene), #98 (parser hardness), #99 (formal-verif honesty +
CI), #100 (keyless / OIDC hardening). Two findings (cert-pinning
enforcement, no_std verifier) are deferred to issue #95 and issue
#79 respectively.

Note on H-8 (version drift): MODULE.bazel and src/cli/BUILD.bazel
were at 0.2.7 on main; this commit takes them straight to 0.8.1.
PR #97 also bumps these to 0.8.0 as part of its H-8 fix; whichever
PR merges last has a trivial conflict that resolves to 0.8.1.

Trace: skip

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
avrabe added a commit that referenced this pull request May 1, 2026
Bumps Cargo.toml, MODULE.bazel, src/cli/BUILD.bazel, and Cargo.lock
to 0.8.1. Adds CHANGELOG.md (new file, repo did not have one) with
the full release notes.

This release closes 26 of 33 findings from the 2026-04-30
14-perspective audit. Specific fix-PRs are #96 (STPA-Sec / docs),
#97 (hygiene), #98 (parser hardness), #99 (formal-verif honesty +
CI), #100 (keyless / OIDC hardening). Two findings (cert-pinning
enforcement, no_std verifier) are deferred to issue #95 and issue
#79 respectively.

Note on H-8 (version drift): MODULE.bazel and src/cli/BUILD.bazel
were at 0.2.7 on main; this commit takes them straight to 0.8.1.
PR #97 also bumps these to 0.8.0 as part of its H-8 fix; whichever
PR merges last has a trivial conflict that resolves to 0.8.1.

Trace: skip

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
avrabe added a commit that referenced this pull request May 1, 2026
Bumps Cargo.toml, MODULE.bazel, src/cli/BUILD.bazel, and Cargo.lock
to 0.8.1. Adds CHANGELOG.md (new file, repo did not have one) with
the full release notes.

This release closes 26 of 33 findings from the 2026-04-30
14-perspective audit. Specific fix-PRs are #96 (STPA-Sec / docs),
#97 (hygiene), #98 (parser hardness), #99 (formal-verif honesty +
CI), #100 (keyless / OIDC hardening). Two findings (cert-pinning
enforcement, no_std verifier) are deferred to issue #95 and issue
#79 respectively.

Note on H-8 (version drift): MODULE.bazel and src/cli/BUILD.bazel
were at 0.2.7 on main; this commit takes them straight to 0.8.1.
PR #97 also bumps these to 0.8.0 as part of its H-8 fix; whichever
PR merges last has a trivial conflict that resolves to 0.8.1.

Trace: skip

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
avrabe added a commit that referenced this pull request May 11, 2026
The target referenced four APIs that no longer exist on
`wsc::signature::keys`:

  - `PublicKey::from_openssh`
  - `PublicKey::from_any`
  - `PublicKeySet::from_openssh`
  - `SecretKey::from_openssh`

OpenSSH ingestion and the polymorphic `from_any` auto-detect entry point
were removed from the public-key surface; only raw-bytes, PEM, and DER
parsing remain. Audit PR #98 (parser hardness) flagged the build failure
as a pre-existing leftover, out of scope for that change.

This commit rewrites the target against the current surface only:

  - PublicKey::{from_bytes,from_pem,from_der} + round-trip oracles
  - SecretKey::{from_bytes,from_pem,from_der} + round-trip
    (handling the `Zeroizing<Vec<u8>>` / `Zeroizing<String>` returns of
    `SecretKey::to_bytes` / `to_pem` via deref coercion)
  - determinism check on `PublicKey::attach_default_key_id`

A module-level comment documents the dropped APIs so the next reviewer
does not re-introduce them. No core source touched; only the fuzz
target was changed.

Verified:
  - `cd fuzz && cargo build --bin fuzz_public_key`  -> clean
  - `cd fuzz && cargo build --bins`                 -> clean
  - `cargo build --workspace --release`             -> clean

Trace: skip

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
avrabe added a commit that referenced this pull request May 11, 2026
Patch release bundling four merged PRs:
  #107 — cargo-deny CI step hardening (closes #103)
  #108 — discharge lemma_le64_injective Verus admit (audit C-1 partial)
  #109 — repair fuzz_public_key target (audit follow-up from #98)
  #110 — clear 3 RUSTSEC advisories via dep bumps (fixes #102)

Companion work on 0.8.2+next:
  #111 — criterion benches for signature verification (#89)
  #112 — lift Kani wasm_module mask; document merkle + format

See CHANGELOG.md for the full release notes.

Trace: skip

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
avrabe added a commit that referenced this pull request May 12, 2026
Adds criterion-driven benchmarks for the four signature-verification hot
paths: Ed25519 verify, DSSE envelope parse+verify, Merkle tree validation
(parameterised by leaf count), and cert-chain validation (parameterised
by chain length, matching MAX_CHAIN_DEPTH=8 from audit PR #98).

SLH-DSA bench deferred to issue #46. CI integration deferred to a
follow-up PR — this commit only lands the bench harness so baselines
can be captured.

Traceability comments at the top of the bench file link each group to
its CR-* artifact.

Implements: #89
Verifies: CR-1, CR-3, CR-7, CR-8

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
avrabe added a commit that referenced this pull request May 12, 2026
…111)

Adds criterion-driven benchmarks for the four signature-verification hot
paths: Ed25519 verify, DSSE envelope parse+verify, Merkle tree validation
(parameterised by leaf count), and cert-chain validation (parameterised
by chain length, matching MAX_CHAIN_DEPTH=8 from audit PR #98).

SLH-DSA bench deferred to issue #46. CI integration deferred to a
follow-up PR — this commit only lands the bench harness so baselines
can be captured.

Traceability comments at the top of the bench file link each group to
its CR-* artifact.

Implements: #89
Verifies: CR-1, CR-3, CR-7, CR-8

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant