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

WebAuthn Level 3 Device Public Key (DPK) Enclave Binding Guardrail

Enforces strict parsing, cryptographic verification, and hardware-binding persistence of WebAuthn Level 3 Device Public Key (DPK) extension outputs. Eliminates multi-device passkey cloning vulnerabilities across synced cloud keychains (e.g., Apple iCloud Keychain, Google Password Manager) by requiring unexportable physical hardware-backed cryptographic proof of origin per assertion.

Prohibited Anti-Pattern: Accepting Synced Multi-Device Passkeys Without Hardware-Bound Device Public Key (DPK) Verification

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: WebAuthn Level 3 Device Public Key (DPK) Enclave Binding Guardrail - Enforces strict parsing, cryptographic verification, and hardware-binding persistence of WebAuthn Level 3 Device Public Key (DPK) extension outputs. Eliminates multi-device passkey cloning vulnerabilities across synced cloud keychains (e.g., Apple iCloud Keychain, Google Password Manager) by requiring unexportable physical hardware-backed cryptographic proof of origin per assertion.
globs: src/auth/**/*.{ts,tsx}, src/security/**/*.{ts,tsx}, src/server/auth/**/*.{ts,tsx}, server/api/auth/**/*.{ts,tsx}, lib/webauthn/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/webauthn-l3-device-public-key-guardrail"
---

# WebAuthn Level 3 Device Public Key (DPK) Enclave Binding Guardrail

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Accepting Synced Multi-Device Passkeys Without Hardware-Bound Device Public Key (DPK) Verification

## System Constraints
You are a Principal Security Architect enforcing the WebAuthn Level 3 Device Public Key (DPK) Attestation Signature Guardrail. Multi-device syncable passkeys provide credential availability at the expense of device isolation. To prevent unauthorized device proliferation and token cloning across synced cloud keychains, you must mandate the WebAuthn Level 3 `devicePubKey` extension across both registration and authentication ceremonies. Never permit an assertion for a high-assurance credential to pass verification without cryptographically proving possession of the unexportable hardware-bound Device Public Key (DPK).

## Strict Guidelines
- Engineers MUST ALWAYS request the `devicePubKey` extension in WebAuthn registration and authentication server options (`extensions: { devicePubKey: { attestation: 'direct' } }`).
- Engineers MUST ALWAYS extract and cryptographically verify the DPK signature (`dpkSig`) over the canonical concatenation of `authenticatorData` and `clientDataHash` using the registered hardware DPK.
- Engineers MUST NOT permit passkey authentication to succeed if the enrolled credential was tagged with high-assurance/device-bound requirements but omits the `devicePubKey` extension in the assertion response.
- Services MUST index and store the Device Public Key (`dpk`), its unique device identifier (`dpkHash`), and the credential ID in a 1:N or M:N relational structure to track multiple authorized hardware enclaves per synced credential.
- Components NEVER assume `credentialId` uniqueness proves physical possession of the original enrolling hardware device.

## Bad vs Good Implementations
### Verifying WebAuthn L3 Device Public Key (DPK) Extension Signature

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The implementation performs basic WebAuthn assertion verification without demanding or validating the WebAuthn L3 `devicePubKey` extension. A cloned or synced passkey on an untrusted secondary device satisfies this check, completely bypassing hardware enclave residency controls.
```typescript
import { verifyAuthenticationResponse } from '@simplewebauthn/server';
import type { AuthenticationResponseJSON } from '@simplewebauthn/types';

export async function verifyPasskeyAssertion(
  response: AuthenticationResponseJSON,
  expectedChallenge: string,
  storedCredential: { publicKey: Uint8Array; counter: number }
) {
  // VULNERABLE: Only verifies the multi-device passkey signature.
  // If the passkey was synced to an unauthorized personal device via cloud keychain,
  // this verification succeeds without proving physical device enclave residency.
  const verification = await verifyAuthenticationResponse({
    response,
    expectedChallenge,
    expectedOrigin: 'https://auth.enterprise.internal',
    expectedRPID: 'enterprise.internal',
    authenticator: {
      credentialPublicKey: storedCredential.publicKey,
      credentialID: response.id,
      counter: storedCredential.counter,
    },
  });

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

  return { verified: true, deviceId: null };
}
```

