Skip to content

refactor(security)!: qualify orchestration lint - #294

Merged
polaz merged 5 commits into
mainfrom
refactor/#276-security-pedantic
Oct 25, 2026
Merged

polaz merged 5 commits into
mainfrom
refactor/#276-security-pedantic

Conversation

@polaz

@polaz polaz commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Qualifies the security orchestration layer under scoped pedantic clippy, with no suppressions and no policy relaxation.

  • Gate. scripts/check-security.mjs runs on the shared diagnostic gate with --force-warn clippy::pedantic (so allow cannot hide a finding). It covers five entry graphs: workspace with all features, workspace with default features, minimal XMLDSig, minimal XMLEnc and the XAdES adapter. Findings are filtered to policy, provider adapters, key inventory and import, XMLDSig/XMLEnc operations, the authenticated operation/evidence API, reference/transform orchestration, the XAdES adapter and their tests. The script and its node --test suite run in the existing hardening job.
  • Owned code.
    • Long orchestration functions are split into named stages: transform chains, XPath admission, relationship normalization, XSLT execution, key resolution, XMLEnc encrypt/decrypt, PKIX CRL matching.
    • Public fallible APIs document # Errors, and pure accessors are #[must_use].
    • Lossy casts are now checked conversions; small Copy policy values are taken by value.
    • Inline unit tests are moved into sibling files.
  • Cfg-dependent paths are gated where they originate.
    • ML-KEM usage validation and the XSLT transform parser exist only when their features are enabled.
    • One certificate-to-XMLDSig algorithm mapping replaces the separate RSA PKCS#1 and ECDSA mappings and the duplicated digest list.
  • Typed key-source policy. KeySourcePolicy is a KeySourceKind set (ALL, NONE, contains, insert, remove, set, intersection, From<[KeySourceKind; N]>) instead of six public booleans. Profiles and xml-sec-config build it from explicit source kinds.
  • Primitives.
    • structured-asn1, structured-pkix, structured-cms, structured-ltv and structured-xades are now 0.15.1.
    • Production certificate parsing goes through structured-pkix; x509-cert is a dev-dependency only.
    • Untouched here: PEM armor, private-key PKCS#8/PKCS#1 decoding, PKCS#12 import (refactor: migrate PKCS#12 to shared containers #281) and the vendored RustCrypto implementations.
  • Key material under the operation account. Every public-key read on the shared PKIX reader inside a verification operation is charged to that operation's X.509 account:
    • pre-set keys, resolver-bound keys, trusted keys, the native provider and issuer key-strength checks all read under it;
    • the configured max_x509_work and workspace limits apply, the work counts toward aggregate usage, and exhaustion surfaces as a typed ResourceLimitExceeded refusal instead of a malformed key;
    • the VerifyingKey policy hooks receive a VerificationScope (operation policy plus account), and InspectedKeyCandidateBudget::verification_scope gives resolvers that pre-check candidates the same scope;
    • standalone entry points (bare provider calls, key import, direct SPKI helpers) read under an explicit standalone account;
    • the RSA recipient key and the software RSA verifier are built from the already admitted SPKI components instead of being parsed a second time.
  • Security properties. Constant-time comparisons, opaque provider keys, zeroization and provider isolation are unchanged. The PKCS#11 suite still proves that handles cannot cross provider sessions and that raw keys cannot be exported.

Breaking changes

  • KeySourcePolicy fields are replaced by the KeySourceKind set API.
  • PolicyCompiler::authorize_replacement takes &PolicyValidity.
  • VerifyingKey::validate_policy, validate_signature_value_with_policy and verify_with_policy take &VerificationScope instead of &VerificationPolicy; verify_with_policy also takes the &SignatureContext.
  • SignatureVerificationInput is #[non_exhaustive] and is built with SignatureVerificationInput::new.

