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

WebAuthn LargeBlob Partition Isolation and Cryptographic AAD Binding Standard

Enforces cryptographically bounded, origin-scoped storage partitioning on WebAuthn Level 3 largeBlob extensions to prevent cross-session payload corruption and token leakage. Mandates that all hardware-backed authenticator storage operations apply AEAD authenticated encryption with Additional Authenticated Data (AAD) strictly bound to the Relying Party ID, Credential ID, and User Handle. Eliminates shared namespace clobbering, replay attacks, and unauthorized cross-identity read-write access.

Prohibited Anti-Pattern: Writing Plaintext or Namespace-Agnostic Payloads into WebAuthn LargeBlob Storage Without Cryptographic AAD Binding

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: WebAuthn LargeBlob Partition Isolation and Cryptographic AAD Binding Standard - Enforces cryptographically bounded, origin-scoped storage partitioning on WebAuthn Level 3 largeBlob extensions to prevent cross-session payload corruption and token leakage. Mandates that all hardware-backed authenticator storage operations apply AEAD authenticated encryption with Additional Authenticated Data (AAD) strictly bound to the Relying Party ID, Credential ID, and User Handle. Eliminates shared namespace clobbering, replay attacks, and unauthorized cross-identity read-write access.
globs: src/**/auth/**/*.{ts,tsx}, src/**/webauthn/**/*.{ts,tsx}, src/**/passkey/**/*.{ts,tsx}, src/**/crypto/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/webauthn-largeblob-partition-isolation-invariant"
---

# WebAuthn LargeBlob Partition Isolation and Cryptographic AAD Binding Standard

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Writing Plaintext or Namespace-Agnostic Payloads into WebAuthn LargeBlob Storage Without Cryptographic AAD Binding

## System Constraints
You are a Principal Security Architect enforcing the WebAuthn LargeBlob Synchronized Key-Value Partition Isolation Invariant. You must reject any WebAuthn implementation that reads or writes authenticator largeBlob payloads as raw unpartitioned data or without cryptographic envelope binding. Mandate strict AEAD authenticated encryption where Additional Authenticated Data (AAD) inextricably couples RP origin, Credential ID, and User Handle, accompanied by monotonic sequence enforcement.

## Strict Guidelines
- Engineers MUST ALWAYS wrap WebAuthn largeBlob data in a cryptographically authenticated envelope using AEAD (e.g., AES-256-GCM or ChaCha20-Poly1305) before writing to the authenticator.
- Engineers MUST cryptographically bind the Relying Party ID (rpId), credentialId, and canonical userHandle as Additional Authenticated Data (AAD) during AEAD sealing and unsealing operations.
- Engineers MUST NOT store raw plaintext tokens, unauthenticated JSON objects, or credentials in CTAP 2.1 largeBlob storage.
- Code SHOULD enforce monotonic sequence counters or cryptographic state commitments within largeBlob envelopes to detect and abort stale write-back races across concurrent tabs.
- Services MUST validate that the decrypted partition identifier matches the active authenticated session context before granting access to contained identity assertions.
- Components NEVER execute blind writes or whole-blob overwrites without executing an atomic read-verify-modify cycle to preserve concurrent partition integrity.

## Bad vs Good Implementations
### Unbound LargeBlob Storage vs. AEAD-Bound Partitioned Storage

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Writing arbitrary plaintext or raw JSON into WebAuthn largeBlob provides zero origin or credential-level binding. A malicious client-side context or compromised sub-origin sharing the same physical authenticator can overwrite or read this token, leading to cross-session identity leakage, token tampering, and replay vulnerabilities without detection.
```typescript
import { startAuthentication } from '@simplewebauthn/browser';

// VULNERABLE: Direct plaintext storage without AAD binding, isolation, or integrity validation
export async function writeSessionTokenToAuthenticator(
  assertionOptions: any,
  token: string
): Promise<void> {
  const credential = await navigator.credentials.get({
    publicKey: {
      ...assertionOptions,
      extensions: {
        largeBlob: {
          // Insecure: Writing raw utf8/JSON directly into authenticator storage
          write: new TextEncoder().encode(JSON.stringify({ sessionToken: token })),
        },
      },
    },
  });

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

#### Production Standard (Correct)
> **Standard**: The secure implementation encapsulates data inside an AES-256-GCM envelope with explicit AAD cryptographic binding to the RP ID, Credential ID, User Handle, and a monotonic sequence number. Any attempt by another session or tampered credential context to decrypt, replay, or overwrite the blob results in cryptographic authentication failure.
```typescript
import { startAuthentication } from '@simplewebauthn/browser';

interface AuthenticatedEnvelope {
  version: 1;
  sequence: number;
  iv: string; // Base64 encoded
  ciphertext: string; // Base64 encoded
  tag: string; // Base64 encoded
}

interface PartitionContext {
  rpId: string;
  credentialId: Uint8Array;
  userHandle: Uint8Array;
  sequence: number;
}

// Constructs canonical AAD binding: rpId || credentialId || userHandle || sequence
function constructAad(ctx: PartitionContext): Uint8Array {
  const enc = new TextEncoder();
  const rpBytes = enc.encode(ctx.rpId);
  const totalLength = 4 + rpBytes.length + 4 + ctx.credentialId.length + 4 + ctx.userHandle.length + 8;
  const buffer = new Uint8Array(totalLength);
  const view = new DataView(buffer.buffer);

  let offset = 0;
  view.setUint32(offset, rpBytes.length, false);
  offset += 4;
  buffer.set(rpBytes, offset);
  offset += rpBytes.length;

  view.setUint32(offset, ctx.credentialId.length, false);
  offset += 4;
  buffer.set(ctx.credentialId, offset);
  offset += ctx.credentialId.length;

  view.setUint32(offset, ctx.userHandle.length, false);
  offset += 4;
  buffer.set(ctx.userHandle, offset);
  offset += ctx.userHandle.length;

  view.setBigUint64(offset, BigInt(ctx.sequence), false);
  return buffer;
}

