This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: webauthn-l3-direct-attestation-validation

WebAuthn L3 Hardware-Bound Direct Attestation and Origin Invariant Validation

Enforces cryptographic direct attestation verification and strict authenticator data flag evaluation for WebAuthn Level 3 registrations. Prohibits multi-device synced credentials by asserting non-backup eligibility (BE=0, BS=0) and enforces exact origin checks to eliminate credential-relay vulnerabilities in enterprise environments.

Prohibited Anti-Pattern: Accepting 'none' attestation or synced passkeys (BE=1) for enterprise-tier hardware authentication

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: "WebAuthn L3 Hardware-Bound Direct Attestation and Origin Invariant Validation - Enforces cryptographic direct attestation verification and strict authenticator data flag evaluation for WebAuthn Level 3 registrations. Prohibits multi-device synced credentials by asserting non-backup eligibility (BE=0, BS=0) and enforces exact origin checks to eliminate credential-relay vulnerabilities in enterprise environments."
globs: "src/**/auth/**/*.{ts,tsx}, src/**/webauthn/**/*.{ts,tsx}, src/**/identity/**/*.{ts,tsx}, src/**/security/**/*.{ts,tsx}"
alwaysApply: true
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/webauthn-l3-direct-attestation-validation"
---

# WebAuthn L3 Hardware-Bound Direct Attestation and Origin Invariant Validation

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Accepting 'none' attestation or synced passkeys (BE=1) for enterprise-tier hardware authentication

## System Constraints
You are a Principal Security Architect enforcing FIDO2/WebAuthn Level 3 specifications. You must reject any authentication implementation that treats passkeys as fungible credentials without validating hardware root-of-trust, direct attestation statements, authenticator data flags, and strict origin bindings.

## Strict Guidelines
- Engineers MUST ALWAYS enforce 'attestation: "direct"' during registration options generation and reject attestation statement format 'none' during verification in enterprise tiers.
- Engineers MUST verify that Authenticator Data flags enforce non-exportable hardware bindings: Backup Eligibility (BE, bit 3) MUST be 0 and Backup State (BS, bit 4) MUST be 0.
- Engineers MUST validate the Authenticator Attestation GUID (AAGUID) against a cryptographically verified FIDO Metadata Service (MDS3) root store to guarantee FIPS 140-2/3 or Common Criteria EAL4+ hardware certification.
- Code MUST strictly validate 'clientDataJSON.origin' using constant-time string comparison against the canonical, fully-qualified enterprise origin (including protocol and port); wildcard, regex, or substring matches are strictly forbidden.
- Services MUST verify the X.509 attestation certificate chain up to a trusted enterprise or FIDO Alliance Root CA, enforcing revocation checks (CRL/OCSP) and checking intermediate certificate constraints.
- Components NEVER store or trust raw public keys prior to validating the cryptographic signature of the attestation statement over the authData and clientDataHash.

## Bad vs Good Implementations
### WebAuthn Registration Response Verification

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Accepts soft tokens and synced multi-device passkeys by failing to mandate direct attestation, failing to inspect authenticator data flags (BE/BS), and allowing dynamic or loose origin matching that opens the door to credential relay attacks.
```typescript
import { verifyRegistrationResponse } from '@simplewebauthn/server';
import type { RegistrationResponseJSON } from '@simplewebauthn/types';

export async function verifyUserPasskey(
  response: RegistrationResponseJSON,
  expectedChallenge: string,
  expectedOrigin: string
) {
  // Flaw 1: Loose origin matching permits reverse-proxy credential relay
  // Flaw 2: Missing direct attestation verification allows 'none' format
  // Flaw 3: Does not check Backup Eligibility (BE flag), allowing iCloud/Google synced passkeys
  const verification = await verifyRegistrationResponse({
    response,
    expectedChallenge,
    expectedOrigin: expectedOrigin.includes('corp.internal') ? response.clientExtensionResults : expectedOrigin,
    requireUserVerification: true,
  });

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

  return verification.registrationInfo;
}
```

