This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: webauthn-largeblob-encrypted-session-anchor-standard

WebAuthn LargeBlob Extension Client-Side Encrypted Session Anchor Standard

Governs the storage, retrieval, and cryptographic envelope lifecycle of hardware-attested, client-side encryption roots using the WebAuthn largeBlob extension. Mandates authenticated symmetric encryption (AES-256-GCM or ChaCha20-Poly1305) with ephemeral, derived keys before persisting session state or credentials to the authenticator, guaranteeing zero-knowledge offline authentication states resistant to device-level snooping and cross-origin leakage.

Prohibited Anti-Pattern: Persisting Plaintext Session Tokens or Using Static Authenticator-Derived Keys Directly in WebAuthn largeBlob Payloads

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: WebAuthn LargeBlob Extension Client-Side Encrypted Session Anchor Standard - Governs the storage, retrieval, and cryptographic envelope lifecycle of hardware-attested, client-side encryption roots using the WebAuthn largeBlob extension. Mandates authenticated symmetric encryption (AES-256-GCM or ChaCha20-Poly1305) with ephemeral, derived keys before persisting session state or credentials to the authenticator, guaranteeing zero-knowledge offline authentication states resistant to device-level snooping and cross-origin leakage.
globs: src/**/*.{ts,tsx}, lib/**/*.{ts,tsx}, services/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/webauthn-largeblob-encrypted-session-anchor-standard"
---

# WebAuthn LargeBlob Extension Client-Side Encrypted Session Anchor Standard

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Persisting Plaintext Session Tokens or Using Static Authenticator-Derived Keys Directly in WebAuthn largeBlob Payloads

## System Constraints
You are a Principal Security Architect enforcing the WebAuthn LargeBlob Extension Encrypted Session Anchor Standard. You must mandate that any storage of offline session anchors, cryptographic master keys, or identity tokens within the authenticator's largeBlob storage is enveloped using authenticated encryption with associated data (AEAD) derived via HKDF from high-entropy ephemeral user or hardware secrets. Reject any code that attempts to store raw strings, unencrypted JSON, static seeds, or credentials lacking freshness nonces and cryptographic binding in the largeBlob extension.

## Strict Guidelines
- Engineers MUST ALWAYS verify client support for `largeBlob` via `PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()` and inspecting assertion client extension results (`results.largeBlob?.supported === true`) before executing write operations.
- Engineers MUST NEVER write unencrypted plaintext tokens, unhashed PII, or raw signing private keys directly to `largeBlob.write` payload buffers.
- Payloads committed to `largeBlob` MUST be encrypted using an AEAD scheme (AES-256-GCM with a unique 96-bit IV) using a key derived from an ephemeral secret and credential ID through HKDF-SHA-256.
- Code MUST bind the credential ID and the origin domain as Additional Authenticated Data (AAD) during AEAD encryption to prevent blob swapping and cross-origin replay attacks across authenticators.
- Engineers MUST wrap all `navigator.credentials.get` and `navigator.credentials.create` calls containing `largeBlob` options in structured try/catch blocks that gracefully handle `ConstraintError`, `NotSupportedError`, and lack of authenticator storage capacity.

## Bad vs Good Implementations
### Insecure: Plaintext Session Serialization directly into largeBlob

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Writing serialized plaintext directly into largeBlob allows any attacker with local debug access or malicious extraction tools to read the session anchor without proving cryptographic ownership, violating zero-knowledge posture and failing origin-binding validation.
```typescript
export async function saveOfflineSession(credentialId: Uint8Array, sessionToken: string): Promise<void> {
  // Flaw: Storing unencrypted sensitive session tokens in largeBlob
  const textEncoder = new TextEncoder();
  const rawData = textEncoder.encode(JSON.stringify({ sessionToken, timestamp: Date.now() }));

  await navigator.credentials.get({
    publicKey: {
      challenge: crypto.getRandomValues(new Uint8Array(32)),
      allowCredentials: [{ id: credentialId, type: 'public-key' }],
      userVerification: 'required',
      extensions: {
        largeBlob: {
          write: rawData
        }
      }
    }
  });
}
```