export async function writeSecurePartitionedBlob(
  assertionOptions: PublicKeyCredentialRequestOptions,
  key: CryptoKey,
  context: PartitionContext,
  partitionPayload: Record<string, unknown>
): Promise<void> {
  const iv = crypto.getRandomValues(new Uint8Array(12));
  const aad = constructAad(context);
  const plaintext = new TextEncoder().encode(JSON.stringify(partitionPayload));

  // AEAD sealing with strict AAD binding
  const ciphertextBuffer = await crypto.subtle.encrypt(
    {
      name: 'AES-GCM',
      iv,
      additionalData: aad,
      tagLength: 128,
    },
    key,
    plaintext
  );

  const envelope = {
    version: 1 as const,
    sequence: context.sequence,
    iv: btoa(String.fromCharCode(...iv)),
    ciphertext: btoa(String.fromCharCode(...new Uint8Array(ciphertextBuffer))),
  };

  const encodedEnvelope = new TextEncoder().encode(JSON.stringify(envelope));

  const credential = (await navigator.credentials.get({
    publicKey: {
      ...assertionOptions,
      extensions: {
        largeBlob: {
          write: encodedEnvelope,
        },
      },
    },
  })) as PublicKeyCredential & { getClientExtensionResults: () => { largeBlob?: { written?: boolean } } };

  const results = credential?.getClientExtensionResults();
  if (!results?.largeBlob?.written) {
    throw new Error('WebAuthn largeBlob write operation failed or was rejected by authenticator');
  }
}
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: WebAuthn LargeBlob Partition Isolation and Cryptographic AAD Binding Standard

WebAuthn LargeBlob Partition Isolation and Cryptographic AAD Binding Standard defines an industrial-grade behavioral standard for security engineering. Enforces cryptographically bounded, origin-scoped storage partitioning on WebAuthn Level 3 largeBlob extensions to prevent cross-session payload corruption and token leakage. Mandates that all hardware-backed authenticator storage operations apply AEAD authenticated encryption with Additional Authenticated Data (AAD) strictly bound to the Relying Party ID, Credential ID, and User Handle. Eliminates shared namespace clobbering, replay attacks, and unauthorized cross-identity read-write access. 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: Writing Plaintext or Namespace-Agnostic Payloads into WebAuthn LargeBlob Storage Without Cryptographic AAD Binding 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 DriftWriting Plaintext or Namespace-Agnostic Payloads into WebAuthn LargeBlob Storage Without Cryptographic AAD BindingCritical
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 wrap WebAuthn largeBlob data in a cryptographically authenticated envelope using AEAD (e.g., AES-256-GCM or ChaCha20-Poly1305) before writing to the authenticator.

Engineers MUST ALWAYS wrap WebAuthn largeBlob data in a cryptographically authenticated envelope using AEAD (e.g., AES-256-GCM or ChaCha20-Poly1305) before writing to the authenticator.

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 cryptographically bind the Relying Party ID (rpId), credentialId, and canonical userHandle as Additional Authenticated Data (AAD) during AEAD sealing and unsealing operations.

Engineers MUST cryptographically bind the Relying Party ID (rpId), credentialId, and canonical userHandle as Additional Authenticated Data (AAD) during AEAD sealing and unsealing 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.
3

Engineers MUST NOT store raw plaintext tokens, unauthenticated JSON objects, or credentials in CTAP 2.1 largeBlob storage.

Engineers MUST NOT store raw plaintext tokens, unauthenticated JSON objects, or credentials in CTAP 2.1 largeBlob 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.
4

Code SHOULD enforce monotonic sequence counters or cryptographic state commitments within largeBlob envelopes to detect and abort stale write-back races across concurrent tabs.

Code SHOULD enforce monotonic sequence counters or cryptographic state commitments within largeBlob envelopes to detect and abort stale write-back races across concurrent tabs.

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

Services MUST validate that the decrypted partition identifier matches the active authenticated session context before granting access to contained identity assertions.

Services MUST validate that the decrypted partition identifier matches the active authenticated session context before granting access to contained identity assertions.

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 execute blind writes or whole-blob overwrites without executing an atomic read-verify-modify cycle to preserve concurrent partition integrity.

Components NEVER execute blind writes or whole-blob overwrites without executing an atomic read-verify-modify cycle to preserve concurrent partition integrity.

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 Partition Isolation and Cryptographic AAD Binding Standard critical for AI coding assistants?

Enforces cryptographically bounded, origin-scoped storage partitioning on WebAuthn Level 3 largeBlob extensions to prevent cross-session payload corruption and token leakage. Mandates that all hardware-backed authenticator storage operations apply AEAD authenticated encryption with Additional Authenticated Data (AAD) strictly bound to the Relying Party ID, Credential ID, and User Handle. Eliminates shared namespace clobbering, replay attacks, and unauthorized cross-identity read-write access. 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 (Writing Plaintext or Namespace-Agnostic Payloads into WebAuthn LargeBlob Storage Without Cryptographic AAD Binding) 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