Architectural Invariant Design: Mandate HKDF Domain Separation and Zero-Knowledge Invariants for WebAuthn PRF Key Derivation
Mandate HKDF Domain Separation and Zero-Knowledge Invariants for WebAuthn PRF Key Derivation defines an industrial-grade behavioral standard for security engineering. WebAuthn PRF (Pseudo-Random Function) extension derives deterministic symmetric key material directly inside hardware authenticators for client-side encryption. Applications must strictly mandate HKDF-SHA-256 expansion with domain separation on the PRF output, verify authenticator extension support before cryptographic operations, and never allow the raw authenticator output to be utilized directly as a cipher key or transmitted to servers. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.
Hazard Analysis: What Breaks Without This Rule
The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:
| Failure Mode | AI Symptom (The Anti-Pattern) | Severity | Production Impact & Remedy |
|---|---|---|---|
| AI Hallucination & Deprecation Drift | Direct Cipher Instantiation with Raw PRF Output Lacking HKDF Domain Separation and Secure Buffer Zeroization | Critical | Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production. Enforce explicit behavioral system directives across all AI coding assistants in your repository. |
| Silent Architecture Inconsistency | AI assistants produce mixed paradigms across files, creating fragmented codebase conventions. | Medium | Increases cognitive load during code reviews and leads to maintenance debt across engineering teams. Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails. |
Step-by-Step Production Directives
Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:
Engineers MUST ALWAYS run authenticator PRF output through HKDF-SHA-256 with distinct domain-separation `info` and `salt` parameters before instantiating AES-256-GCM or ChaCha20-Poly1305 ciphers.
Engineers MUST ALWAYS run authenticator PRF output through HKDF-SHA-256 with distinct domain-separation `info` and `salt` parameters before instantiating AES-256-GCM or ChaCha20-Poly1305 ciphers.
Engineers MUST NOT use raw PRF output (`results.prf.first` or `results.prf.second`) directly as an encryption or MAC key.
Engineers MUST NOT use raw PRF output (`results.prf.first` or `results.prf.second`) directly as an encryption or MAC key.
Engineers MUST ALWAYS verify that `assertion.getClientExtensionResults().prf?.results` exists and contains non-null derivation output before proceeding with decryption workflows.
Engineers MUST ALWAYS verify that `assertion.getClientExtensionResults().prf?.results` exists and contains non-null derivation output before proceeding with decryption workflows.
Engineers MUST explicitly handle authenticators lacking PRF capabilities without falling back to insecure, hardcoded, or server-derived keys without explicit authorization and user consent.
Engineers MUST explicitly handle authenticators lacking PRF capabilities without falling back to insecure, hardcoded, or server-derived keys without explicit authorization and user consent.
Code MUST zero out raw PRF output arrays (`Uint8Array.fill(0)`) immediately after importing the keying material into `SubtleCrypto`.
Code MUST zero out raw PRF output arrays (`Uint8Array.fill(0)`) immediately after importing the keying material into `SubtleCrypto`.
Services MUST NEVER transmit raw PRF inputs, salt seeds, or derived encryption keys to the server
Services MUST NEVER transmit raw PRF inputs, salt seeds, or derived encryption keys to the server; only encrypted ciphertext, IVs, and public cryptographic parameters may traverse the boundary.
Frequently Asked Technical Questions
Common questions developers face when configuring AI coding assistants for this stack:
Q:Why is Mandate HKDF Domain Separation and Zero-Knowledge Invariants for WebAuthn PRF Key Derivation critical for AI coding assistants?
WebAuthn PRF (Pseudo-Random Function) extension derives deterministic symmetric key material directly inside hardware authenticators for client-side encryption. Applications must strictly mandate HKDF-SHA-256 expansion with domain separation on the PRF output, verify authenticator extension support before cryptographic operations, and never allow the raw authenticator output to be utilized directly as a cipher key or transmitted to servers. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.
Q:How does adopting this rule prevent AI hallucinations?
This rule explicitly declares what the AI must avoid (Direct Cipher Instantiation with Raw PRF Output Lacking HKDF Domain Separation and Secure Buffer Zeroization) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.
Q:Which AI coding environments are supported?
This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).
Q:Can I combine this rule with other technology stacks?
Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.