This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: webauthn-device-bound-attestation-enforcement-webauthn-device--616

WebAuthn Device-Bound Attestation vs Synced-Passkey Enforcement Invariant

Enforces strict validation of authenticator attachment, AAGUID metadata, and authenticator data flags at the Relying Party (RP) layer during credential registration and step-up authentication. Prevents multi-device synced credentials (such as iCloud Keychain or Google Password Manager passkeys) from satisfying high-assurance authorization gates requiring hardware-bound FIDO2 security keys (YubiKey, Titan).

Prohibited Anti-Pattern: Accepting Synced Passkeys for Step-Up Authentication Due to Missing AAGUID and BE/BS Flag Checks

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: WebAuthn Device-Bound Attestation vs Synced-Passkey Enforcement Invariant - Enforces strict validation of authenticator attachment, AAGUID metadata, and authenticator data flags at the Relying Party (RP) layer during credential registration and step-up authentication. Prevents multi-device synced credentials (such as iCloud Keychain or Google Password Manager passkeys) from satisfying high-assurance authorization gates requiring hardware-bound FIDO2 security keys (YubiKey, Titan).
globs: src/auth/**/*.{ts,tsx}, src/server/auth/**/*.{ts,tsx}, src/api/auth/**/*.{ts,tsx}, src/lib/webauthn/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/webauthn-device-bound-attestation-enforcement-webauthn-device--616"
---

# WebAuthn Device-Bound Attestation vs Synced-Passkey Enforcement Invariant

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Accepting Synced Passkeys for Step-Up Authentication Due to Missing AAGUID and BE/BS Flag Checks

## System Constraints
You are a Principal Security Architect enforcing the WebAuthn Device-Bound Attestation vs Synced-Passkey Enforcement Invariant. You must ensure that authentication systems differentiate between multi-device synced passkeys and device-bound hardware authenticators at the Relying Party (RP) layer. Step-up privileges, administrative actions, and high-assurance operations must reject credentials that exhibit Backup Eligibility (BE) flags or non-hardware AAGUIDs.

## Strict Guidelines
- Engineers MUST ALWAYS inspect Authenticator Data flags: verify the Backup Eligibility (BE) flag (bit 3) and Backup State (BS) flag (bit 4) to distinguish multi-device credentials from single-device bound credentials.
- Engineers MUST NEVER permit credentials with `backupEligible: true` or `backedUp: true` to satisfy step-up authorization policies requiring device-bound FIDO2 keys.
- Services MUST validate the AAGUID against an authoritative FIDO Alliance Metadata Service (MDS) blob when attestation is requested to confirm hardware-backed security capabilities.
- Services MUST request direct or enterprise attestation (`attestation: 'direct' | 'enterprise'`) and reject `none` when provisioning credentials meant for hardware-enforced step-up workflows.
- Code SHOULD persist the verified authenticator transport characteristics, AAGUID, and device-bound status (`isDeviceBound: boolean`) in the database alongside credential public keys for subsequent assertion evaluations.

## Bad vs Good Implementations
### Enforcing Device-Bound Attestation Verification at Registration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The handler accepts any verified WebAuthn registration. Synced multi-device passkeys (such as iCloud Keychain or Google Password Manager) will successfully register, violating the invariant that high-security step-up actions must require non-exportable hardware-bound authenticators.
```typescript
import { verifyRegistrationResponse } from '@simplewebauthn/server';
import type { RegistrationResponseJSON } from '@simplewebauthn/types';

export async function registerStepUpCredential(response: RegistrationResponseJSON, expectedChallenge: string) {
  const verification = await verifyRegistrationResponse({
    response,
    expectedChallenge,
    expectedOrigin: 'https://auth.example.com',
    expectedRPID: 'example.com',
  });

  if (!verification.verified || !verification.registrationInfo) {
    throw new Error('Registration failed');
  }

  // SECURITY FLAW: Blindly accepting any passkey including synced iCloud/Google passkeys
  // for high-privilege operations without validating BE flag or AAGUID
  return saveUserCredential({
    credentialID: verification.registrationInfo.credentialID,
    credentialPublicKey: verification.registrationInfo.credentialPublicKey,
    counter: verification.registrationInfo.counter,
    isHighSecurity: true,
  });
}
```

