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

WebAuthn LargeBlob Hardware-Isolated Zero-Knowledge Storage Invariant

Enforces strict hardware-isolated cryptographic key and credential synchronization using the WebAuthn CTAP 2.1 largeBlob extension. Guarantees that sensitive client-side key material is sealed within authenticator-backed memory and AEAD-authenticated, strictly forbidding cloud-side custody or unencrypted persistence in standard Web Storage APIs.

Prohibited Anti-Pattern: Degrading to Insecure Web Storage or Cloud Custody by Bypassing Hardware-Bound LargeBlob AEAD Verification

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: WebAuthn LargeBlob Hardware-Isolated Zero-Knowledge Storage Invariant - Enforces strict hardware-isolated cryptographic key and credential synchronization using the WebAuthn CTAP 2.1 largeBlob extension. Guarantees that sensitive client-side key material is sealed within authenticator-backed memory and AEAD-authenticated, strictly forbidding cloud-side custody or unencrypted persistence in standard Web Storage APIs.
globs: src/**/*.{ts,tsx,js,mjs}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/webauthn-largeblob-zero-knowledge-storage-invariant"
---

# WebAuthn LargeBlob Hardware-Isolated Zero-Knowledge Storage Invariant

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Degrading to Insecure Web Storage or Cloud Custody by Bypassing Hardware-Bound LargeBlob AEAD Verification

## System Constraints
You are a Principal Security Architect enforcing the WebAuthn LargeBlob Zero-Knowledge Local Storage Invariant. You must reject any pattern that stores sensitive client cryptographic secrets or recovery tokens in unbonded browser storage (localStorage, sessionStorage, IndexedDB) or exposes them to server-side custody. Authenticator hardware must serve as the root-of-trust for secret persistence via CTAP 2.1 largeBlob extensions, wrapped with AEAD authenticated encryption before write operations.

## Strict Guidelines
- Engineers MUST ALWAYS verify authenticator support for the 'largeBlob' extension during registration by asserting `clientExtensionResults.largeBlob?.supported === true` before provisioning zero-knowledge features.
- Engineers MUST NEVER persist raw cryptographic keys, recovery phrases, or private vault payloads in standard Web Storage (localStorage, sessionStorage, unencrypted IndexedDB) when largeBlob support is negotiated.
- Engineers MUST encrypt all data stored in largeBlob using an AEAD scheme (such as AES-256-GCM or ChaCha20-Poly1305) with an ephemeral key derived from the hardware credential or user master key before invoking the write operation.
- Services MUST NOT accept unverified or unsigned client-side assertions to bypass hardware presence checks; write operations MUST be cryptographically linked to a valid PublicKeyCredential assertion.
- Components NEVER silently fall back to cloud-side key custody when an authenticator lacks largeBlob capability; the system MUST explicitly warn the user and require an alternative hardware-backed or passphrase-derived key ceremony.

## Bad vs Good Implementations
### Hardware-Bound Zero-Knowledge Vault Synchronization via WebAuthn largeBlob

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Stores unprotected master key material in localStorage where it is vulnerable to XSS and client-side extraction, and exposes raw key material directly to cloud-side custody, completely violating the zero-knowledge hardware-isolation invariant.
```typescript
import { startAuthentication, startRegistration } from '@simplewebauthn/browser';

// ANTI-PATTERN: Leaking sensitive vault keys to unbonded storage and cloud database
export async function syncVaultKey(vaultKey: Uint8Array, credentialId: string) {
  // Insecure: Storing unencrypted secret in localStorage if WebAuthn sync is complex
  localStorage.setItem(`vault_key_${credentialId}`, Buffer.from(vaultKey).toString('hex'));

  // Insecure: Uploading raw vault key to backend API under the guise of 'cloud backup'
  await fetch('/api/vault/backup', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      credentialId,
      rawKey: Array.from(vaultKey)
    })
  });
}
```

