This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: fido2-device-public-key-tpm-attestation-standard

FIDO2 Device Public Key (DPK) Hardware-Bound Attestation Invariant

Enforces cryptographic binding of WebAuthn passkey assertion ceremonies to physical endpoint hardware state using the W3C devicePubKey extension and TPM/Secure Enclave attestation. Prevents enterprise compromise from synced passkey exfiltration across unmanaged personal devices by validating hardware-rooted device identity on every authentication ceremony.

Prohibited Anti-Pattern: Trusting Synced Multi-Device Passkeys Without Hardware-Bound Device Public Key Validation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: FIDO2 Device Public Key (DPK) Hardware-Bound Attestation Invariant - Enforces cryptographic binding of WebAuthn passkey assertion ceremonies to physical endpoint hardware state using the W3C devicePubKey extension and TPM/Secure Enclave attestation. Prevents enterprise compromise from synced passkey exfiltration across unmanaged personal devices by validating hardware-rooted device identity on every authentication ceremony.
globs: src/auth/**/*.ts, src/security/**/*.ts, src/webauthn/**/*.ts, server/auth/**/*.ts
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/fido2-device-public-key-tpm-attestation-standard"
---

# FIDO2 Device Public Key (DPK) Hardware-Bound Attestation Invariant

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Trusting Synced Multi-Device Passkeys Without Hardware-Bound Device Public Key Validation

## System Constraints
You are a Principal Security Architect enforcing the W3C FIDO2 Device Public Key (DPK) Hardware-Bound Attestation Protocol. You must mandate that WebAuthn assertion verification routines cryptographically validate the devicePubKey extension, verify the hardware attestation chain (TPM 2.0 / Apple SE / Android KeyMint) against enterprise trust anchors, and confirm the secondary signature over the assertion payload before granting enterprise authorization.

## Strict Guidelines
- Engineers MUST ALWAYS extract, parse, and cryptographically verify the `devicePubKey` extension (`dpk`, `dpkSig`, and `attStmt`) during WebAuthn assertion ceremonies for enterprise-tier authentication.
- Engineers MUST NOT issue authorization tokens or enterprise session cookies based solely on standard passkey assertion validation without verifying physical hardware binding.
- Code SHOULD verify the DPK attestation certificate chain against enterprise-approved hardware roots of trust (e.g., TPM Endorsement Key Root CAs) to confirm execution on a managed fleet asset.
- Services MUST verify that `dpkSig` cryptographically signs the binary concatenation of `authenticatorData` and SHA-256 `clientDataHash` using the enrolled hardware-bound public key.
- Components NEVER accept authentication requests where the recovered `dpk` identifier diverges from the device-to-credential mapping registered in the managed device inventory database.

## Bad vs Good Implementations
### Verifying WebAuthn Passkey Assertions with Hardware-Bound DPK and TPM Attestation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The handler validates standard WebAuthn assertions but completely ignores the devicePubKey extension. Synced multi-device passkeys synced to unmanaged personal devices bypass enterprise zero-trust controls because no physical TPM/Secure Enclave signature or attestation is validated.
```typescript
import { verifyAuthenticationResponse } from '@simplewebauthn/server';
import type { AuthenticationResponseJSON } from '@simplewebauthn/types';

interface SessionUser {
  id: string;
  currentChallenge: string;
  devices: Array<{ credentialID: Uint8Array; credentialPublicKey: Uint8Array; counter: number }>;
}

export async function authenticateEnterpriseUser(
  response: AuthenticationResponseJSON,
  user: SessionUser
): Promise<{ success: boolean }> {
  const matchingPasskey = user.devices.find(
    (d) => Buffer.from(d.credentialID).toString('base64url') === response.id
  );

  if (!matchingPasskey) {
    throw new Error('Credential not found');
  }

  // VULNERABLE: Only verifies the primary passkey credential signature.
  // If the passkey was synced to a non-compliant personal device (e.g., iCloud Keychain,
  // Google Password Manager), this authentication succeeds without hardware verification.
  const verification = await verifyAuthenticationResponse({
    response,
    expectedChallenge: user.currentChallenge,
    expectedOrigin: 'https://fleet.enterprise.internal',
    expectedRPID: 'enterprise.internal',
    authenticator: {
      credentialID: matchingPasskey.credentialID,
      credentialPublicKey: matchingPasskey.credentialPublicKey,
      counter: matchingPasskey.counter,
    },
  });

  if (!verification.verified) {
    throw new Error('Assertion failed');
  }

  return { success: true };
}
```

