Skip to content

Commit c69d9fb

Browse files
committed
docs(pqc): concise implementation/testing focus; prohibit draft Kyber; add ML-KEM-512 constrained-use guidance; regenerate skills
1 parent eace1ed commit c69d9fb

2 files changed

Lines changed: 58 additions & 170 deletions

File tree

skills/software-security/rules/codeguard-1-post-quantum-cryptography.md

Lines changed: 29 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -7,92 +7,36 @@ rule_id: codeguard-1-post-quantum-cryptography
77

88
# Post-Quantum Cryptography (PQC)
99

10-
Post-quantum cryptography protects long-lived secrets and future-proof communications against adversaries with quantum capabilities. Adopt PQC via supported libraries and protocols, favoring algorithm agility and incremental, interoperable rollout.
11-
12-
## Goals
13-
- Prefer standardized primitives and vendor-supported APIs; never implement custom crypto.
14-
- Maintain algorithm agility (configurable algorithms, decoupled from business logic).
15-
- Use hybrid key establishment during transition to preserve interoperability and defense-in-depth.
16-
- Validate interoperability and performance before broad rollout.
17-
18-
## Algorithm Selection (Key Establishment and Signatures)
19-
- Key establishment (KEM): Use NIST-standardized ML-KEM (FIPS 203). Select parameter sets per risk and performance.
20-
- Digital signatures: Use standardized ML-DSA (FIPS 204) where supported. Consider SLH-DSA (FIPS 205) where required by policy; account for larger signatures.
21-
- Continue to rely on vendor-provided, audited implementations. Do not hardcode experimental group names or OIDs; use library-provided options.
22-
23-
## ML-KEM Parameter Set Selection and Packet Size Considerations
24-
- Minimum baseline: ML-KEM-768 should be the minimum consideration for general-purpose and multi-tenant deployments. Avoid ML-KEM-512 for broad use; only consider in highly constrained environments after explicit risk acceptance and compensating controls.
25-
- High-assurance option: ML-KEM-1024 for regulated or high-assurance segments where added overhead is acceptable; validate capacity and latency budgets.
26-
- Packet/message size impacts:
27-
- ML-KEM public keys and ciphertexts increase handshake sizes; expect larger ClientHello/ServerHello and key exchange messages.
28-
- Plan for path MTU and fragmentation: tune TLS record sizing as supported; validate middlebox tolerance to larger handshakes; monitor for handshake failures/timeouts.
29-
- Assess QUIC vs TCP/TLS behavior in your environment; verify congestion and packetization with your vendor’s stack.
30-
- Measure peak and P95 handshake size and latency before/after enabling hybrids; adjust proxy/load balancer limits as needed (e.g., header/body/initial settings).
31-
- Operational guidance:
32-
- Prefer vendor-documented hybrid groups or ciphersuites that include ML-KEM-768; avoid experimental or draft identifiers.
33-
- Document fallback behavior and client capability detection; surface algorithm choices in configuration, not code.
34-
- Ensure telemetry captures negotiated groups and retry causes to support safe rollouts and rollbacks.
35-
36-
## Recommendation for Multi-Tenant Ecosystems
37-
- Use a hybrid key establishment that combines a classical ECDHE group with ML-KEM-768.
38-
- Rationale: ML-KEM-768 provides a widely recommended balance of security and performance suitable for shared, multi-tenant environments where diverse client capabilities and high request volume demand efficient handshakes.
39-
- Implementation guidance:
40-
- Enable the library’s supported hybrid mode pairing ML-KEM-768 with a classical group such as X25519 or secp256r1, as documented by the vendor.
41-
- For example, use X25519 + ML-KEM-768 as the default hybrid pairing; use secp256r1 + ML-KEM-768 when X25519 is unavailable due to policy or platform constraints.
42-
- Avoid bespoke or ad-hoc hybrids. Do not assemble hybrid handshakes manually; use stable, supported configuration flags or cipher/group selections provided by the stack.
43-
44-
## Deprecations and Disallowed Predecessors
45-
- Discontinue pre-standard, draft, or experiment-only Kyber-based hybrid groups and ciphers (often labeled generically as “Hybrid-Kyber” or with draft names like X25519Kyber…/P256_Kyber/CECPQ2). These predecessors must be replaced with a hybrid ML-KEM alternative provided by the vendor.
46-
- Do not introduce new dependencies on legacy Kyber draft identifiers or OIDs. Migrate configuration and policy to ML-KEM-based hybrids in accordance with FIPS 203 and vendor guidance.
47-
48-
## Protocol Guidance (e.g., TLS, SSH, HPKE)
49-
- Prefer TLS 1.3 where hybrid KEMs are supported by your stack. New solutions should mandate using TLS 1.3 only and avoid TLS 1.2 and earlier versions where possible.
50-
- Use vendor-documented hybrid groups that include ML-KEM-768 during transition. Avoid TLS 1.2 and earlier versions where possible.
51-
- Only enable pure-PQC key establishment when interoperability with required clients is verified. Otherwise, deploy hybrid modes to preserve compatibility while adding PQC assurances.
52-
- For signatures, adopt ML-DSA when supported by the protocol and vendor stack; validate message sizes, handshake overhead, and client support.
53-
54-
## Key Management and Operations
55-
- Generate keys via FIPS-validated or vendor-audited modules (KMS/HSM where available). Use a CSPRNG suitable for the platform.
56-
- Maintain separate keys by purpose (encryption, signatures). Rotate per policy, compromise, or cryptoperiod changes.
57-
- Store keys in KMS/HSM or secure vaults. Never hardcode keys or parameters; avoid plain environment variables for long-lived secrets. Prefer HW-based key protections over Software-only solutions.
58-
- Ensure algorithm identifiers, parameters, and certificates reflect ML-KEM/ML-DSA selections from supported libraries; avoid stale Kyber-era identifiers.
59-
- TPM-backed keys typically do not support ML-DSA today; for mTLS client/server authentication, continue to use EC algorithms supported by your TPM (e.g., ECDSA with secp256r1) until suitable ML-DSA TPM implementations are available in hardware.
60-
- You can deploy hybrid ML-KEM key establishment while continuing to authenticate with ECDSA mTLS certificates; plan migration to ML-DSA-signed certificates when vendor hardware and ecosystem support becomes available.
61-
62-
## Authenticators and Credentials
63-
- FIDO2/WebAuthn: Platform and roaming authenticators today primarily use ECC (e.g., ECDSA/EdDSA). PQC attestation is not broadly deployed; continue using supported authenticators and track vendor roadmaps for PQC or hybrid attestation.
64-
- TPM-backed mTLS: Current TPMs typically do not support ML-DSA. For client/server mTLS certificates, continue to use ECDSA (e.g., secp256r1) until suitable ML-DSA TPM implementations are available in hardware.
65-
- Tokens and credentials: Hybrid ML-KEM key establishment protects transport but does not change token formats. Keep token signing on widely supported algorithms today and design for algorithm agility to adopt ML-DSA when ecosystems support it.
66-
- Policy and configurability: Surface algorithm choices in configuration/policy (not code), define safe defaults and explicit fallback behavior, and capture telemetry for negotiated groups and failures.
67-
68-
## Digital Signatures and Code/Artifact Signing
69-
- Current practice: Use vetted, widely supported signatures (e.g., ECDSA P-256 or Ed25519) for code, container, and SBOM signing while PQC HSM/TPM support is nascent.
70-
- Migration path: Plan for algorithm agility and adopt ML-DSA (FIPS 204) when your toolchain, HSMs/TPMs, and verifiers support it. Expect larger signatures and potential format/verification updates.
71-
- Avoid drafts: Do not adopt draft/proprietary PQC signatures. Prefer standardized ML-DSA when available from audited libraries and hardware.
72-
- Operational checks: Verify verifier support across CI/CD, registries, update servers, and clients; measure artifact size impact; ensure revocation and audit logs remain effective.
73-
74-
## Adoptable Today (Open Source Projects)
75-
- TLS 1.3 hybrid KEM with ML-KEM-768 is available using OpenSSL 3 with the oqs-provider (Open Quantum Safe) or OQS-OpenSSL builds. Use in controlled environments where you manage both client and server. Keep classical fallback enabled; note these builds are not yet FIPS-validated.
76-
- SSH: OpenSSH supports a hybrid key exchange (sntrup761x25519). While not ML-KEM, it provides a PQC KEX option. Adopt per your policy until ML-KEM hybrids are supported in your SSH stack.
77-
- HPKE and libraries: Open Quantum Safe libraries (liboqs) can be used to develop ML-KEM-based HPKE and related constructs.
78-
- FIDO/WebAuthn (production today): Continue to use platform/hardware authenticators with classical algorithms (COSE ES256/ECDSA P-256; allow EdDSA where supported). Keep accepted COSE algorithms configurable on the RP/server, log negotiated algorithms, and maintain attestation/trust metadata. PQC authenticators/attestations are not broadly available today; track standards and vendor roadmaps.
79-
80-
## Migration Plan
81-
- Inventory cryptography usage and endpoints. Identify where key establishment and signature algorithms are configured or negotiated.
82-
- Prioritize externally facing, high-value, and long-lived data flows for hybrid deployment first.
83-
- Roll out hybrid ML-KEM-768 in stages with monitoring, fallbacks, and explicit client compat testing.
84-
- Decommission predecessor “Hybrid-Kyber” configurations and remove any policy allowances or feature flags that enable them.
10+
Concise Code Guard focused on what to implement and how to test it.
11+
12+
## Implementation (Do this)
13+
- Enforce TLS 1.3 only (or later when available).
14+
- Use vendor‑supported crypto APIs only; never implement custom crypto. Do not hand‑roll hybrids or hardcode experimental group names/OIDs.
15+
- Hybrid KEM: enable vendor‑documented hybrids that include ML‑KEM‑768 with a classical ECDHE group (X25519 or secp256r1). Use ML‑KEM‑1024 for high‑assurance segments after validating overhead.
16+
- Multi-tenant systems that share crypto resources across tenants should select Hybrid KEM with ML‑KEM‑768 + ECDHE; ML‑KEM‑1024 where required. X25519 is recommended for ECDHE.
17+
- Avoid predecessors: remove legacy/draft “Hybrid‑Kyber” groups (e.g., CECPQ2; X25519Kyber…, P256_Kyber) and draft OIDs.
18+
- Configuration, not code: expose algorithm choices in config/policy; document fallback behavior; keep a classical‑only fallback for incompatible clients if you don't control both client and server.
19+
- Key management: use KMS/HSM; generate keys with a CSPRNG; separate encryption vs signatures; rotate per policy; never hardcode keys/parameters; avoid plain env vars for long‑lived secrets.
20+
- Certificates/signatures: continue ECDSA (P‑256) for mTLS and code signing until ML‑DSA is supported by your stack; plan migration to ML‑DSA.
21+
- Telemetry and limits: capture negotiated groups, handshake sizes, and retry/failure causes. Tune TLS record sizes and proxy/LB limits to avoid fragmentation and timeouts.
22+
- SSH/HPKE: enable only vendor‑supported PQC/hybrid KEX (e.g., sntrup761x25519 in OpenSSH if allowed). For HPKE, rely on native language runtime/vendor/audited libraries that support ML‑KEM.
23+
24+
## Migration
25+
- Inventory endpoints and crypto usage.
26+
- Prioritize external/high‑value/long‑lived flows.
27+
- Roll out hybrids in stages with metrics and rollback; remove predecessor configs after success criteria are met.
8528