Testing

  • node scripts/check-security.mjs: all five entry graphs pass. node --test scripts/check-security.test.mjs passes.
  • cargo fmt --all --check and cargo clippy --workspace --all-targets --all-features -- -D warnings are clean on stable and 1.92.0; the minimal feature profiles of scripts/check-features.sh (dsig, xmlenc, legacy, experimental, pkcs11, fips-dsig) lint clean.
  • cargo nextest run --workspace --all-features -E 'not binary(libxslt_oracle)' with the xmlsec1 1.3.13 oracle and SoftHSM (scripts/test-pkcs11.sh): 5604 passed. The fips-dsig profile tests: 2282 passed.
  • Regression test preset_verification_keys_charge_the_operation_certificate_account: RSA and P-256 pre-set keys verify under the default policy and are refused with ResourceLimitExceeded under max_x509_work = 1.
  • cargo test --doc --workspace --all-features passes. RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features -p xml-sec is clean.
  • The full platform matrix (embedded, WASM, alloc) and coverage run in CI.

BREAKING CHANGE: KeySourcePolicy is a typed set of KeySourceKind values instead of six public bool fields, PolicyCompiler::authorize_replacement takes &PolicyValidity, the VerifyingKey policy hooks take &VerificationScope (verify_with_policy also takes &SignatureContext), and SignatureVerificationInput is non_exhaustive with a new() constructor.

Closes #276

- Add scripts/check-security.mjs on the shared diagnostic gate: pedantic
  clippy over five entry graphs (workspace all/default features, minimal
  XMLDSig, minimal XMLEnc, XAdES adapter), filtered to policy, providers,
  key inventory/import, XMLDSig/XMLEnc operations, operation/evidence API,
  transforms and XAdES, including their tests; wired into the hardening job
- Make every owned diagnostic pass without suppressions: split long
  orchestration functions into named stages, add Errors/must_use docs,
  replace lossy casts with checked conversions, take Copy policy values
  by value and move unit tests into sibling files
- Replace the six KeySourcePolicy booleans with a typed KeySourceKind set
- Take the authorization of PolicyCompiler::authorize_replacement by
  reference, since it is only validated and copied into the policies
- Gate cfg-only paths at their source: ML-KEM usage validation and the
  XSLT transform parser exist only with their features, and one
  certificate-to-XMLDSig algorithm mapping serves RSA PKCS#1 and ECDSA
- Update the structured-* primitives to 0.15.1 and parse certificates
  through structured-pkix; x509-cert remains a test-only dependency

BREAKING CHANGE: KeySourcePolicy is a typed set of KeySourceKind values instead of six public bool fields, and PolicyCompiler::authorize_replacement takes &PolicyValidity.

Closes #276
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 174 files, which is 74 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 1d4546c and 5fdc458.

