This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: webauthn-l3-dynamic-backup-state-verification

WebAuthn Level 3 Dynamic Credential Backup State & Transport Flag Verification

Enforces strict server-side cryptographic verification of authenticator data flags (BE/BS) and transport hints during registration and authentication ceremonies according to W3C WebAuthn Level 3. Prevents multi-device credential synchronization spoofing and ensures accurate auditing of multi-device (synced) versus single-device (hardware-bound) passkeys.

Prohibited Anti-Pattern: Trusting client-reported credential properties or ignoring Backup Eligibility (BE) and Backup State (BS) flags during authenticatorData verification

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: WebAuthn Level 3 Dynamic Credential Backup State & Transport Flag Verification - Enforces strict server-side cryptographic verification of authenticator data flags (BE/BS) and transport hints during registration and authentication ceremonies according to W3C WebAuthn Level 3. Prevents multi-device credential synchronization spoofing and ensures accurate auditing of multi-device (synced) versus single-device (hardware-bound) passkeys.
globs: src/**/auth/**/*.{ts,js}, src/**/webauthn/**/*.{ts,js}, src/**/credentials/**/*.{ts,js}, src/**/services/**/*.{ts,js}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/webauthn-l3-dynamic-backup-state-verification"
---

# WebAuthn Level 3 Dynamic Credential Backup State & Transport Flag Verification

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Trusting client-reported credential properties or ignoring Backup Eligibility (BE) and Backup State (BS) flags during authenticatorData verification

## System Constraints
You are a Principal Security Architect enforcing W3C WebAuthn Level 3 compliance for passkeys. You must mandate strict cryptographic parsing and verification of authenticatorData bit flags (Bit 3: BE - Backup Eligibility, Bit 4: BS - Backup State) and authenticator transports directly from signed attestation and assertion objects. You must never trust unverified client-side metadata regarding passkey portability or backup status.

## Strict Guidelines
- Services MUST extract and verify Backup Eligibility (BE, bit 3, 0x08) and Backup State (BS, bit 4, 0x10) flags directly from the raw authenticatorData buffer signed by the credential.
- Services MUST reject or flag any authenticatorData where Backup State (BS) is true (1) but Backup Eligibility (BE) is false (0), as this violates Section 6.1 of the W3C WebAuthn Level 3 specification.
- Services MUST store and dynamically update the credential's `backupState` across authentications: if BE is true, the BS bit may transition from false to true over time, but a credential with BE=false MUST NEVER have BS=true.
- Engineers MUST NOT persist client-provided `response.transports` directly without sanitizing against valid authenticator transport enums ('ble', 'hybrid', 'internal', 'nfc', 'smart-card', 'usb').
- Services MUST enforce policy-based access control based on `backupEligibility`: single-device security keys (BE=0) must be tracked independently from multi-device synced passkeys (BE=1) when compliance requirements mandate hardware-bound tokens.

## Bad vs Good Implementations
### Verifying WebAuthn L3 AuthenticatorData Flags on Assertion

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Trusting client-reported backup states ('isBackedUp') and transports without inspecting the cryptographically signed 'authenticatorData' buffer allows attackers to bypass hardware token policies and falsify audit records.
```typescript
import { Request, Response } from 'express';
import { db } from './db';

export async function verifyAssertion(req: Request, res: Response) {
  const { credentialId, clientTransport, isBackedUp } = req.body;

  // SECURITY FLAW: Blindly trusts client-reported backup state and transport
  await db.credentials.update({
    where: { id: credentialId },
    data: {
      transports: clientTransport,
      isBackedUp: Boolean(isBackedUp),
      lastUsedAt: new Date()
    }
  });

  return res.json({ success: true });
}
```

