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

Hardware-Backed WebAuthn PRF Zero-Knowledge Key Derivation Standard

Enforces deterministic, client-side symmetric key derivation strictly via the WebAuthn Level 3 PRF (Pseudo-Random Function) extension for zero-knowledge end-to-end encryption. Prohibits insecure software fallbacks, client-side disk persistence of derived root secrets, and transmission of hardware-derived entropy to remote servers.

Prohibited Anti-Pattern: Persisting PRF Entropy or Deriving Zero-Knowledge Keys via Fallback Client-Side Hashes

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Hardware-Backed WebAuthn PRF Zero-Knowledge Key Derivation Standard - Enforces deterministic, client-side symmetric key derivation strictly via the WebAuthn Level 3 PRF (Pseudo-Random Function) extension for zero-knowledge end-to-end encryption. Prohibits insecure software fallbacks, client-side disk persistence of derived root secrets, and transmission of hardware-derived entropy to remote servers.
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-zk-salt-derivation-standard"
---

# Hardware-Backed WebAuthn PRF Zero-Knowledge Key Derivation Standard

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Persisting PRF Entropy or Deriving Zero-Knowledge Keys via Fallback Client-Side Hashes

## System Constraints
You are a Principal Security Architect enforcing the WebAuthn PRF (Pseudo-Random Function) Zero-Knowledge Salt Derivation Standard. You must mandate that all client-side symmetric encryption keys for zero-knowledge data at rest are derived exclusively from hardware-backed WebAuthn PRF extension outputs. Never allow fallback to user passwords, Web Crypto PBKDF2 without PRF hardware backing, or transmitting derived PRF outputs to server endpoints.

## Strict Guidelines
- Engineers MUST ALWAYS verify that the authenticator supports the `prf` extension during registration by requesting `{ extensions: { prf: {} } }` and inspecting `clientExtensionResults.prf.supported`.
- Engineers MUST ALWAYS supply a cryptographically secure, deterministic application salt (minimum 32 bytes) to `navigator.credentials.get()` inside `extensions.prf.eval.first`.
- Engineers MUST derive symmetric encryption keys (e.g., AES-256-GCM) from the raw PRF output using HKDF (RFC 5869) via `SubtleCrypto.deriveKey()` with an explicit application domain-separation context string.
- Engineers MUST NOT persist the raw PRF output or derived root encryption keys in `localStorage`, `sessionStorage`, `IndexedDB`, or cookies under any circumstances.
- Engineers MUST NOT transmit raw PRF output or derived symmetric key material over the network or include it in WebAuthn assertion verification payloads sent to the backend.
- Components NEVER fall back to password-based derivation (e.g., PBKDF2 over raw master passwords) when the WebAuthn PRF extension fails; the operation MUST fail closed.
- Services MUST overwrite and zeroize intermediate PRF output buffers immediately after importing them into non-extractable Web Crypto CryptoKey objects.

## Bad vs Good Implementations
### WebAuthn PRF Zero-Knowledge Key Derivation and Zeroization

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Fails to request or evaluate the WebAuthn PRF extension, generates a soft random seed in software, leaks the key material to localStorage and an API endpoint, and falls back to insecure derivation, completely breaking zero-knowledge guarantees.
```typescript
import { api } from './api';

export async function getEncryptionKey(credentialId: Uint8Array): Promise<CryptoKey> {
  // Anti-pattern: Missing PRF extension, fallback to PBKDF2 on password, or leaking secret to API
  const assertion = await navigator.credentials.get({
    publicKey: {
      challenge: new Uint8Array(32),
      allowCredentials: [{ id: credentialId, type: 'public-key' }]
    }
  }) as PublicKeyCredential;

  // Storing or sending derived seeds to backend violates zero-knowledge guarantees
  const seed = crypto.randomUUID();
  localStorage.setItem('zk_vault_key', seed);
  await api.post('/store-salt', { seed });

  const enc = new TextEncoder();
  return crypto.subtle.importKey(
    'raw',
    enc.encode(seed),
    { name: 'PBKDF2' },
    false,
    ['deriveKey']
  );
}
```

