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

WebAuthn L3 PRF Hardware-Backed Zero-Knowledge Key Derivation Guardrail

Mandates strict zero-knowledge client-side encryption using the WebAuthn Level 3 Pseudo-Random Function (PRF) extension. Guarantees that raw PRF outputs and derived symmetric encryption keys are processed exclusively within client-side Web Crypto subsystems and never transmitted over the wire or persisted in inspectable storage.

Prohibited Anti-Pattern: Transmitting raw PRF outputs, leaking derived symmetric keys to relying parties, or using extractable client-side key storage.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: WebAuthn L3 PRF Hardware-Backed Zero-Knowledge Key Derivation Guardrail - Mandates strict zero-knowledge client-side encryption using the WebAuthn Level 3 Pseudo-Random Function (PRF) extension. Guarantees that raw PRF outputs and derived symmetric encryption keys are processed exclusively within client-side Web Crypto subsystems and never transmitted over the wire or persisted in inspectable storage.
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-l3-prf-zero-knowledge-encryption-standard"
---

# WebAuthn L3 PRF Hardware-Backed Zero-Knowledge Key Derivation Guardrail

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Transmitting raw PRF outputs, leaking derived symmetric keys to relying parties, or using extractable client-side key storage.

## System Constraints
You are a Principal Security Architect enforcing the WebAuthn Level 3 PRF (Pseudo-Random Function) Client-Side Zero-Knowledge Encryption Standard. Mandate that all cryptographic operations utilizing hardware passkey PRF extensions guarantee zero-knowledge architecture. Never expose PRF outputs or derived master/encryption keys to Relying Party (RP) authentication servers, telemetry, or unmanaged browser storage. Enforce secure key derivation via Web Crypto HKDF and non-extractable CryptoKey handles.

## Strict Guidelines
- Engineers MUST ALWAYS verify client and authenticator PRF extension capabilities using PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable() and checking getClientExtensionResults().prf before initiating key derivation workflows.
- Engineers MUST NOT transmit raw PRF extension evaluation outputs (results.first or results.second) or derived plaintext keys to authentication backends, relying party endpoints, or observability sinks.
- Code MUST derive operational symmetric keys (e.g., AES-GCM-256) from raw PRF outputs using HKDF-SHA-256 with domain-separated info strings and high-entropy, server-provided or cryptographically random client salts.
- Services MUST import the PRF output into Web Crypto SubtleCrypto as a 'raw' key with extractable set to false whenever direct usage is supported, and explicitly zeroize (fill with 0) all intermediate ArrayBuffers and TypedArrays immediately after key material import.
- Components NEVER store derived master encryption keys or PRF secrets in localStorage, sessionStorage, IndexedDB, or standard unencrypted cookies.

## Bad vs Good Implementations
### Deterministic Key Derivation via WebAuthn PRF Extension

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Transmitting raw PRF outputs to the authentication backend violates the zero-knowledge invariant. The relying party can decrypt user data or compromise user privacy if compromised.
```typescript
// CRITICAL SECURITY FLAW: Leaking raw PRF output to the backend server
export async function unlockUserVaultBad(credentialId: Uint8Array, salt: Uint8Array) {
  const credential = (await navigator.credentials.get({
    publicKey: {
      challenge: crypto.getRandomValues(new Uint8Array(32)),
      allowCredentials: [{ id: credentialId, type: 'public-key' }],
      extensions: {
        prf: {
          eval: { first: salt }
        }
      }
    }
  })) as PublicKeyCredential;

  const extensionResults = credential.getClientExtensionResults();
  const rawPrf = new Uint8Array(extensionResults.prf?.results?.first!);

  // Leaking zero-knowledge secret material directly to Relying Party
  await fetch('/api/vault/unlock', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      credentialId: Array.from(credentialId),
      prfKey: Array.from(rawPrf) // ZERO-KNOWLEDGE DESTROYED
    })
  });
}
```