Files selected for processing: 174
  • .github/workflows/ci.yml
  • Cargo.toml
  • benches/support/mod.rs
  • crates/xml-sec-config/src/settings.rs
  • crates/xml-sec-config/src/settings/key_source_tests.rs
  • crates/xml-sec-xades/Cargo.toml
  • crates/xml-sec-xades/src/basic.rs
  • crates/xml-sec-xades/src/binary.rs
  • crates/xml-sec-xades/src/lib.rs
  • crates/xml-sec-xades/src/path.rs
  • crates/xml-sec-xades/src/path/tests.rs
  • crates/xml-sec-xades/src/signature.rs
  • crates/xml-sec-xades/tests/basic.rs
  • docs/policy-profiles.md
  • docs/rust-api.md
  • docs/xmldsig.md
  • docs/xmlenc.md
  • scripts/check-security.mjs
  • scripts/check-security.test.mjs
  • scripts/fuzz-security.sh
  • src/api.rs
  • src/benchmark_support.rs
  • src/hard_limits.rs
  • src/key_establishment.rs
  • src/key_manager.rs
  • src/key_manager/pkcs12_import.rs
  • src/key_manager/pkcs12_import/tests.rs
  • src/key_manager/tests.rs
  • src/operation.rs
  • src/operation/tests.rs
  • src/policy.rs
  • src/policy/key_establishment.rs
  • src/policy/key_sources.rs
  • src/policy/key_sources/tests.rs
  • src/policy/profiles.rs
  • src/policy/profiles/composition.rs
  • src/policy/profiles/constraints.rs
  • src/provider.rs
  • src/provider/aws_lc.rs
  • src/provider/aws_lc/tests.rs
  • src/provider/chacha.rs
  • src/provider/key_association.rs
  • src/provider/key_encapsulation.rs
  • src/provider/key_encapsulation/rustcrypto.rs
  • src/provider/key_establishment.rs
  • src/provider/key_establishment/bit_hash.rs
  • src/provider/key_establishment/dh.rs
  • src/provider/pkcs11.rs
  • src/provider/rsa_pkcs1v15.rs
  • src/provider/rsa_pss.rs
  • src/rsa_encoding.rs
  • src/rustcrypto_ml_dsa/algebra.rs
  • src/rustcrypto_ml_dsa/hint.rs
  • src/rustcrypto_ml_dsa/lib.rs
  • src/rustcrypto_ml_dsa/ntt.rs
  • src/rustcrypto_ml_dsa/ntt/test.rs
  • src/rustcrypto_ml_dsa/param.rs
  • src/rustcrypto_ml_dsa/sampling.rs
  • src/rustcrypto_ml_dsa/signing.rs
  • src/rustcrypto_sha3/lib.rs
  • src/rustcrypto_sha3/tests.rs
  • src/rustcrypto_sha3/utils.rs
  • src/xmldsig/builder.rs
  • src/xmldsig/digest.rs
  • src/xmldsig/extension.rs
  • src/xmldsig/extension/scalar.rs
  • src/xmldsig/extension/tree.rs
  • src/xmldsig/keys.rs
  • src/xmldsig/mod.rs
  • src/xmldsig/modern.rs
  • src/xmldsig/mutation.rs
  • src/xmldsig/parse.rs
  • src/xmldsig/pkix.rs
  • src/xmldsig/post_quantum.rs
  • src/xmldsig/pq_algorithm.rs
  • src/xmldsig/sign.rs
  • src/xmldsig/sign/dsa_import_tests.rs
  • src/xmldsig/sign/error_conversion_tests.rs
  • src/xmldsig/signature.rs
  • src/xmldsig/transforms.rs
  • src/xmldsig/transforms/parameters.rs
  • src/xmldsig/transforms/relationship.rs
  • src/xmldsig/transforms/source.rs
  • src/xmldsig/transforms/xslt.rs
  • src/xmldsig/transforms/xslt/tests.rs
  • src/xmldsig/trust.rs
  • src/xmldsig/types.rs
  • src/xmldsig/types/projection.rs
  • src/xmldsig/types/projection/tests.rs
  • src/xmldsig/uri.rs
  • src/xmldsig/verify.rs
  • src/xmldsig/verify/capture.rs
  • src/xmldsig/verify/session.rs
  • src/xmldsig/verify/session/hash_uses.rs
  • src/xmldsig/verify/session/hash_uses/tests.rs
  • src/xmldsig/verify/session/key_receipt.rs
  • src/xmldsig/verify/session/lookup.rs
  • src/xmldsig/verify/tests.rs
  • src/xmldsig/verify/xml_parse_budget_tests.rs
  • src/xmldsig/whitespace.rs
  • src/xmldsig/x509.rs
  • src/xmldsig/xpath.rs
  • src/xmldsig/xpath/storage.rs
  • src/xmlenc/agreement.rs
  • src/xmlenc/cipher_reference.rs
  • src/xmlenc/decrypt.rs
  • src/xmlenc/derived_key.rs
  • src/xmlenc/encrypt.rs
  • src/xmlenc/hkdf_agreement.rs
  • src/xmlenc/key_derivation.rs
  • src/xmlenc/key_derivation/serialize.rs
  • src/xmlenc/key_establishment_budget.rs
  • src/xmlenc/mod.rs
  • src/xmlenc/parse.rs
  • src/xmlenc/types.rs
  • tests/authenticated_reference_replay.rs
  • tests/aws_lc_provider.rs
  • tests/base64_transform_integration.rs
  • tests/behavioral_compatibility.rs
  • tests/capability_ledger.rs
  • tests/cipher_reference.rs
  • tests/cve_security.rs
  • tests/dh_agreement.rs
  • tests/donor_full_verification_suite.rs
  • tests/donor_interop_suite.rs
  • tests/donor_negative_vectors.rs
  • tests/ecdsa_signature_integration.rs
  • tests/historical_security.rs
  • tests/hmac_pipeline.rs
  • tests/key_establishment.rs
  • tests/merlin_interop.rs
  • tests/modern_algorithms.rs
  • tests/opc_relationship_transform.rs
  • tests/phaos_interop.rs
  • tests/pkcs11.rs
  • tests/policy_profiles.rs
  • tests/provider_key_association.rs
  • tests/reference_integration.rs
  • tests/rsa_encoding.rs
  • tests/rsa_pss.rs
  • tests/rsa_signature_integration.rs
  • tests/rust_api.rs
  • tests/saml_idp_integration.rs
  • tests/saml_signing_integration.rs
  • tests/secret_ownership.rs
  • tests/selected_key_receipts.rs
  • tests/session_lookups.rs
  • tests/signature_builder.rs
  • tests/signature_hash_uses.rs
  • tests/signature_pipeline_integration.rs
  • tests/signing_digest.rs
  • tests/spki_key_structure.rs
  • tests/transforms_integration.rs
  • tests/uri_integration.rs
  • tests/verification_evidence.rs
  • tests/x509_chain_integration.rs
  • tests/xml_integer_inspection.rs
  • tests/xml_qname_inspection.rs
  • tests/xml_scalar_inspection.rs
  • tests/xml_tree_navigation.rs
  • tests/xmlenc11_corpus.rs
  • tests/xmlenc_agreement.rs
  • tests/xmlenc_donor_integration.rs
  • tests/xmlenc_encrypt_integration.rs
  • tests/xmlenc_nested.rs
  • tests/xmlsec1_interop.rs
  • tests/xpath_donor_vectors.rs
  • tests/xpath_transform_integration.rs
  • tests/xslt_transform_integration.rs
  • tools/xmlsec1/Cargo.toml
  • tools/xmlsec1/src/commands.rs
  • tools/xmlsec1/src/key_material.rs
  • tools/xmlsec1/tests/ml_kem_keys.rs
  • vendor/sxd-document-no-unsafe/Cargo.toml

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T01:10:59.680631Z 5fdc458 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Clippy 1.92 rejects find(..).is_none() and asks for any(), while pedantic
clippy rejects the closure any() needs because Node::is_element takes a
reference. all() with a negated closure satisfies both toolchains with
identical semantics.