#### Production Standard (Correct)
> **Standard**: Pins key persistence directly to the physical authenticator via the CTAP 2.1 largeBlob extension with userVerification required. Secret data is AEAD-protected and never exposed to vulnerable browser storage or backend servers.
```typescript
interface LargeBlobExtensionOutput {
  supported?: boolean;
  blob?: ArrayBuffer;
  written?: boolean;
}

export async function writeHardwareSealedVaultKey(
  credentialId: Uint8Array,
  challenge: Uint8Array,
  encryptedVaultPayload: Uint8Array // Pre-encrypted with user-derived AEAD key
): Promise<boolean> {
  // Hardware-bound write operation using CTAP 2.1 largeBlob extension
  const assertion = await navigator.credentials.get({
    publicKey: {
      challenge,
      allowCredentials: [{
        id: credentialId,
        type: 'public-key',
        transports: ['internal', 'usb', 'nfc', 'ble']
      }],
      userVerification: 'required',
      extensions: {
        largeBlob: {
          write: encryptedVaultPayload.buffer
        }
      }
    }
  }) as PublicKeyCredential | null;

  if (!assertion) {
    throw new Error('WebAuthn assertion failed or was rejected by user.');
  }

  const extensionOutputs = assertion.getClientExtensionResults() as Record<string, unknown>;
  const largeBlobResult = extensionOutputs.largeBlob as LargeBlobExtensionOutput | undefined;

  if (!largeBlobResult || !largeBlobResult.written) {
    throw new SecurityError('Hardware authenticator failed to commit largeBlob payload.');
  }

  return true;
}
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: WebAuthn LargeBlob Hardware-Isolated Zero-Knowledge Storage Invariant

WebAuthn LargeBlob Hardware-Isolated Zero-Knowledge Storage Invariant defines an industrial-grade behavioral standard for security engineering. Enforces strict hardware-isolated cryptographic key and credential synchronization using the WebAuthn CTAP 2.1 largeBlob extension. Guarantees that sensitive client-side key material is sealed within authenticator-backed memory and AEAD-authenticated, strictly forbidding cloud-side custody or unencrypted persistence in standard Web Storage APIs. 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: Degrading to Insecure Web Storage or Cloud Custody by Bypassing Hardware-Bound LargeBlob AEAD Verification 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 DriftDegrading to Insecure Web Storage or Cloud Custody by Bypassing Hardware-Bound LargeBlob AEAD VerificationCritical
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 authenticator support for the 'largeBlob' extension during registration by asserting `clientExtensionResults.largeBlob?.supported === true` before provisioning zero-knowledge features.

Engineers MUST ALWAYS verify authenticator support for the 'largeBlob' extension during registration by asserting `clientExtensionResults.largeBlob?.supported === true` before provisioning zero-knowledge features.

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 NEVER persist raw cryptographic keys, recovery phrases, or private vault payloads in standard Web Storage (localStorage, sessionStorage, unencrypted IndexedDB) when largeBlob support is negotiated.

Engineers MUST NEVER persist raw cryptographic keys, recovery phrases, or private vault payloads in standard Web Storage (localStorage, sessionStorage, unencrypted IndexedDB) when largeBlob support is negotiated.

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 encrypt all data stored in largeBlob using an AEAD scheme (such as AES-256-GCM or ChaCha20-Poly1305) with an ephemeral key derived from the hardware credential or user master key before invoking the write operation.

Engineers MUST encrypt all data stored in largeBlob using an AEAD scheme (such as AES-256-GCM or ChaCha20-Poly1305) with an ephemeral key derived from the hardware credential or user master key before invoking the write operation.

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 NOT accept unverified or unsigned client-side assertions to bypass hardware presence checks

Services MUST NOT accept unverified or unsigned client-side assertions to bypass hardware presence checks; write operations MUST be cryptographically linked to a valid PublicKeyCredential assertion.

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 silently fall back to cloud-side key custody when an authenticator lacks largeBlob capability

Components NEVER silently fall back to cloud-side key custody when an authenticator lacks largeBlob capability; the system MUST explicitly warn the user and require an alternative hardware-backed or passphrase-derived key ceremony.

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 LargeBlob Hardware-Isolated Zero-Knowledge Storage Invariant critical for AI coding assistants?

Enforces strict hardware-isolated cryptographic key and credential synchronization using the WebAuthn CTAP 2.1 largeBlob extension. Guarantees that sensitive client-side key material is sealed within authenticator-backed memory and AEAD-authenticated, strictly forbidding cloud-side custody or unencrypted persistence in standard Web Storage APIs. 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 (Degrading to Insecure Web Storage or Cloud Custody by Bypassing Hardware-Bound LargeBlob AEAD Verification) 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