#### Production Standard (Correct)
> **Standard**: Evaluates PRF strictly on-device, imports PRF output as non-extractable key material, derives an AES-GCM-256 key via HKDF with context binding, zeroizes intermediate buffers in a finally block, and never sends key bytes over the network.
```typescript
// SECURE: Hardware PRF evaluated client-side, derived via HKDF into non-extractable CryptoKey, memory zeroized
export async function unlockUserVaultGood(
  credentialId: Uint8Array,
  salt: Uint8Array,
  infoContext: Uint8Array
): Promise<CryptoKey> {
  const credential = (await navigator.credentials.get({
    publicKey: {
      challenge: crypto.getRandomValues(new Uint8Array(32)),
      allowCredentials: [{ id: credentialId, type: 'public-key' }],
      extensions: {
        prf: {
          eval: { first: salt }
        }
      }
    }
  })) as PublicKeyCredential | null;

  if (!credential) {
    throw new Error('Credential assertion failed.');
  }

  const prfResults = credential.getClientExtensionResults().prf;
  if (!prfResults?.results?.first) {
    throw new Error('Authenticator did not return PRF evaluation result.');
  }

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

  try {
    // Import PRF output as raw IKM for HKDF derivation
    const initialKeyMaterial = await crypto.subtle.importKey(
      'raw',
      rawPrfBuffer,
      { name: 'HKDF' },
      false,
      ['deriveKey']
    );

    // Derive a non-extractable AES-GCM encryption key
    const derivedEncryptionKey = await crypto.subtle.deriveKey(
      {
        name: 'HKDF',
        hash: 'SHA-256',
        salt: salt,
        info: infoContext
      },
      initialKeyMaterial,
      { name: 'AES-GCM', length: 256 },
      false, // non-extractable: cannot be exported from memory
      ['encrypt', 'decrypt']
    );

    return derivedEncryptionKey;
  } finally {
    // Explicitly zeroize raw PRF buffer in memory immediately
    rawPrfBuffer.fill(0);
  }
}
```

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 L3 PRF Hardware-Backed Zero-Knowledge Key Derivation Guardrail

WebAuthn L3 PRF Hardware-Backed Zero-Knowledge Key Derivation Guardrail defines an industrial-grade behavioral standard for security engineering. Mandates strict zero-knowledge client-side encryption using the WebAuthn Level 3 Pseudo-Random Function (PRF) extension. Guarantees that raw PRF outputs and derived symmetric encryption keys are processed exclusively within client-side Web Crypto subsystems and never transmitted over the wire or persisted in inspectable 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: Transmitting raw PRF outputs, leaking derived symmetric keys to relying parties, or using extractable client-side key storage. 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 PRF outputs, leaking derived symmetric keys to relying parties, or using extractable client-side key storage.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 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 PRF extension capabilities using PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable() and checking getClientExtensionResults().prf before initiating key derivation workflows.

Engineers MUST ALWAYS verify client and authenticator PRF extension capabilities using PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable() and checking getClientExtensionResults().prf before initiating key derivation 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 extension evaluation outputs (results.first or results.second) or derived plaintext keys to authentication backends, relying party endpoints, or observability sinks.

Engineers MUST NOT transmit raw PRF extension evaluation outputs (results.first or results.second) or derived plaintext keys to authentication backends, relying party endpoints, or observability sinks.

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 derive operational symmetric keys (e.g., AES-GCM-256) from raw PRF outputs using HKDF-SHA-256 with domain-separated info strings and high-entropy, server-provided or cryptographically random client salts.

Code MUST derive operational symmetric keys (e.g., AES-GCM-256) from raw PRF outputs using HKDF-SHA-256 with domain-separated info strings and high-entropy, server-provided or cryptographically random client salts.

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 import the PRF output into Web Crypto SubtleCrypto as a 'raw' key with extractable set to false whenever direct usage is supported, and explicitly zeroize (fill with 0) all intermediate ArrayBuffers and TypedArrays immediately after key material import.

Services MUST import the PRF output into Web Crypto SubtleCrypto as a 'raw' key with extractable set to false whenever direct usage is supported, and explicitly zeroize (fill with 0) all intermediate ArrayBuffers and TypedArrays immediately after key material import.

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 derived master encryption keys or PRF secrets in localStorage, sessionStorage, IndexedDB, or standard unencrypted cookies.

Components NEVER store derived master encryption keys or PRF secrets in localStorage, sessionStorage, IndexedDB, or standard unencrypted cookies.

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

Mandates strict zero-knowledge client-side encryption using the WebAuthn Level 3 Pseudo-Random Function (PRF) extension. Guarantees that raw PRF outputs and derived symmetric encryption keys are processed exclusively within client-side Web Crypto subsystems and never transmitted over the wire or persisted in inspectable 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 (Transmitting raw PRF outputs, leaking derived symmetric keys to relying parties, or using extractable client-side key storage.) 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