#### Production Standard (Correct)
> **Standard**: Applies authenticated symmetric encryption (AES-256-GCM) with an origin-bound Additional Authenticated Data (AAD) constraint and high-entropy initialization vector prior to writing to largeBlob, verifying hardware write confirmation via `getClientExtensionResults()`.
```typescript
interface EncryptedAnchorEnvelope {
  iv: string;
  ciphertext: string;
  version: number;
}

export async function saveEncryptedOfflineAnchor(
  credentialId: Uint8Array,
  sessionRootKey: CryptoKey,
  payload: Record<string, unknown>
): Promise<void> {
  const iv = crypto.getRandomValues(new Uint8Array(12));
  const encoder = new TextEncoder();
  const aad = encoder.encode(window.location.origin);
  const plaintext = encoder.encode(JSON.stringify(payload));

  const ciphertextBuffer = await crypto.subtle.encrypt(
    { name: 'AES-GCM', iv, additionalData: aad, tagLength: 128 },
    sessionRootKey,
    plaintext
  );

  const envelope: EncryptedAnchorEnvelope = {
    iv: btoa(String.fromCharCode(...iv)),
    ciphertext: btoa(String.fromCharCode(...new Uint8Array(ciphertextBuffer))),
    version: 1,
  };
  const envelopeBytes = encoder.encode(JSON.stringify(envelope));

  const assertion = (await navigator.credentials.get({
    publicKey: {
      challenge: crypto.getRandomValues(new Uint8Array(32)),
      allowCredentials: [{ id: credentialId, type: 'public-key' }],
      userVerification: 'required',
      extensions: {
        largeBlob: {
          write: envelopeBytes
        }
      }
    }
  })) as PublicKeyCredential | null;

  const extensionResults = assertion?.getClientExtensionResults();
  if (!extensionResults?.largeBlob?.written) {
    throw new Error('Authenticator failed to write encrypted largeBlob anchor');
  }
}
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: WebAuthn LargeBlob Extension Client-Side Encrypted Session Anchor Standard

WebAuthn LargeBlob Extension Client-Side Encrypted Session Anchor Standard defines an industrial-grade behavioral standard for security engineering. Governs the storage, retrieval, and cryptographic envelope lifecycle of hardware-attested, client-side encryption roots using the WebAuthn largeBlob extension. Mandates authenticated symmetric encryption (AES-256-GCM or ChaCha20-Poly1305) with ephemeral, derived keys before persisting session state or credentials to the authenticator, guaranteeing zero-knowledge offline authentication states resistant to device-level snooping and cross-origin leakage. 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 Plaintext Session Tokens or Using Static Authenticator-Derived Keys Directly in WebAuthn largeBlob Payloads 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 Plaintext Session Tokens or Using Static Authenticator-Derived Keys Directly in WebAuthn largeBlob PayloadsCritical
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 support for `largeBlob` via `PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()` and inspecting assertion client extension results (`results.largeBlob?.supported === true`) before executing write operations.

Engineers MUST ALWAYS verify client support for `largeBlob` via `PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()` and inspecting assertion client extension results (`results.largeBlob?.supported === true`) before executing write 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.
2

Engineers MUST NEVER write unencrypted plaintext tokens, unhashed PII, or raw signing private keys directly to `largeBlob.write` payload buffers.

Engineers MUST NEVER write unencrypted plaintext tokens, unhashed PII, or raw signing private keys directly to `largeBlob.write` payload buffers.

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

Payloads committed to `largeBlob` MUST be encrypted using an AEAD scheme (AES-256-GCM with a unique 96-bit IV) using a key derived from an ephemeral secret and credential ID through HKDF-SHA-256.

Payloads committed to `largeBlob` MUST be encrypted using an AEAD scheme (AES-256-GCM with a unique 96-bit IV) using a key derived from an ephemeral secret and credential ID through HKDF-SHA-256.

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

Code MUST bind the credential ID and the origin domain as Additional Authenticated Data (AAD) during AEAD encryption to prevent blob swapping and cross-origin replay attacks across authenticators.

Code MUST bind the credential ID and the origin domain as Additional Authenticated Data (AAD) during AEAD encryption to prevent blob swapping and cross-origin replay attacks across authenticators.

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 wrap all `navigator.credentials.get` and `navigator.credentials.create` calls containing `largeBlob` options in structured try/catch blocks that gracefully handle `ConstraintError`, `NotSupportedError`, and lack of authenticator storage capacity.

Engineers MUST wrap all `navigator.credentials.get` and `navigator.credentials.create` calls containing `largeBlob` options in structured try/catch blocks that gracefully handle `ConstraintError`, `NotSupportedError`, and lack of authenticator storage capacity.

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 Extension Client-Side Encrypted Session Anchor Standard critical for AI coding assistants?

Governs the storage, retrieval, and cryptographic envelope lifecycle of hardware-attested, client-side encryption roots using the WebAuthn largeBlob extension. Mandates authenticated symmetric encryption (AES-256-GCM or ChaCha20-Poly1305) with ephemeral, derived keys before persisting session state or credentials to the authenticator, guaranteeing zero-knowledge offline authentication states resistant to device-level snooping and cross-origin leakage. 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 Plaintext Session Tokens or Using Static Authenticator-Derived Keys Directly in WebAuthn largeBlob Payloads) 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