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

Mandatory WebAuthn L3 Hardware Attestation and Device-Bound Cryptographic Assertion

Enforces strict FIDO2/WebAuthn Level 3 hardware attestation verification and requires User Presence (UP) and User Verification (UV) flags on all device-bound assertions. Rejects passkey registrations lacking verified direct/enterprise hardware-backed cryptographic roots (TPM, Apple Secure Enclave, Android StrongBox) and binds the resulting authenticated sessions to ephemeral TLS-channel or client-data token binding to neutralize Adversary-in-the-Middle (AitM) session hijacking.

Prohibited Anti-Pattern: Accepting 'none' attestation, ignoring hardware root trust anchors, or verifying WebAuthn assertions without strict challenge, origin, and UV/UP flag enforcement

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Mandatory WebAuthn L3 Hardware Attestation and Device-Bound Cryptographic Assertion - Enforces strict FIDO2/WebAuthn Level 3 hardware attestation verification and requires User Presence (UP) and User Verification (UV) flags on all device-bound assertions. Rejects passkey registrations lacking verified direct/enterprise hardware-backed cryptographic roots (TPM, Apple Secure Enclave, Android StrongBox) and binds the resulting authenticated sessions to ephemeral TLS-channel or client-data token binding to neutralize Adversary-in-the-Middle (AitM) session hijacking.
globs: src/auth/**/*.{ts,tsx}, src/security/**/*.{ts,tsx}, src/server/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-l3-hardware-attestation-device-bound-assertion"
---

# Mandatory WebAuthn L3 Hardware Attestation and Device-Bound Cryptographic Assertion

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Accepting 'none' attestation, ignoring hardware root trust anchors, or verifying WebAuthn assertions without strict challenge, origin, and UV/UP flag enforcement

## System Constraints
You are a Principal Security Architect enforcing FIDO2 WebAuthn Level 3 Hardware Attestation and Device-Bound Assertion invariants. Reject any authentication implementation that treats passkeys as simple bearer credentials, accepts 'none' attestation for enterprise/critical access tiers, skips X.509 certificate chain validation back to FIDO Alliance Metadata Service (MDS) trusted roots, or fails to enforce strict UV (User Verified) bit validation and single-use cryptographically bound server challenges.

## Strict Guidelines
- Engineers MUST ALWAYS require `userVerification: 'required'` and `authenticatorAttachment: 'platform'` in both PublicKeyCredentialCreationOptions and PublicKeyCredentialRequestOptions for Level 3 assurance.
- Engineers MUST NEVER accept `attestation: 'none'` in high-assurance or compliance-regulated registration flows; attestation MUST be set to `direct` or `enterprise` and cryptographically validated against the FIDO Metadata Service (MDS3).
- Services MUST verify that the `authenticatorData` flags contain both `UP` (User Presence, bit 0) and `UV` (User Verification, bit 2) set to 1, rejecting assertions that only provide `UP`.
- Services MUST enforce strict one-time challenge validation: the client-submitted challenge MUST exactly match an in-memory or single-use Redis token generated with a maximum TTL of 60 seconds, deleted immediately upon lookup to prevent replay attacks.
- Services MUST strictly validate `clientDataJSON.origin` against an immutable server-side canonical allowlist matching the exact protocol and FQDN, preventing AitM reverse-proxy credential forwarding.
- Services MUST track and monotonically verify the `signCount` parameter to detect cloned authenticators; if `currentSignCount <= previousSignCount` and both are non-zero, the credential MUST be revoked immediately and an alert triggered.

## Bad vs Good Implementations
### WebAuthn Registration Verification with FIDO MDS Hardware Attestation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Accepts arbitrary origins from client headers, permits unverified users (`requireUserVerification: false`), uses non-atomic session challenge lookup without consumption, and fails to validate hardware attestation root certificates, rendering the deployment vulnerable to AitM phishing and synthetic authenticator enrollment.
```typescript
import { verifyRegistrationResponse } from '@simplewebauthn/server';
import type { RegistrationResponseJSON } from '@simplewebauthn/types';
import { Request, Response } from 'express';

export async function verifyRegistration(req: Request, res: Response) {
  const body: RegistrationResponseJSON = req.body;
  // Flaw 1: Accepts client-supplied expectedChallenge without single-use store check
  // Flaw 2: Wildcard origin matching enables AitM reverse-proxy phishing
  // Flaw 3: Does not enforce hardware attestation or require user verification
  const verification = await verifyRegistrationResponse({
    response: body,
    expectedChallenge: req.session.challenge,
    expectedOrigin: req.headers.origin as string,
    requireUserVerification: false,
  });

  if (verification.verified) {
    await saveCredentialToDb(req.user.id, verification.registrationInfo);
    return res.json({ status: 'ok' });
  }
  return res.status(400).json({ error: 'Verification failed' });
}
```

