Architectural Invariant Design: WebAuthn Level 3 PRF Zero-Knowledge Key Derivation and Lifecycle Invariant
WebAuthn Level 3 PRF Zero-Knowledge Key Derivation and Lifecycle Invariant defines an industrial-grade behavioral standard for security engineering. Enforces deterministic, zero-knowledge symmetric key derivation using the WebAuthn Level 3 PRF (Pseudo-Random Function) extension. Derived raw secret material MUST be processed via HKDF with domain-separated contexts, marked non-extractable, zeroized in volatile memory, and NEVER transmitted across network boundaries or stored in persistent client-side storage. 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 | Persisting raw PRF outputs or treating PRF output as directly usable symmetric keys without HKDF expansion and extractability guards | 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 feed raw PRF output (`results.prf.results.first`) into WebCrypto HKDF (HMAC-based Extract-and-Expand Key Derivation Function) using SHA-256 and an explicit, domain-separated `info` parameter before using it for encryption.
Engineers MUST ALWAYS feed raw PRF output (`results.prf.results.first`) into WebCrypto HKDF (HMAC-based Extract-and-Expand Key Derivation Function) using SHA-256 and an explicit, domain-separated `info` parameter before using it for encryption.
Engineers MUST ALWAYS enforce `extractable
Engineers MUST ALWAYS enforce `extractable: false` when importing or deriving symmetric operational keys (e.g., AES-GCM) via `crypto.subtle.deriveKey`.
Engineers MUST ALWAYS explicitly zeroize ephemeral Uint8Array buffers containing raw PRF entropy immediately after deriving the operational key using `buffer.fill(0)`.
Engineers MUST ALWAYS explicitly zeroize ephemeral Uint8Array buffers containing raw PRF entropy immediately after deriving the operational key using `buffer.fill(0)`.
Engineers MUST NOT persist raw PRF output, intermediate HKDF entropy, or derived symmetric keys in `localStorage`, `sessionStorage`, `IndexedDB`, or cookies under any circumstances.
Engineers MUST NOT persist raw PRF output, intermediate HKDF entropy, or derived symmetric keys in `localStorage`, `sessionStorage`, `IndexedDB`, or cookies under any circumstances.
Engineers MUST NOT transmit raw PRF output or derived master encryption keys over the network or expose them to backend verification endpoints.
Engineers MUST NOT transmit raw PRF output or derived master encryption keys over the network or expose them to backend verification endpoints.
Code SHOULD verify hardware authenticator PRF support via `clientExtensionResults.prf?.enabled` or check for existence of `results.first` before attempting derivation, providing explicit recovery workflows if PRF is unsupported.
Code SHOULD verify hardware authenticator PRF support via `clientExtensionResults.prf?.enabled` or check for existence of `results.first` before attempting derivation, providing explicit recovery workflows if PRF is unsupported.
Code MUST require salt inputs for PRF evaluation to be exactly 32 bytes generated via `crypto.getRandomValues(new Uint8Array(32))` and stored publicly alongside encrypted payloads.
Code MUST require salt inputs for PRF evaluation to be exactly 32 bytes generated via `crypto.getRandomValues(new Uint8Array(32))` and stored publicly alongside encrypted payloads.
Components NEVER store or expose non-extractable `CryptoKey` references on global window scopes or debug consoles.
Components NEVER store or expose non-extractable `CryptoKey` references on global window scopes or debug consoles.
Frequently Asked Technical Questions
Common questions developers face when configuring AI coding assistants for this stack:
Q:Why is WebAuthn Level 3 PRF Zero-Knowledge Key Derivation and Lifecycle Invariant critical for AI coding assistants?
Enforces deterministic, zero-knowledge symmetric key derivation using the WebAuthn Level 3 PRF (Pseudo-Random Function) extension. Derived raw secret material MUST be processed via HKDF with domain-separated contexts, marked non-extractable, zeroized in volatile memory, and NEVER transmitted across network boundaries or stored in persistent client-side storage. 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 (Persisting raw PRF outputs or treating PRF output as directly usable symmetric keys without HKDF expansion and extractability guards) 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.