Part of #276
The PR smoke replays every retained corpus input under ASan before its
new mutations. With the unoptimized --dev build the replay ran at 1-60
executions per second and the evolving corpora outgrew the 35 minute
job budget. An optimized build with debug assertions keeps overflow
checks and debug_assert coverage; the security_roundtrip corpus (893
inputs) replays in 12 s instead of 271 s.

Part of #276
@polaz

polaz commented Oct 24, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4707d509de

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/xmldsig/signature.rs Resolved
Public-key adapters on the shared PKIX reader created a fresh
default-policy account per read. Inside a verification operation that
ignored the configured max_x509_work and workspace limits, left the work
out of aggregate usage, and reported exhaustion as a malformed key.

- VerifyingKey policy hooks receive a VerificationScope (operation
  policy plus its certificate account) instead of a bare policy;
  verify_with_policy also carries the SignatureContext
- built-in keys, resolver-bound keys and trusted keys read their SPKI
  under that account; exhaustion surfaces as a typed
  KeyPolicy(ResourceLimitExceeded) refusal
- InspectedKeyCandidateBudget::verification_scope lets resolvers that
  pre-check candidates use the same account
- SignatureVerificationInput is non_exhaustive with a new() constructor;
  the native provider reads SPKI under the operation account it carries
- issuer SPKI strength checks read under the chain session
- standalone entry points (bare provider calls, key import, direct
  helpers) read under an explicit standalone account
- the recipient RSA key and the software RSA verifier are built from the
  already admitted SPKI components instead of a second parse

Regression test: preset_verification_keys_charge_the_operation_certificate_account

BREAKING CHANGE: VerifyingKey::validate_policy,
validate_signature_value_with_policy and verify_with_policy take
&VerificationScope; verify_with_policy also takes &SignatureContext.
SignatureVerificationInput is non_exhaustive and built with new().
@polaz
polaz enabled auto-merge (squash) October 25, 2026 00:47
- dispatch public-key verification by algorithm family instead of
  enumerating every method, which kept the helper over the length limit
- declare the resource-limit imports before the early return
- bind the expected EC key info with let-else in the regression test
@polaz
polaz merged commit 91975cf into main Oct 25, 2026
30 checks passed
@polaz
polaz deleted the refactor/#276-security-pedantic branch October 25, 2026 01:37
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.

refactor: qualify security orchestration lint

1 participant