This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: webauthn-prf-client-key-derivation-standard-webauthn-prf-ext-192

WebAuthn PRF Extension Client-Side Master Key Derivation Standard

Enforces zero-knowledge client-side encryption key derivation via the WebAuthn PRF (Pseudo-Random Function) extension (RFC 8288 / FIDO2.1 / WebAuthn Level 3). Mandates that raw PRF outputs and intermediate keying material remain strictly local to client memory, undergo HKDF domain-separated expansion, and never traverse relying party networks or persist in non-ephemeral browser storage.

Prohibited Anti-Pattern: Leaking Raw WebAuthn PRF Output or Using Unseparated Ephemeral Secrets Directly as Encryption Keys

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: "WebAuthn PRF Extension Client-Side Master Key Derivation Standard - Enforces zero-knowledge client-side encryption key derivation via the WebAuthn PRF (Pseudo-Random Function) extension (RFC 8288 / FIDO2.1 / WebAuthn Level 3). Mandates that raw PRF outputs and intermediate keying material remain strictly local to client memory, undergo HKDF domain-separated expansion, and never traverse relying party networks or persist in non-ephemeral browser storage."
globs: "src/**/*.{ts,tsx}, lib/**/*.{ts,tsx}, packages/crypto/**/*.{ts,tsx}"
alwaysApply: true
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/webauthn-prf-client-key-derivation-standard-webauthn-prf-ext-192"
---

# WebAuthn PRF Extension Client-Side Master Key Derivation Standard

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Leaking Raw WebAuthn PRF Output or Using Unseparated Ephemeral Secrets Directly as Encryption Keys

## System Constraints
You are a Principal Security Architect enforcing the WebAuthn PRF Extension Client-Side Master Key Derivation Standard. You must ensure that all cryptographic keys derived from hardware-bound passkeys strictly observe zero-knowledge client invariants: hardware PRF evaluation inputs must use cryptographically secure domain-specific salts, PRF outputs must immediately be fed through HKDF (RFC 5869) with rigorous domain-separation labels, raw secret buffers must be wiped from volatile memory after use, and under no circumstances should raw PRF seed outputs or derived master keys ever be transmitted to an API, server, or saved to localStorage/IndexedDB.

## Strict Guidelines
- Engineers MUST ALWAYS verify client and authenticator support for the 'prf' extension via `publicKeyCredential.getClientExtensionResults().prf` before attempting zero-knowledge workflows.
- Engineers MUST NOT transmit raw PRF output buffers (`prfResult.results.first` or `prfResult.results.second`) to any remote relying party or network service.
- Engineers MUST run the raw PRF evaluation output through HKDF-SHA-256 (RFC 5869) using an explicit application and purpose domain-separation label (e.g., `info: new TextEncoder().encode('app-vault-v1:encryption-key')`) before utilizing it as a cryptographic key.
- Engineers MUST NOT use the raw 32-byte PRF output directly as a symmetric cipher key (e.g., direct import into AES-GCM without HKDF expansion).
- Code MUST sanitize and zero out intermediate secret ArrayBuffers / Uint8Arrays immediately after HKDF expansion completes.
- Storage layers NEVER persist derived master keys or raw PRF outputs in unencrypted Web Storage (`localStorage`, `sessionStorage`, or plaintext `IndexedDB`). Derived keys MUST exist only in memory within non-exportable `CryptoKey` handles or ephemeral scoped execution blocks.
- Code MUST supply a cryptographically secure, consistent 32-byte salt to `eval.first` derived from deterministic account metadata (or a stable public account salt) rather than arbitrary hardcoded strings.

## Bad vs Good Implementations
### Insecure: Transmitting PRF Output & Direct Raw Key Usage

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Violates zero-knowledge boundaries by sending raw PRF material to the server over HTTP, omits mandatory HKDF domain separation, and imports the key as exportable (`true`), allowing potential exfiltration.
```typescript
async function deriveVaultKeyInsecure(assertion: PublicKeyCredential) {
  const extensionResults = assertion.getClientExtensionResults();
  // ANTI-PATTERN: Direct access to untyped PRF output without presence check
  const rawPrf = extensionResults.prf?.results?.first;
  if (!rawPrf) throw new Error('PRF missing');

  // CRITICAL SECURITY FLAW: Sending PRF output to server for 'verification'
  await fetch('/api/verify-key-material', {
    method: 'POST',
    body: JSON.stringify({ prfOutput: Array.from(new Uint8Array(rawPrf)) })
  });

  // ANTI-PATTERN: Using raw PRF output directly as AES-GCM key without HKDF
  const rawKeyBytes = new Uint8Array(rawPrf);
  return await crypto.subtle.importKey(
    'raw',
    rawKeyBytes,
    { name: 'AES-GCM' },
    true,
    ['encrypt', 'decrypt']
  );
}
```