8629
## Implementation Checklist
87-
- Hybrid key establishment enabled with ML-KEM-768 alongside a classical ECDHE group.
88-
- No usage of predecessor draft Kyber hybrids; configurations updated to ML-KEM hybrids.
89-
- Algorithms are configurable (algorithm agility) and surfaced in policy/config, not compiled into business logic.
90-
- Keys generated with a CSPRNG in validated modules; stored in KMS/HSM; separated by purpose; rotation documented.
91-
- Protocol versions and cipher/group selections align with vendor-documented, supported PQC options.
92-
- Monitoring in place for handshake success rates, latency, and error codes after enabling hybrids.
30+
- Hybrid key establishment with ML‑KEM‑768 + ECDHE; ML‑KEM‑1024 where required.
31+
- Avoid ML‑KEM‑512 except in explicitly risk‑accepted, highly constrained device or network environments, with compensating controls and tight scope.
32+
- No draft Kyber groups; only vendor‑documented ML‑KEM hybrids.
33+
- Algorithm agility via configuration (not code); explicit fallback behavior.
34+
- Keys via validated modules; separated by purpose; rotation policy in place.
35+
- TLS version and group selections align with supported PQC options.
36+
- Monitoring in place for handshake success/latency/errors and negotiated groups.
9337

9438
## Test Plan
95-
- Interoperability tests across representative clients/agents for hybrid ML-KEM-768 handshakes; verify negotiation and fallback behavior.
96-
- Negative tests: reject configurations attempting legacy Hybrid-Kyber or draft-only group names.
97-
- Performance/regression tests: measure handshake latency and server CPU for peak and P95 after enabling hybrids.
98-
- Configuration validation: confirm algorithm identifiers and parameters map to ML-KEM/ML-DSA in logs and diagnostics; ensure no stale Kyber draft identifiers remain.
39+
- Interoperability: verify hybrid MLKEM768 and ML‑KEM‑1024 handshakes across representative clients; validate negotiated groups and fallback paths.
40+
- Negative: reject legacy/draft HybridKyber identifiers and misconfigured groups.
41+
- Performance: measure handshake size and latency (peak and P95) and server CPU after enabling hybrids; tune record sizes and limits as needed.
42+
- Configuration validation: confirm groups/algorithm identifiers in logs and diagnostics; ensure no stale Kyber‑era identifiers remain.

0 commit comments

Comments
 (0)