#### Production Standard (Correct)
> **Standard**: Strictly asserts that the credential is neither backup-eligible nor backed up by parsing authenticator flags, while rejecting zeroed/unattested AAGUIDs before associating the key with elevated privileges.
```typescript
import { verifyRegistrationResponse } from '@simplewebauthn/server';
import type { RegistrationResponseJSON } from '@simplewebauthn/types';

// Zeroed AAGUID represents an authenticator that does not identify its make/model (common for synced passkeys)
const ZERO_AAGUID = '00000000-0000-0000-0000-000000000000';

export async function registerStepUpCredential(response: RegistrationResponseJSON, expectedChallenge: string) {
  const verification = await verifyRegistrationResponse({
    response,
    expectedChallenge,
    expectedOrigin: 'https://auth.example.com',
    expectedRPID: 'example.com',
    requireUserVerification: true,
  });

  if (!verification.verified || !verification.registrationInfo) {
    throw new Error('WebAuthn registration verification failed');
  }

  const { aaguid, flags, credentialID, credentialPublicKey, counter } = verification.registrationInfo;

  // Invariant: Step-up hardware authenticators MUST NOT be backup eligible or backed up
  const isDeviceBound = !flags.backupEligible && !flags.backupState;
  const isRecognizedHardware = aaguid !== ZERO_AAGUID;

  if (!isDeviceBound || !isRecognizedHardware) {
    throw new SecurityError('Credential does not satisfy device-bound hardware invariant for step-up escalation');
  }

  return saveUserCredential({
    credentialID,
    credentialPublicKey,
    counter,
    aaguid,
    isDeviceBound: true,
    registeredAt: new Date(),
  });
}
```

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 Device-Bound Attestation vs Synced-Passkey Enforcement Invariant

WebAuthn Device-Bound Attestation vs Synced-Passkey Enforcement Invariant defines an industrial-grade behavioral standard for security engineering. Enforces strict validation of authenticator attachment, AAGUID metadata, and authenticator data flags at the Relying Party (RP) layer during credential registration and step-up authentication. Prevents multi-device synced credentials (such as iCloud Keychain or Google Password Manager passkeys) from satisfying high-assurance authorization gates requiring hardware-bound FIDO2 security keys (YubiKey, Titan). 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: Accepting Synced Passkeys for Step-Up Authentication Due to Missing AAGUID and BE/BS Flag Checks 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 DriftAccepting Synced Passkeys for Step-Up Authentication Due to Missing AAGUID and BE/BS Flag ChecksCritical
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 inspect Authenticator Data flags

Engineers MUST ALWAYS inspect Authenticator Data flags: verify the Backup Eligibility (BE) flag (bit 3) and Backup State (BS) flag (bit 4) to distinguish multi-device credentials from single-device bound credentials.

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 permit credentials with `backupEligible

Engineers MUST NEVER permit credentials with `backupEligible: true` or `backedUp: true` to satisfy step-up authorization policies requiring device-bound FIDO2 keys.

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 validate the AAGUID against an authoritative FIDO Alliance Metadata Service (MDS) blob when attestation is requested to confirm hardware-backed security capabilities.

Services MUST validate the AAGUID against an authoritative FIDO Alliance Metadata Service (MDS) blob when attestation is requested to confirm hardware-backed security capabilities.

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 request direct or enterprise attestation (`attestation

Services MUST request direct or enterprise attestation (`attestation: 'direct' | 'enterprise'`) and reject `none` when provisioning credentials meant for hardware-enforced step-up 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.
5

Code SHOULD persist the verified authenticator transport characteristics, AAGUID, and device-bound status (`isDeviceBound

Code SHOULD persist the verified authenticator transport characteristics, AAGUID, and device-bound status (`isDeviceBound: boolean`) in the database alongside credential public keys for subsequent assertion evaluations.

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 Device-Bound Attestation vs Synced-Passkey Enforcement Invariant critical for AI coding assistants?

Enforces strict validation of authenticator attachment, AAGUID metadata, and authenticator data flags at the Relying Party (RP) layer during credential registration and step-up authentication. Prevents multi-device synced credentials (such as iCloud Keychain or Google Password Manager passkeys) from satisfying high-assurance authorization gates requiring hardware-bound FIDO2 security keys (YubiKey, Titan). 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 (Accepting Synced Passkeys for Step-Up Authentication Due to Missing AAGUID and BE/BS Flag Checks) 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