#### Production Standard (Correct)
> **Standard**: Cryptographically parses the authenticatorData flags via SimpleWebAuthn, validates the W3C L3 invariant that BS implies BE, rejects invalid dynamic mutations of device-bound keys, and sanitizes transport hints before persisting.
```typescript
import { Request, Response } from 'express';
import { db } from './db';
import { verifyAuthenticationResponse } from '@simplewebauthn/server';
import type { AuthenticatorTransportFuture } from '@simplewebauthn/types';

const VALID_TRANSPORTS: readonly AuthenticatorTransportFuture[] = [
  'ble', 'hybrid', 'internal', 'nfc', 'smart-card', 'usb'
];

export async function verifyAssertion(req: Request, res: Response) {
  const { body } = req;
  const expectedChallenge = await db.challenges.consume(req.session.id);
  const credential = await db.credentials.findUniqueOrThrow({ where: { id: body.id } });

  const verification = await verifyAuthenticationResponse({
    response: body,
    expectedChallenge,
    expectedOrigin: process.env.AUTH_ORIGIN!,
    expectedRPID: process.env.AUTH_RPID!,
    credential: {
      id: credential.id,
      publicKey: credential.publicKey,
      counter: credential.signCount,
      transports: credential.transports as AuthenticatorTransportFuture[],
    },
  });

  if (!verification.verified || !verification.authenticationInfo) {
    return res.status(401).json({ error: 'Assertion verification failed' });
  }

  const { authenticatorData } = verification.authenticationInfo;
  const { flags } = authenticatorData;

  // W3C WebAuthn L3 Invariant: BS cannot be true if BE is false
  if (flags.backupState && !flags.backupEligibility) {
    throw new SecurityError('Invalid WebAuthn flag invariant: BS=1 with BE=0');
  }

  // Maintain hardware-bound credential immutability invariant
  if (!credential.backupEligible && flags.backupEligibility) {
    throw new SecurityError('Credential mutated immutability status from non-eligible to eligible');
  }

  const rawTransports = body.response.transports ?? [];
  const validatedTransports = rawTransports.filter((t: any): t is AuthenticatorTransportFuture => 
    VALID_TRANSPORTS.includes(t)
  );

  await db.credentials.update({
    where: { id: credential.id },
    data: {
      signCount: authenticatorData.counter,
      backupState: flags.backupState,
      backupEligible: flags.backupEligibility,
      transports: validatedTransports.length > 0 ? validatedTransports : credential.transports,
      lastUsedAt: new Date(),
    },
  });

  return res.json({ success: true });
}
```

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 Level 3 Dynamic Credential Backup State & Transport Flag Verification

WebAuthn Level 3 Dynamic Credential Backup State & Transport Flag Verification defines an industrial-grade behavioral standard for security engineering. Enforces strict server-side cryptographic verification of authenticator data flags (BE/BS) and transport hints during registration and authentication ceremonies according to W3C WebAuthn Level 3. Prevents multi-device credential synchronization spoofing and ensures accurate auditing of multi-device (synced) versus single-device (hardware-bound) passkeys. 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: Trusting client-reported credential properties or ignoring Backup Eligibility (BE) and Backup State (BS) flags during authenticatorData 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 DriftTrusting client-reported credential properties or ignoring Backup Eligibility (BE) and Backup State (BS) flags during authenticatorData 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

Services MUST extract and verify Backup Eligibility (BE, bit 3, 0x08) and Backup State (BS, bit 4, 0x10) flags directly from the raw authenticatorData buffer signed by the credential.

Services MUST extract and verify Backup Eligibility (BE, bit 3, 0x08) and Backup State (BS, bit 4, 0x10) flags directly from the raw authenticatorData buffer signed by the credential.

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

Services MUST reject or flag any authenticatorData where Backup State (BS) is true (1) but Backup Eligibility (BE) is false (0), as this violates Section 6.1 of the W3C WebAuthn Level 3 specification.

Services MUST reject or flag any authenticatorData where Backup State (BS) is true (1) but Backup Eligibility (BE) is false (0), as this violates Section 6.1 of the W3C WebAuthn Level 3 specification.

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

Services MUST store and dynamically update the credential's `backupState` across authentications

Services MUST store and dynamically update the credential's `backupState` across authentications: if BE is true, the BS bit may transition from false to true over time, but a credential with BE=false MUST NEVER have BS=true.

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 client-provided `response.transports` directly without sanitizing against valid authenticator transport enums ('ble', 'hybrid', 'internal', 'nfc', 'smart-card', 'usb').

Engineers MUST NOT persist client-provided `response.transports` directly without sanitizing against valid authenticator transport enums ('ble', 'hybrid', 'internal', 'nfc', 'smart-card', 'usb').

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 enforce policy-based access control based on `backupEligibility`

Services MUST enforce policy-based access control based on `backupEligibility`: single-device security keys (BE=0) must be tracked independently from multi-device synced passkeys (BE=1) when compliance requirements mandate hardware-bound tokens.

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 Level 3 Dynamic Credential Backup State & Transport Flag Verification critical for AI coding assistants?

Enforces strict server-side cryptographic verification of authenticator data flags (BE/BS) and transport hints during registration and authentication ceremonies according to W3C WebAuthn Level 3. Prevents multi-device credential synchronization spoofing and ensures accurate auditing of multi-device (synced) versus single-device (hardware-bound) passkeys. 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 (Trusting client-reported credential properties or ignoring Backup Eligibility (BE) and Backup State (BS) flags during authenticatorData 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