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

WebAuthn PRF Extension Zero-Knowledge Key Derivation Standard

Enforces hardware-bound symmetric key derivation using the WebAuthn Pseudo-Random Function (PRF) extension directly within the browser context. Prohibits transiting raw PRF outputs, evaluation inputs, or derived master encryption keys across network boundaries, guaranteeing zero-knowledge client-side encryption. Mandates HKDF-SHA-256 contextual expansion and strict validation of authenticator PRF capabilities during registration and authentication assertions.

Prohibited Anti-Pattern: Transmitting Raw Passkey PRF Secrets to Servers or Deriving Symmetric Keys Without Salt Separation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: WebAuthn PRF Extension Zero-Knowledge Key Derivation Standard - Enforces hardware-bound symmetric key derivation using the WebAuthn Pseudo-Random Function (PRF) extension directly within the browser context. Prohibits transiting raw PRF outputs, evaluation inputs, or derived master encryption keys across network boundaries, guaranteeing zero-knowledge client-side encryption. Mandates HKDF-SHA-256 contextual expansion and strict validation of authenticator PRF capabilities during registration and authentication assertions.
globs: src/**/*.{ts,tsx}, lib/**/*.{ts,tsx}, packages/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/webauthn-prf-zero-knowledge-derivation-standard"
---

# WebAuthn PRF Extension Zero-Knowledge Key Derivation Standard

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Transmitting Raw Passkey PRF Secrets to Servers or Deriving Symmetric Keys Without Salt Separation

## System Constraints
You are a Principal Security Architect enforcing the WebAuthn PRF Extension Zero-Knowledge Derivation Standard. You must ensure that all client-side cryptographic key derivations via WebAuthn PRF extensions remain strictly zero-knowledge. Ensure raw PRF outputs never leave local volatile memory, all keys are derived using standard HKDF expansion with domain-specific info salts, and fallback paths handle unsupported authenticators gracefully without reducing security postures.

## Strict Guidelines
- Engineers MUST ALWAYS verify navigator.credentials PRF support via PublicKeyCredential.getClientCapabilities() or authenticator attachment extensions before initiating cryptographic transactions.
- Engineers MUST NOT transmit raw PRF output bytes (results.prf.results.first) to any remote API, database, or logging sink under any circumstance.
- Code MUST use Web Crypto API (SubtleCrypto) to ingest PRF outputs into CryptoKey primitives marked extractable: false for all subsequent symmetric operations.
- Services MUST enforce HKDF-SHA-256 derivation over the PRF seed using unique, context-specific info strings (e.g., 'org.app.vault.v1') and a 32-byte cryptographically secure salt.
- Components NEVER store PRF-derived encryption keys in persistent browser storage (localStorage, sessionStorage, or unencrypted IndexedDB); keys must reside solely in transient memory or secure non-exportable WebCrypto storage.

## Bad vs Good Implementations
### Hardware Key Derivation via WebAuthn PRF with HKDF Expansion

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Transmits the raw PRF evaluation bytes directly across the wire to the server, breaking zero-knowledge guarantees and exposing the master root of trust. It also uses a static, non-contextual derivation input string.
```typescript
export async function unlockUserVault(credentialId: string, serverChallenge: string) {
  const credential = await navigator.credentials.get({
    publicKey: {
      challenge: Uint8Array.from(atob(serverChallenge), c => c.charCodeAt(0)),
      allowCredentials: [{ id: Uint8Array.from(atob(credentialId), c => c.charCodeAt(0)), type: 'public-key' }],
      extensions: {
        prf: {
          eval: {
            first: new TextEncoder().encode('global-encryption-salt')
          }
        }
      }
    }
  }) as PublicKeyCredential;

  const extensionResults = credential.getClientExtensionResults();
  const rawPrfKey = extensionResults.prf?.results?.first;

  // CRITICAL ANTI-PATTERN: Sending raw PRF output to server for vault decryption
  await fetch('/api/vault/decrypt', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      credentialId,
      secret: Array.from(new Uint8Array(rawPrfKey as ArrayBuffer))
    })
  });
}
```

