Architectural Invariant Design: WebAuthn PRF Extension Zero-Knowledge Envelope Encryption Standard
WebAuthn PRF Extension Zero-Knowledge Envelope Encryption Standard defines an industrial-grade behavioral standard for security engineering. Mandates that client-side zero-knowledge encryption powered by the WebAuthn PRF extension derives cryptographic keys strictly in-memory using HKDF with domain separation. Prohibits transmission of raw PRF outputs or derived Key Encryption Keys (KEKs) to remote servers and requires strict envelope encryption via ephemeral Data Encryption Keys (DEKs). 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 Encryption with Raw PRF Secret Outputs or Exposing Derived Keys to Server APIs | 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 verify that `results.getClientExtensionResults().prf` is populated before proceeding with key derivation, falling back to secure failure or re-authentication if the hardware authenticator does not support PRF.
Engineers MUST ALWAYS verify that `results.getClientExtensionResults().prf` is populated before proceeding with key derivation, falling back to secure failure or re-authentication if the hardware authenticator does not support PRF.
Engineers MUST NOT transmit raw PRF outputs (`first`, `second`), derived Key Encryption Keys (KEKs), or ephemeral Data Encryption Keys (DEKs) in plaintext to any server or intermediary.
Engineers MUST NOT transmit raw PRF outputs (`first`, `second`), derived Key Encryption Keys (KEKs), or ephemeral Data Encryption Keys (DEKs) in plaintext to any server or intermediary.
Engineers MUST ALWAYS expand the raw PRF output via `crypto.subtle.deriveKey` or `crypto.subtle.deriveBits` using HKDF-SHA-256 with an explicit, immutable `info` parameter for domain separation (e.g., `enc
Engineers MUST ALWAYS expand the raw PRF output via `crypto.subtle.deriveKey` or `crypto.subtle.deriveBits` using HKDF-SHA-256 with an explicit, immutable `info` parameter for domain separation (e.g., `enc:zk-vault:v1`).
Code MUST implement Envelope Encryption by generating a cryptographically secure random 256-bit ephemeral Data Encryption Key (DEK) via `crypto.getRandomValues()`, encrypting the payload with AES-256-GCM, and wrapping the DEK with the PRF-derived KEK via AES-KW (AES Key Wrap) or AES-256-GCM.
Code MUST implement Envelope Encryption by generating a cryptographically secure random 256-bit ephemeral Data Encryption Key (DEK) via `crypto.getRandomValues()`, encrypting the payload with AES-256-GCM, and wrapping the DEK with the PRF-derived KEK via AES-KW (AES Key Wrap) or AES-256-GCM.
Components NEVER use the raw PRF evaluation result directly as a symmetric cipher key for bulk data encryption.
Components NEVER use the raw PRF evaluation result directly as a symmetric cipher key for bulk data encryption.
Code MUST generate a fresh, unique 96-bit Initialization Vector (IV) from `crypto.getRandomValues(new Uint8Array(12))` for every AES-GCM operation
Code MUST generate a fresh, unique 96-bit Initialization Vector (IV) from `crypto.getRandomValues(new Uint8Array(12))` for every AES-GCM operation; IV reuse is strictly prohibited.
Services MUST only accept and persist the encrypted envelope containing the ciphertext, the wrapped DEK, the IV, and the public authenticator credential ID and salt.
Services MUST only accept and persist the encrypted envelope containing the ciphertext, the wrapped DEK, the IV, and the public authenticator credential ID and salt.
Frequently Asked Technical Questions
Common questions developers face when configuring AI coding assistants for this stack:
Q:Why is WebAuthn PRF Extension Zero-Knowledge Envelope Encryption Standard critical for AI coding assistants?
Mandates that client-side zero-knowledge encryption powered by the WebAuthn PRF extension derives cryptographic keys strictly in-memory using HKDF with domain separation. Prohibits transmission of raw PRF outputs or derived Key Encryption Keys (KEKs) to remote servers and requires strict envelope encryption via ephemeral Data Encryption Keys (DEKs). 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 Encryption with Raw PRF Secret Outputs or Exposing Derived Keys to Server APIs) 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.