This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: w3c-dbsc-session-binding-guardrail-w3c-device-bound-219

W3C Device Bound Session Credentials (DBSC) TPM/Enclave Invariant Standard

Enforces strict server-side validation and client-side lifecycle management for W3C Device Bound Session Credentials (DBSC). Protects against session hijacking, adversary-in-the-middle (AitM) attacks, and malware infostealer cookie exfiltration by cryptographically binding HTTP session cookies to a public key anchored in the device's hardware security module (TPM or Apple Secure Enclave). Requires rigorous verification of session challenge-response JWT proofs, short-lived cookie lifetimes, and atomic session termination upon signature or challenge mismatch.

Prohibited Anti-Pattern: Bearer-Only Session Issuance Without Hardware Proof of Possession Verification

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: W3C Device Bound Session Credentials (DBSC) TPM/Enclave Invariant Standard - Enforces strict server-side validation and client-side lifecycle management for W3C Device Bound Session Credentials (DBSC). Protects against session hijacking, adversary-in-the-middle (AitM) attacks, and malware infostealer cookie exfiltration by cryptographically binding HTTP session cookies to a public key anchored in the device's hardware security module (TPM or Apple Secure Enclave). Requires rigorous verification of session challenge-response JWT proofs, short-lived cookie lifetimes, and atomic session termination upon signature or challenge mismatch.
globs: src/auth/**/*.{ts,tsx,js,jsx}, src/middleware/**/*.{ts,tsx,js,jsx}, src/security/**/*.{ts,tsx,js,jsx}, src/server/**/*.{ts,tsx,js,jsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/w3c-dbsc-session-binding-guardrail-w3c-device-bound-219"
---

# W3C Device Bound Session Credentials (DBSC) TPM/Enclave Invariant Standard

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Bearer-Only Session Issuance Without Hardware Proof of Possession Verification

## System Constraints
You are a Principal Security Architect enforcing the W3C Device Bound Session Credentials (DBSC) protocol specification. Never allow authentication flows to rely solely on bearer session identifiers or cookies that lack cryptographic hardware proofs. Mandate that session initialization, challenge refreshing, and session continuity check the hardware-bound asymmetric key pair via TPM 2.0 or Secure Enclave signature proofs. Enforce strict server-side replay prevention via single-use challenges, short challenge TTLs, and cryptographic freshness checks.

## Strict Guidelines
- Services MUST emit the `Sec-Session-Challenge` header when establishing or refreshing sessions, mandating the client response with a valid proof-of-possession JWT.
- Engineers MUST validate the client signature (`Sec-Session-Response`) using the enrolled hardware public key (RSASSA-PKCS1-v1_5 or ECDSA P-256) registered during the DBSC handshake.
- Services MUST invalidate and terminate the underlying session immediately if a session cookie is presented with a missing, malformed, or cryptographically invalid DBSC challenge response.
- Engineers MUST set short time-to-live (TTL) limits (maximum 120 seconds) on DBSC challenge tokens, binding each challenge nonce to an atomic, single-use, cryptographically secure redis or distributed cache entry.
- Services MUST associate device-bound cookies strictly with `SameSite=None; Secure; HttpOnly` attributes while pinning the `session_id` directly to the enrolled public key identifier in persistent storage.
- Components NEVER accept DBSC session proof tokens containing software-exported private keys; the cryptographic keys MUST be confirmed non-exportable and bound to hardware attestation during enrollment.

## Bad vs Good Implementations
### Verifying DBSC Session Proof vs Bearer Cookie Verification

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Accepting the session token without validating the W3C DBSC hardware-bound signature leaves users vulnerable to Infostealer malware and cookie exfiltration attacks, allowing attackers to replay the stolen session on an unbound remote machine.
```typescript
import { Request, Response, NextFunction } from 'express';
import jwt from 'jsonwebtoken';

export async function authenticateSession(req: Request, res: Response, next: NextFunction) {
  const sessionCookie = req.cookies['session_token'];
  if (!sessionCookie) {
    return res.status(401).json({ error: 'Missing session cookie' });
  }

  try {
    // INSECURE: Relies strictly on bearer session token without hardware binding proof.
    // Malware extracting this cookie can impersonate the user from an arbitrary device.
    const payload = jwt.verify(sessionCookie, process.env.JWT_SECRET as string) as { sessionId: string };
    req.user = { sessionId: payload.sessionId };
    next();
  } catch (err) {
    return res.status(401).json({ error: 'Invalid session' });
  }
}
```

#### Production Standard (Correct)
> **Standard**: Implements the W3C DBSC specification: ensures incoming requests present a cryptographically verified JWT (`Sec-Session-Response`) signed by the client's non-exportable hardware key (TPM/Secure Enclave), validates single-use challenge nonces, and immediately invalidates the session upon signature failure.
```typescript
import { Request, Response, NextFunction } from 'express';
import crypto from 'node:crypto';
import * as jose from 'jose';
import { sessionStore } from './sessionStore';

export async function authenticateSession(req: Request, res: Response, next: NextFunction) {
  const sessionId = req.cookies['dbsc_session_id'];
  const dbscProof = req.header('Sec-Session-Response');

  if (!sessionId) {
    return res.status(401).json({ error: 'Missing session token' });
  }

  const session = await sessionStore.findById(sessionId);
  if (!session || !session.publicKeyPem) {
    return res.status(401).json({ error: 'Session binding not found' });
  }

  // DBSC requires cryptographic hardware proof verification
  if (!dbscProof) {
    const newChallenge = crypto.randomBytes(32).toString('base64url');
    await sessionStore.setPendingChallenge(session.id, newChallenge, 120);
    res.setHeader('Sec-Session-Challenge', `"${newChallenge}"; id="${session.id}"`);
    return res.status(401).json({ error: 'Hardware session proof required' });
  }

  try {
    const publicKey = await jose.importSPKI(session.publicKeyPem, 'ES256');
    const { payload } = await jose.jwtVerify(dbscProof, publicKey, {
      algorithms: ['ES256', 'RS256'],
    });

    const expectedChallenge = await sessionStore.consumePendingChallenge(session.id);
    if (!expectedChallenge || payload.nonce !== expectedChallenge) {
      // Atomic revocation upon challenge replay or mismatch
      await sessionStore.revoke(session.id);
      return res.status(403).json({ error: 'DBSC proof invalid or expired nonce' });
    }

    req.user = { id: session.userId, sessionId: session.id };
    next();
  } catch (err) {
    await sessionStore.revoke(session.id);
    return res.status(401).json({ error: 'DBSC hardware signature verification failed' });
  }
}
```

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: W3C Device Bound Session Credentials (DBSC) TPM/Enclave Invariant Standard

W3C Device Bound Session Credentials (DBSC) TPM/Enclave Invariant Standard defines an industrial-grade behavioral standard for security engineering. Enforces strict server-side validation and client-side lifecycle management for W3C Device Bound Session Credentials (DBSC). Protects against session hijacking, adversary-in-the-middle (AitM) attacks, and malware infostealer cookie exfiltration by cryptographically binding HTTP session cookies to a public key anchored in the device's hardware security module (TPM or Apple Secure Enclave). Requires rigorous verification of session challenge-response JWT proofs, short-lived cookie lifetimes, and atomic session termination upon signature or challenge mismatch. 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: Bearer-Only Session Issuance Without Hardware Proof of Possession 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 DriftBearer-Only Session Issuance Without Hardware Proof of Possession 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

Services MUST emit the `Sec-Session-Challenge` header when establishing or refreshing sessions, mandating the client response with a valid proof-of-possession JWT.

Services MUST emit the `Sec-Session-Challenge` header when establishing or refreshing sessions, mandating the client response with a valid proof-of-possession JWT.

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 validate the client signature (`Sec-Session-Response`) using the enrolled hardware public key (RSASSA-PKCS1-v1_5 or ECDSA P-256) registered during the DBSC handshake.

Engineers MUST validate the client signature (`Sec-Session-Response`) using the enrolled hardware public key (RSASSA-PKCS1-v1_5 or ECDSA P-256) registered during the DBSC handshake.

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 invalidate and terminate the underlying session immediately if a session cookie is presented with a missing, malformed, or cryptographically invalid DBSC challenge response.

Services MUST invalidate and terminate the underlying session immediately if a session cookie is presented with a missing, malformed, or cryptographically invalid DBSC challenge 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

Engineers MUST set short time-to-live (TTL) limits (maximum 120 seconds) on DBSC challenge tokens, binding each challenge nonce to an atomic, single-use, cryptographically secure redis or distributed cache entry.

Engineers MUST set short time-to-live (TTL) limits (maximum 120 seconds) on DBSC challenge tokens, binding each challenge nonce to an atomic, single-use, cryptographically secure redis or distributed cache entry.

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 associate device-bound cookies strictly with `SameSite=None

Services MUST associate device-bound cookies strictly with `SameSite=None; Secure; HttpOnly` attributes while pinning the `session_id` directly to the enrolled public key identifier in persistent storage.

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 accept DBSC session proof tokens containing software-exported private keys

Components NEVER accept DBSC session proof tokens containing software-exported private keys; the cryptographic keys MUST be confirmed non-exportable and bound to hardware attestation during enrollment.

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 W3C Device Bound Session Credentials (DBSC) TPM/Enclave Invariant Standard critical for AI coding assistants?

Enforces strict server-side validation and client-side lifecycle management for W3C Device Bound Session Credentials (DBSC). Protects against session hijacking, adversary-in-the-middle (AitM) attacks, and malware infostealer cookie exfiltration by cryptographically binding HTTP session cookies to a public key anchored in the device's hardware security module (TPM or Apple Secure Enclave). Requires rigorous verification of session challenge-response JWT proofs, short-lived cookie lifetimes, and atomic session termination upon signature or challenge mismatch. 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 (Bearer-Only Session Issuance Without Hardware Proof of Possession 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

W3C