#### Production Standard (Correct)
> **Standard**: Safely captures the PRF output in client volatile memory, executes HKDF expansion with a 32-byte salt and domain separation info string, and returns an unextractable AES-GCM CryptoKey without server leakage.
```typescript
export async function unlockUserVault(
  credentialId: Uint8Array,
  challenge: Uint8Array,
  appSalt: Uint8Array
): Promise<CryptoKey> {
  const credential = await navigator.credentials.get({
    publicKey: {
      challenge,
      allowCredentials: [{ id: credentialId, type: 'public-key' }],
      extensions: {
        prf: {
          eval: {
            first: appSalt // Cryptographically random, persistent 32-byte client-known salt
          }
        }
      }
    }
  }) as PublicKeyCredential;

  const extResults = credential.getClientExtensionResults();
  const prfResult = extResults.prf?.results?.first;

  if (!prfResult) {
    throw new Error('Authenticator did not return PRF output or PRF not supported.');
  }

  // Import raw PRF output strictly into WebCrypto HKDF wrapper
  const rawPrfKey = await window.crypto.subtle.importKey(
    'raw',
    prfResult,
    { name: 'HKDF' },
    false,
    ['deriveKey']
  );

  // Derive AES-GCM 256-bit encryption key with strict contextual separation
  return await window.crypto.subtle.deriveKey(
    {
      name: 'HKDF',
      hash: 'SHA-256',
      salt: appSalt,
      info: new TextEncoder().encode('org.secure.vault.aes-gcm.v1')
    },
    rawPrfKey,
    { name: 'AES-GCM', length: 256 },
    false,
    ['encrypt', 'decrypt']
  );
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: WebAuthn PRF Extension Zero-Knowledge Key Derivation Standard

WebAuthn PRF Extension Zero-Knowledge Key Derivation Standard defines an industrial-grade behavioral standard for security engineering. Enforces hardware-bound symmetric key derivation using the WebAuthn Pseudo-Random Function (PRF) extension directly within the browser context. Prohibits transiting raw PRF outputs, evaluation inputs, or derived master encryption keys across network boundaries, guaranteeing zero-knowledge client-side encryption. Mandates HKDF-SHA-256 contextual expansion and strict validation of authenticator PRF capabilities during registration and authentication assertions. 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: Transmitting Raw Passkey PRF Secrets to Servers or Deriving Symmetric Keys Without Salt Separation 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 DriftTransmitting Raw Passkey PRF Secrets to Servers or Deriving Symmetric Keys Without Salt SeparationCritical
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 navigator.credentials PRF support via PublicKeyCredential.getClientCapabilities() or authenticator attachment extensions before initiating cryptographic transactions.

Engineers MUST ALWAYS verify navigator.credentials PRF support via PublicKeyCredential.getClientCapabilities() or authenticator attachment extensions before initiating cryptographic transactions.

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 bytes (results.prf.results.first) to any remote API, database, or logging sink under any circumstance.

Engineers MUST NOT transmit raw PRF output bytes (results.prf.results.first) to any remote API, database, or logging sink under any circumstance.

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

Code MUST use Web Crypto API (SubtleCrypto) to ingest PRF outputs into CryptoKey primitives marked extractable

Code MUST use Web Crypto API (SubtleCrypto) to ingest PRF outputs into CryptoKey primitives marked extractable: false for all subsequent symmetric operations.

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

Services MUST enforce HKDF-SHA-256 derivation over the PRF seed using unique, context-specific info strings (e.g., 'org.app.vault.v1') and a 32-byte cryptographically secure salt.

Services MUST enforce HKDF-SHA-256 derivation over the PRF seed using unique, context-specific info strings (e.g., 'org.app.vault.v1') and a 32-byte cryptographically secure salt.

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

Components NEVER store PRF-derived encryption keys in persistent browser storage (localStorage, sessionStorage, or unencrypted IndexedDB)

Components NEVER store PRF-derived encryption keys in persistent browser storage (localStorage, sessionStorage, or unencrypted IndexedDB); keys must reside solely in transient memory or secure non-exportable WebCrypto storage.

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 Zero-Knowledge Key Derivation Standard critical for AI coding assistants?

Enforces hardware-bound symmetric key derivation using the WebAuthn Pseudo-Random Function (PRF) extension directly within the browser context. Prohibits transiting raw PRF outputs, evaluation inputs, or derived master encryption keys across network boundaries, guaranteeing zero-knowledge client-side encryption. Mandates HKDF-SHA-256 contextual expansion and strict validation of authenticator PRF capabilities during registration and authentication assertions. 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 (Transmitting Raw Passkey PRF Secrets to Servers or Deriving Symmetric Keys Without Salt Separation) 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