#### Production Standard (Correct)
> **Standard**: Extracts the devicePubKey extension, verifies that the physical TPM key (`dpk`) cryptographically signed the concatenation of `authenticatorData` and `clientDataHash` via `dpkSig`, verifies the hardware attestation chain against trusted TPM roots, and strictly confirms that the hardware key matches the enrolled enterprise device inventory ID.
```typescript
import { verifyAuthenticationResponse } from '@simplewebauthn/server';
import type { AuthenticationResponseJSON } from '@simplewebauthn/types';
import { createHash, verify } from 'node:crypto';
import { decodeCbor } from './cbor-utils';
import { verifyTpmAttestationRoot } from './tpm-trust-store';

interface ManagedFleetDevice {
  credentialID: Uint8Array;
  credentialPublicKey: Uint8Array;
  counter: number;
  expectedDpkId: string;
}

interface SessionUser {
  id: string;
  currentChallenge: string;
  managedDevice: ManagedFleetDevice;
}

interface DpkExtensionOutput {
  dpk: Uint8Array;
  dpkSig: Uint8Array;
  attStmt?: Record<string, unknown>;
  fmt?: string;
}

export async function authenticateEnterpriseUser(
  response: AuthenticationResponseJSON,
  user: SessionUser
): Promise<{ success: boolean }> {
  const managedDevice = user.managedDevice;

  // 1. Standard Passkey Signature Verification
  const verification = await verifyAuthenticationResponse({
    response,
    expectedChallenge: user.currentChallenge,
    expectedOrigin: 'https://fleet.enterprise.internal',
    expectedRPID: 'enterprise.internal',
    authenticator: {
      credentialID: managedDevice.credentialID,
      credentialPublicKey: managedDevice.credentialPublicKey,
      counter: managedDevice.counter,
    },
  });

  if (!verification.verified || !verification.authenticationInfo) {
    throw new Error('WebAuthn primary assertion failed');
  }

  // 2. Extract and Validate Device Public Key (DPK) Extension
  const clientExtensions = response.response.clientExtensionResults as Record<string, unknown>;
  const authenticatorExtensionsRaw = verification.authenticationInfo.authenticatorExtensionResults;
  const dpkExtension = (clientExtensions?.devicePubKey ??
    authenticatorExtensionsRaw?.devicePubKey) as DpkExtensionOutput | undefined;

  if (!dpkExtension?.dpk || !dpkExtension?.dpkSig) {
    throw new Error('Zero-Trust Policy Violation: Missing required hardware devicePubKey (DPK)');
  }

  const { dpk, dpkSig, attStmt, fmt } = dpkExtension;

  // 3. Cryptographically bind DPK signature: signs (authenticatorData || clientDataHash)
  const rawAuthData = Buffer.from(response.response.authenticatorData, 'base64url');
  const clientDataHash = createHash('sha256')
    .update(Buffer.from(response.response.clientDataJSON, 'base64url'))
    .digest();
  const signedPayload = Buffer.concat([rawAuthData, clientDataHash]);

  const isDpkSigValid = verify(
    'SHA256',
    signedPayload,
    { key: Buffer.from(dpk), format: 'der', type: 'spki' },
    Buffer.from(dpkSig)
  );

  if (!isDpkSigValid) {
    throw new Error('Cryptographic failure: DPK secondary signature mismatch');
  }

  // 4. Assert Device Binding Identity & Validate TPM Hardware Attestation
  const computedDpkId = createHash('sha256').update(dpk).digest('base64url');
  if (computedDpkId !== managedDevice.expectedDpkId) {
    throw new Error('Device authorization rejected: Passkey asserted on unmanaged hardware');
  }

  if (fmt && attStmt) {
    const isHardwareRootValid = await verifyTpmAttestationRoot(fmt, attStmt, dpk);
    if (!isHardwareRootValid) {
      throw new Error('TPM hardware attestation root validation failed');
    }
  }

  return { success: true };
}
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: FIDO2 Device Public Key (DPK) Hardware-Bound Attestation Invariant

FIDO2 Device Public Key (DPK) Hardware-Bound Attestation Invariant defines an industrial-grade behavioral standard for security engineering. Enforces cryptographic binding of WebAuthn passkey assertion ceremonies to physical endpoint hardware state using the W3C devicePubKey extension and TPM/Secure Enclave attestation. Prevents enterprise compromise from synced passkey exfiltration across unmanaged personal devices by validating hardware-rooted device identity on every authentication ceremony. 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 Synced Multi-Device Passkeys Without Hardware-Bound Device Public Key Validation 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 Synced Multi-Device Passkeys Without Hardware-Bound Device Public Key ValidationCritical
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 extract, parse, and cryptographically verify the `devicePubKey` extension (`dpk`, `dpkSig`, and `attStmt`) during WebAuthn assertion ceremonies for enterprise-tier authentication.

Engineers MUST ALWAYS extract, parse, and cryptographically verify the `devicePubKey` extension (`dpk`, `dpkSig`, and `attStmt`) during WebAuthn assertion ceremonies for enterprise-tier authentication.

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 NOT issue authorization tokens or enterprise session cookies based solely on standard passkey assertion validation without verifying physical hardware binding.

Engineers MUST NOT issue authorization tokens or enterprise session cookies based solely on standard passkey assertion validation without verifying physical hardware binding.

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

Code SHOULD verify the DPK attestation certificate chain against enterprise-approved hardware roots of trust (e.g., TPM Endorsement Key Root CAs) to confirm execution on a managed fleet asset.

Code SHOULD verify the DPK attestation certificate chain against enterprise-approved hardware roots of trust (e.g., TPM Endorsement Key Root CAs) to confirm execution on a managed fleet asset.

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 verify that `dpkSig` cryptographically signs the binary concatenation of `authenticatorData` and SHA-256 `clientDataHash` using the enrolled hardware-bound public key.

Services MUST verify that `dpkSig` cryptographically signs the binary concatenation of `authenticatorData` and SHA-256 `clientDataHash` using the enrolled hardware-bound public key.

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

Components NEVER accept authentication requests where the recovered `dpk` identifier diverges from the device-to-credential mapping registered in the managed device inventory database.

Components NEVER accept authentication requests where the recovered `dpk` identifier diverges from the device-to-credential mapping registered in the managed device inventory database.

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 FIDO2 Device Public Key (DPK) Hardware-Bound Attestation Invariant critical for AI coding assistants?

Enforces cryptographic binding of WebAuthn passkey assertion ceremonies to physical endpoint hardware state using the W3C devicePubKey extension and TPM/Secure Enclave attestation. Prevents enterprise compromise from synced passkey exfiltration across unmanaged personal devices by validating hardware-rooted device identity on every authentication ceremony. 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 Synced Multi-Device Passkeys Without Hardware-Bound Device Public Key Validation) 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

FIDO2