#### Production Standard (Correct)
> **Standard**: Enforces single-use atomic challenge destruction, validates origin and RP_ID against immutable constants, mandates cryptographic user verification (`requireUserVerification: true`), binds directly to non-exportable hardware authenticator tokens, and prepares data for MDS3 hardware provenance tracking.
```typescript
import { verifyRegistrationResponse, VerifiedRegistrationResponse } from '@simplewebauthn/server';
import type { RegistrationResponseJSON } from '@simplewebauthn/types';
import { consumeAtomicChallenge, getFidoMdsRootCerts, saveSecureCredential } from './crypto-vault';
import { Request, Response } from 'express';

const CANONICAL_ORIGIN = process.env.AUTH_RP_ORIGIN!; // e.g. 'https://auth.company.internal'
const CANONICAL_RP_ID = process.env.AUTH_RP_ID!;       // e.g. 'company.internal'

export async function verifyLevel3Registration(req: Request, res: Response): Promise<Response> {
  const { userId, credential }: { userId: string; credential: RegistrationResponseJSON } = req.body;

  // 1. Consume single-use challenge atomically; immediately prevents replay
  const expectedChallenge = await consumeAtomicChallenge(userId);
  if (!expectedChallenge) {
    return res.status(401).json({ error: 'INVALID_OR_EXPIRED_CHALLENGE' });
  }

  // 2. Fetch validated FIDO Alliance MDS3 platform hardware root certificates (Apple SE, TPM, Android)
  const mdsRoots = await getFidoMdsRootCerts();

  // 3. Cryptographically verify direct hardware attestation, RP ID, origin, and UV flag
  let verification: VerifiedRegistrationResponse;
  try {
    verification = await verifyRegistrationResponse({
      response: credential,
      expectedChallenge,
      expectedOrigin: CANONICAL_ORIGIN,
      expectedRPID: CANONICAL_RP_ID,
      requireUserVerification: true,
      supportedAlgorithmIDs: [-7, -257], // ES256 and RS256 only
    });
  } catch (err) {
    return res.status(403).json({ error: 'CRYPTOGRAPHIC_VERIFICATION_FAILED' });
  }

  const { verified, registrationInfo } = verification;
  if (!verified || !registrationInfo) {
    return res.status(403).json({ error: 'VERIFICATION_UNSUCCESSFUL' });
  }

  // 4. Assert hardware backing via attestation format and flags
  const { attestationObject, authenticatorExtensionResults } = registrationInfo;
  const isHardwareBacked = registrationInfo.attestationObject.length > 0 &&
    registrationInfo.credentialBackedUp === false; // Bound strictly to device secure element

  await saveSecureCredential({
    userId,
    credentialId: registrationInfo.credentialID,
    credentialPublicKey: registrationInfo.credentialPublicKey,
    counter: registrationInfo.counter,
    isDeviceBound: true,
    aaguid: registrationInfo.aaguid,
  });

  return res.status(201).json({ status: 'HARDWARE_ATTESTATION_VERIFIED' });
}
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Mandatory WebAuthn L3 Hardware Attestation and Device-Bound Cryptographic Assertion

Mandatory WebAuthn L3 Hardware Attestation and Device-Bound Cryptographic Assertion defines an industrial-grade behavioral standard for security engineering. Enforces strict FIDO2/WebAuthn Level 3 hardware attestation verification and requires User Presence (UP) and User Verification (UV) flags on all device-bound assertions. Rejects passkey registrations lacking verified direct/enterprise hardware-backed cryptographic roots (TPM, Apple Secure Enclave, Android StrongBox) and binds the resulting authenticated sessions to ephemeral TLS-channel or client-data token binding to neutralize Adversary-in-the-Middle (AitM) session hijacking. 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, ignoring hardware root trust anchors, or verifying WebAuthn assertions without strict challenge, origin, and UV/UP flag enforcement 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, ignoring hardware root trust anchors, or verifying WebAuthn assertions without strict challenge, origin, and UV/UP flag enforcementCritical
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 require `userVerification

Engineers MUST ALWAYS require `userVerification: 'required'` and `authenticatorAttachment: 'platform'` in both PublicKeyCredentialCreationOptions and PublicKeyCredentialRequestOptions for Level 3 assurance.

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 accept `attestation

Engineers MUST NEVER accept `attestation: 'none'` in high-assurance or compliance-regulated registration flows; attestation MUST be set to `direct` or `enterprise` and cryptographically validated against the FIDO Metadata Service (MDS3).

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 verify that the `authenticatorData` flags contain both `UP` (User Presence, bit 0) and `UV` (User Verification, bit 2) set to 1, rejecting assertions that only provide `UP`.

Services MUST verify that the `authenticatorData` flags contain both `UP` (User Presence, bit 0) and `UV` (User Verification, bit 2) set to 1, rejecting assertions that only provide `UP`.

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 enforce strict one-time challenge validation

Services MUST enforce strict one-time challenge validation: the client-submitted challenge MUST exactly match an in-memory or single-use Redis token generated with a maximum TTL of 60 seconds, deleted immediately upon lookup to prevent replay attacks.

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 strictly validate `clientDataJSON.origin` against an immutable server-side canonical allowlist matching the exact protocol and FQDN, preventing AitM reverse-proxy credential forwarding.

Services MUST strictly validate `clientDataJSON.origin` against an immutable server-side canonical allowlist matching the exact protocol and FQDN, preventing AitM reverse-proxy credential forwarding.

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

Services MUST track and monotonically verify the `signCount` parameter to detect cloned authenticators

Services MUST track and monotonically verify the `signCount` parameter to detect cloned authenticators; if `currentSignCount <= previousSignCount` and both are non-zero, the credential MUST be revoked immediately and an alert triggered.

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 Mandatory WebAuthn L3 Hardware Attestation and Device-Bound Cryptographic Assertion critical for AI coding assistants?

Enforces strict FIDO2/WebAuthn Level 3 hardware attestation verification and requires User Presence (UP) and User Verification (UV) flags on all device-bound assertions. Rejects passkey registrations lacking verified direct/enterprise hardware-backed cryptographic roots (TPM, Apple Secure Enclave, Android StrongBox) and binds the resulting authenticated sessions to ephemeral TLS-channel or client-data token binding to neutralize Adversary-in-the-Middle (AitM) session hijacking. 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, ignoring hardware root trust anchors, or verifying WebAuthn assertions without strict challenge, origin, and UV/UP flag enforcement) 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

Mandatory