#### Production Standard (Correct)
> **Standard**: Enforces non-exportable hardware credentials by validating the BE/BS flags in authenticatorData, requires direct attestation formats, enforces a verified AAGUID allowlist, and restricts origin validation to a strictly parameterized canonical endpoint.
```typescript
import { verifyRegistrationResponse } from '@simplewebauthn/server';
import type { RegistrationResponseJSON } from '@simplewebauthn/types';
import crypto from 'node:crypto';

interface EnterpriseVerificationOptions {
  response: RegistrationResponseJSON;
  expectedChallenge: string;
  canonicalOrigin: string;
  canonicalRpId: string;
  allowedAaguids: ReadonlySet<string>;
}

export async function verifyEnterprisePasskey({
  response,
  expectedChallenge,
  canonicalOrigin,
  canonicalRpId,
  allowedAaguids
}: EnterpriseVerificationOptions) {
  const verification = await verifyRegistrationResponse({
    response,
    expectedChallenge,
    expectedOrigin: canonicalOrigin,
    expectedRPID: canonicalRpId,
    requireUserVerification: true,
  });

  if (!verification.verified || !verification.registrationInfo) {
    throw new SecurityError('AUTHENTICATION_FAILED', 'WebAuthn response failed structural validation');
  }

  const { attestationObject, authenticatorData, aaguid } = verification.registrationInfo;
  const flags = authenticatorData.flags;

  // Invariant 1: Multi-device credentials MUST be rejected for enterprise fleets
  // Bit 3: Backup Eligibility (BE), Bit 4: Backup State (BS)
  if (flags.backupEligible || flags.backupState) {
    throw new SecurityError('SYNCED_CREDENTIAL_PROHIBITED', 'Hardware-bound security key required; synced passkeys are forbidden');
  }

  // Invariant 2: Hardware provenance enforcement via AAGUID allowlist (FIDO MDS verified)
  if (!allowedAaguids.has(aaguid)) {
    throw new SecurityError('UNTRUSTED_AUTHENTICATOR', `AAGUID ${aaguid} is not authorized for enterprise access`);
  }

  // Invariant 3: Reject 'none' attestation; must contain cryptographically verified statement
  const attestationStatementFormat = attestationObject.fmt;
  if (attestationStatementFormat === 'none') {
    throw new SecurityError('DIRECT_ATTESTATION_REQUIRED', 'Direct cryptographic attestation is mandatory');
  }

  return {
    credentialId: verification.registrationInfo.credentialID,
    credentialPublicKey: verification.registrationInfo.credentialPublicKey,
    counter: verification.registrationInfo.counter,
    aaguid,
  };
}
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: WebAuthn L3 Hardware-Bound Direct Attestation and Origin Invariant Validation

WebAuthn L3 Hardware-Bound Direct Attestation and Origin Invariant Validation defines an industrial-grade behavioral standard for security engineering. Enforces cryptographic direct attestation verification and strict authenticator data flag evaluation for WebAuthn Level 3 registrations. Prohibits multi-device synced credentials by asserting non-backup eligibility (BE=0, BS=0) and enforces exact origin checks to eliminate credential-relay vulnerabilities in enterprise environments. 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 'none' attestation or synced passkeys (BE=1) for enterprise-tier hardware authentication 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 'none' attestation or synced passkeys (BE=1) for enterprise-tier hardware authenticationCritical
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 enforce 'attestation

Engineers MUST ALWAYS enforce 'attestation: "direct"' during registration options generation and reject attestation statement format 'none' during verification in enterprise tiers.

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 verify that Authenticator Data flags enforce non-exportable hardware bindings

Engineers MUST verify that Authenticator Data flags enforce non-exportable hardware bindings: Backup Eligibility (BE, bit 3) MUST be 0 and Backup State (BS, bit 4) MUST be 0.

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 validate the Authenticator Attestation GUID (AAGUID) against a cryptographically verified FIDO Metadata Service (MDS3) root store to guarantee FIPS 140-2/3 or Common Criteria EAL4+ hardware certification.

Engineers MUST validate the Authenticator Attestation GUID (AAGUID) against a cryptographically verified FIDO Metadata Service (MDS3) root store to guarantee FIPS 140-2/3 or Common Criteria EAL4+ hardware certification.

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 strictly validate 'clientDataJSON.origin' using constant-time string comparison against the canonical, fully-qualified enterprise origin (including protocol and port)

Code MUST strictly validate 'clientDataJSON.origin' using constant-time string comparison against the canonical, fully-qualified enterprise origin (including protocol and port); wildcard, regex, or substring matches are strictly forbidden.

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 verify the X.509 attestation certificate chain up to a trusted enterprise or FIDO Alliance Root CA, enforcing revocation checks (CRL/OCSP) and checking intermediate certificate constraints.

Services MUST verify the X.509 attestation certificate chain up to a trusted enterprise or FIDO Alliance Root CA, enforcing revocation checks (CRL/OCSP) and checking intermediate certificate constraints.

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 store or trust raw public keys prior to validating the cryptographic signature of the attestation statement over the authData and clientDataHash.

Components NEVER store or trust raw public keys prior to validating the cryptographic signature of the attestation statement over the authData and clientDataHash.

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 L3 Hardware-Bound Direct Attestation and Origin Invariant Validation critical for AI coding assistants?

Enforces cryptographic direct attestation verification and strict authenticator data flag evaluation for WebAuthn Level 3 registrations. Prohibits multi-device synced credentials by asserting non-backup eligibility (BE=0, BS=0) and enforces exact origin checks to eliminate credential-relay vulnerabilities in enterprise environments. 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 'none' attestation or synced passkeys (BE=1) for enterprise-tier hardware authentication) 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