#### Production Standard (Correct)
> **Standard**: The production implementation strictly enforces WebAuthn Level 3 DPK verification. It extracts the raw `devicePubKey` extension from authenticator output, calculates the canonical `authenticatorData || clientDataHash` digest, looks up the enrolled physical device enclave key, and cryptographically verifies the hardware-bound signature. Any attempt to use a cloned or cloud-synced passkey on an unauthorized machine is immediately rejected.
```typescript
import crypto from 'node:crypto';
import { decode } from 'cbor-x';
import { verifyAuthenticationResponse } from '@simplewebauthn/server';
import type { AuthenticationResponseJSON } from '@simplewebauthn/types';

interface StoredDeviceKey {
  rawDpk: Uint8Array;
  algorithm: number; // COSE algorithm ID, e.g., -7 (ES256)
  revoked: boolean;
}

interface DpkExtensionOutput {
  dpk: Uint8Array;
  dpkSig: Uint8Array;
  nonce?: Uint8Array;
}

export async function verifyDeviceBoundPasskeyAssertion(
  response: AuthenticationResponseJSON,
  expectedChallenge: string,
  storedCredential: { publicKey: Uint8Array; counter: number },
  storedDevices: Map<string, StoredDeviceKey>
) {
  // 1. Primary WebAuthn assertion verification
  const verification = await verifyAuthenticationResponse({
    response,
    expectedChallenge,
    expectedOrigin: 'https://auth.enterprise.internal',
    expectedRPID: 'enterprise.internal',
    authenticator: {
      credentialPublicKey: storedCredential.publicKey,
      credentialID: response.id,
      counter: storedCredential.counter,
    },
  });

  if (!verification.verified || !verification.authenticationInfo) {
    throw new SecurityError('Base WebAuthn assertion rejected');
  }

  // 2. Decode Authenticator Data and extract WebAuthn L3 `devicePubKey` extension
  const clientExtensionResults = response.clientExtensionResults as Record<string, unknown>;
  const dpkResult = clientExtensionResults?.devicePubKey as DpkExtensionOutput | undefined;

  if (!dpkResult || !dpkResult.dpkSig) {
    throw new SecurityError('WebAuthn L3 DPK guardrail failed: Missing mandatory devicePubKey extension');
  }

  const authDataBuffer = Buffer.from(response.response.authenticatorData, 'base64url');
  const clientDataHash = crypto
    .createHash('sha256')
    .update(Buffer.from(response.response.clientDataJSON, 'base64url'))
    .digest();

  // 3. Compute canonical signature payload: authenticatorData || clientDataHash
  const signedPayload = Buffer.concat([authDataBuffer, clientDataHash]);
  const dpkFingerprint = crypto.createHash('sha256').update(dpkResult.dpk).digest('hex');

  const enrolledDevice = storedDevices.get(dpkFingerprint);
  if (!enrolledDevice || enrolledDevice.revoked) {
    throw new SecurityError(`Unenrolled or revoked hardware enclave device: ${dpkFingerprint}`);
  }

  // 4. Verify cryptographic signature from the hardware enclave DPK
  const coseKey = decode(dpkResult.dpk);
  const keyObject = crypto.createPublicKey({ key: coseKey, format: 'jwk' });
  const isDpkValid = crypto.verify(null, signedPayload, keyObject, dpkResult.dpkSig);

  if (!isDpkValid) {
    throw new SecurityError('Invalid DPK attestation signature: Device enclave residency check failed');
  }

  return {
    verified: true,
    deviceId: dpkFingerprint,
    newCounter: verification.authenticationInfo.newCounter,
  };
}
```

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 Device Public Key (DPK) Enclave Binding Guardrail

WebAuthn Level 3 Device Public Key (DPK) Enclave Binding Guardrail defines an industrial-grade behavioral standard for security engineering. Enforces strict parsing, cryptographic verification, and hardware-binding persistence of WebAuthn Level 3 Device Public Key (DPK) extension outputs. Eliminates multi-device passkey cloning vulnerabilities across synced cloud keychains (e.g., Apple iCloud Keychain, Google Password Manager) by requiring unexportable physical hardware-backed cryptographic proof of origin per assertion. 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 Multi-Device Passkeys Without Hardware-Bound Device Public Key (DPK) 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 DriftAccepting Synced Multi-Device Passkeys Without Hardware-Bound Device Public Key (DPK) 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

Engineers MUST ALWAYS request the `devicePubKey` extension in WebAuthn registration and authentication server options (`extensions

Engineers MUST ALWAYS request the `devicePubKey` extension in WebAuthn registration and authentication server options (`extensions: { devicePubKey: { attestation: 'direct' } }`).

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 ALWAYS extract and cryptographically verify the DPK signature (`dpkSig`) over the canonical concatenation of `authenticatorData` and `clientDataHash` using the registered hardware DPK.

Engineers MUST ALWAYS extract and cryptographically verify the DPK signature (`dpkSig`) over the canonical concatenation of `authenticatorData` and `clientDataHash` using the registered hardware DPK.

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 NOT permit passkey authentication to succeed if the enrolled credential was tagged with high-assurance/device-bound requirements but omits the `devicePubKey` extension in the assertion response.

Engineers MUST NOT permit passkey authentication to succeed if the enrolled credential was tagged with high-assurance/device-bound requirements but omits the `devicePubKey` extension in the assertion response.

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 index and store the Device Public Key (`dpk`), its unique device identifier (`dpkHash`), and the credential ID in a 1

Services MUST index and store the Device Public Key (`dpk`), its unique device identifier (`dpkHash`), and the credential ID in a 1:N or M:N relational structure to track multiple authorized hardware enclaves per synced 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.
5

Components NEVER assume `credentialId` uniqueness proves physical possession of the original enrolling hardware device.

Components NEVER assume `credentialId` uniqueness proves physical possession of the original enrolling hardware device.

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 Device Public Key (DPK) Enclave Binding Guardrail critical for AI coding assistants?

Enforces strict parsing, cryptographic verification, and hardware-binding persistence of WebAuthn Level 3 Device Public Key (DPK) extension outputs. Eliminates multi-device passkey cloning vulnerabilities across synced cloud keychains (e.g., Apple iCloud Keychain, Google Password Manager) by requiring unexportable physical hardware-backed cryptographic proof of origin per assertion. 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 Multi-Device Passkeys Without Hardware-Bound Device Public Key (DPK) 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