#### Production Standard (Correct)
> **Standard**: Correctly invokes WebAuthn PRF extension with a deterministic domain salt, handles missing PRF extension by failing closed, imports hardware entropy directly into non-extractable Web Crypto handles, and securely zeroizes raw PRF buffers from client memory.
```typescript
const VAULT_SALT = new TextEncoder().encode('global-app-vault-v1-prf-domain-salt');

export async function deriveHardwareKey(
  credentialId: Uint8Array,
  challenge: Uint8Array
): Promise<CryptoKey> {
  const assertion = await navigator.credentials.get({
    publicKey: {
      challenge,
      allowCredentials: [{
        id: credentialId,
        type: 'public-key',
        transports: ['internal', 'hybrid', 'usb', 'nfc']
      }],
      extensions: {
        prf: {
          eval: {
            first: VAULT_SALT
          }
        }
      }
    }
  }) as PublicKeyCredential | null;

  if (!assertion) {
    throw new Error('Authentication rejected by hardware authenticator.');
  }

  const extensionResults = assertion.getClientExtensionResults();
  const prfResult = extensionResults.prf?.results?.first;

  if (!prfResult) {
    throw new Error('Hardware authenticator does not support WebAuthn PRF extension or eval failed.');
  }

  const prfBytes = new Uint8Array(prfResult);
  try {
    // Import raw PRF output as non-extractable HKDF master key
    const baseKey = await crypto.subtle.importKey(
      'raw',
      prfBytes,
      'HKDF',
      false,
      ['deriveKey']
    );

    // Derive the final non-extractable AES-256-GCM symmetric key
    return await crypto.subtle.deriveKey(
      {
        name: 'HKDF',
        salt: new Uint8Array(32), // domain separation salt
        info: new TextEncoder().encode('app-vault-aes-gcm-encryption'),
        hash: 'SHA-256'
      },
      baseKey,
      { name: 'AES-GCM', length: 256 },
      false, // non-extractable
      ['encrypt', 'decrypt']
    );
  } finally {
    // Zeroize PRF raw buffer immediately from client memory
    prfBytes.fill(0);
  }
}
```

Architectural Specification & Invariant Rationale

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

Hardware-Backed WebAuthn PRF Zero-Knowledge Key Derivation Standard defines an industrial-grade behavioral standard for security engineering. Enforces deterministic, client-side symmetric key derivation strictly via the WebAuthn Level 3 PRF (Pseudo-Random Function) extension for zero-knowledge end-to-end encryption. Prohibits insecure software fallbacks, client-side disk persistence of derived root secrets, and transmission of hardware-derived entropy to remote servers. 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: Persisting PRF Entropy or Deriving Zero-Knowledge Keys via Fallback Client-Side Hashes 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 DriftPersisting PRF Entropy or Deriving Zero-Knowledge Keys via Fallback Client-Side HashesCritical
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 that the authenticator supports the `prf` extension during registration by requesting `{ extensions

Engineers MUST ALWAYS verify that the authenticator supports the `prf` extension during registration by requesting `{ extensions: { prf: {} } }` and inspecting `clientExtensionResults.prf.supported`.

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 ALWAYS supply a cryptographically secure, deterministic application salt (minimum 32 bytes) to `navigator.credentials.get()` inside `extensions.prf.eval.first`.

Engineers MUST ALWAYS supply a cryptographically secure, deterministic application salt (minimum 32 bytes) to `navigator.credentials.get()` inside `extensions.prf.eval.first`.

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 derive symmetric encryption keys (e.g., AES-256-GCM) from the raw PRF output using HKDF (RFC 5869) via `SubtleCrypto.deriveKey()` with an explicit application domain-separation context string.

Engineers MUST derive symmetric encryption keys (e.g., AES-256-GCM) from the raw PRF output using HKDF (RFC 5869) via `SubtleCrypto.deriveKey()` with an explicit application domain-separation context string.

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 persist the raw PRF output or derived root encryption keys in `localStorage`, `sessionStorage`, `IndexedDB`, or cookies under any circumstances.

Engineers MUST NOT persist the raw PRF output or derived root encryption keys in `localStorage`, `sessionStorage`, `IndexedDB`, or cookies under any circumstances.

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

Engineers MUST NOT transmit raw PRF output or derived symmetric key material over the network or include it in WebAuthn assertion verification payloads sent to the backend.

Engineers MUST NOT transmit raw PRF output or derived symmetric key material over the network or include it in WebAuthn assertion verification payloads sent to the backend.

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

Components NEVER fall back to password-based derivation (e.g., PBKDF2 over raw master passwords) when the WebAuthn PRF extension fails

Components NEVER fall back to password-based derivation (e.g., PBKDF2 over raw master passwords) when the WebAuthn PRF extension fails; the operation MUST fail closed.

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

Services MUST overwrite and zeroize intermediate PRF output buffers immediately after importing them into non-extractable Web Crypto CryptoKey objects.

Services MUST overwrite and zeroize intermediate PRF output buffers immediately after importing them into non-extractable Web Crypto CryptoKey objects.

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

Enforces deterministic, client-side symmetric key derivation strictly via the WebAuthn Level 3 PRF (Pseudo-Random Function) extension for zero-knowledge end-to-end encryption. Prohibits insecure software fallbacks, client-side disk persistence of derived root secrets, and transmission of hardware-derived entropy to remote 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 (Persisting PRF Entropy or Deriving Zero-Knowledge Keys via Fallback Client-Side Hashes) 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

Hardware-Backed