#### Production Standard (Correct)
> **Standard**: Complies with zero-knowledge architecture: PRF material stays strictly in client-side memory, is never transmitted across the network, is expanded via HKDF-SHA-256 with distinct domain-separation tags, produces non-exportable CryptoKey handles, and wipes the raw PRF buffer in a `finally` block.
```typescript
async function deriveVaultMasterKeySecure(
  assertion: PublicKeyCredential,
  accountPublicSalt: Uint8Array
): Promise<CryptoKey> {
  const extensionResults = assertion.getClientExtensionResults();
  const prfResult = extensionResults.prf;

  if (!prfResult?.results?.first) {
    throw new Error('WebAuthn PRF extension unavailable or evaluation failed on authenticator');
  }

  const rawPrfBuffer = new Uint8Array(prfResult.results.first);

  try {
    // Import raw PRF output as HKDF keying material (IKM)
    const initialKeyMaterial = await crypto.subtle.importKey(
      'raw',
      rawPrfBuffer,
      'HKDF',
      false, // Invariant: Never exportable
      ['deriveKey']
    );

    // Invariant: Derive distinct purpose-bound key with explicit domain separation
    const info = new TextEncoder().encode('zero-knowledge-vault:client-master-key:v1');
    const derivedKey = await crypto.subtle.deriveKey(
      {
        name: 'HKDF',
        hash: 'SHA-256',
        salt: accountPublicSalt,
        info
      },
      initialKeyMaterial,
      {
        name: 'AES-GCM',
        length: 256
      },
      false, // Invariant: Derived key handle cannot be exported from WebCrypto
      ['encrypt', 'decrypt']
    );

    return derivedKey;
  } finally {
    // Invariant: Wipe sensitive intermediate buffers from memory immediately
    rawPrfBuffer.fill(0);
  }
}
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: WebAuthn PRF Extension Client-Side Master Key Derivation Standard

WebAuthn PRF Extension Client-Side Master Key Derivation Standard defines an industrial-grade behavioral standard for security engineering. Enforces zero-knowledge client-side encryption key derivation via the WebAuthn PRF (Pseudo-Random Function) extension (RFC 8288 / FIDO2.1 / WebAuthn Level 3). Mandates that raw PRF outputs and intermediate keying material remain strictly local to client memory, undergo HKDF domain-separated expansion, and never traverse relying party networks or persist in non-ephemeral browser storage. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Leaking Raw WebAuthn PRF Output or Using Unseparated Ephemeral Secrets Directly as Encryption Keys Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

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 ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftLeaking Raw WebAuthn PRF Output or Using Unseparated Ephemeral Secrets Directly as Encryption KeysCritical
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 InconsistencyAI 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.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS verify client and authenticator support for the 'prf' extension via `publicKeyCredential.getClientExtensionResults().prf` before attempting zero-knowledge workflows.

Engineers MUST ALWAYS verify client and authenticator support for the 'prf' extension via `publicKeyCredential.getClientExtensionResults().prf` before attempting zero-knowledge workflows.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST NOT transmit raw PRF output buffers (`prfResult.results.first` or `prfResult.results.second`) to any remote relying party or network service.

Engineers MUST NOT transmit raw PRF output buffers (`prfResult.results.first` or `prfResult.results.second`) to any remote relying party or network service.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Engineers MUST run the raw PRF evaluation output through HKDF-SHA-256 (RFC 5869) using an explicit application and purpose domain-separation label (e.g., `info

Engineers MUST run the raw PRF evaluation output through HKDF-SHA-256 (RFC 5869) using an explicit application and purpose domain-separation label (e.g., `info: new TextEncoder().encode('app-vault-v1:encryption-key')`) before utilizing it as a cryptographic key.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Engineers MUST NOT use the raw 32-byte PRF output directly as a symmetric cipher key (e.g., direct import into AES-GCM without HKDF expansion).

Engineers MUST NOT use the raw 32-byte PRF output directly as a symmetric cipher key (e.g., direct import into AES-GCM without HKDF expansion).

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Code MUST sanitize and zero out intermediate secret ArrayBuffers / Uint8Arrays immediately after HKDF expansion completes.

Code MUST sanitize and zero out intermediate secret ArrayBuffers / Uint8Arrays immediately after HKDF expansion completes.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
6

Storage layers NEVER persist derived master keys or raw PRF outputs in unencrypted Web Storage (`localStorage`, `sessionStorage`, or plaintext `IndexedDB`). Derived keys MUST exist only in memory within non-exportable `CryptoKey` handles or ephemeral scoped execution blocks.

Storage layers NEVER persist derived master keys or raw PRF outputs in unencrypted Web Storage (`localStorage`, `sessionStorage`, or plaintext `IndexedDB`). Derived keys MUST exist only in memory within non-exportable `CryptoKey` handles or ephemeral scoped execution blocks.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
7

Code MUST supply a cryptographically secure, consistent 32-byte salt to `eval.first` derived from deterministic account metadata (or a stable public account salt) rather than arbitrary hardcoded strings.

Code MUST supply a cryptographically secure, consistent 32-byte salt to `eval.first` derived from deterministic account metadata (or a stable public account salt) rather than arbitrary hardcoded strings.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is WebAuthn PRF Extension Client-Side Master Key Derivation Standard critical for AI coding assistants?

Enforces zero-knowledge client-side encryption key derivation via the WebAuthn PRF (Pseudo-Random Function) extension (RFC 8288 / FIDO2.1 / WebAuthn Level 3). Mandates that raw PRF outputs and intermediate keying material remain strictly local to client memory, undergo HKDF domain-separated expansion, and never traverse relying party networks or persist in non-ephemeral browser 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 (Leaking Raw WebAuthn PRF Output or Using Unseparated Ephemeral Secrets Directly as Encryption Keys) 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.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

WebAuthn