This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: rfc-8693-workload-token-downscoping-invariant

RFC 8693 Token Exchange: Mandatory Audience and Scope Attenuation at Inter-Service Hops

Enforces cryptographic audience, scope, and lifetime downscoping at every distributed microservice boundary using RFC 8693 OAuth 2.0 Token Exchange. Prevents lateral ambient authority and confused deputy vulnerabilities by strictly forbidding the propagation of unmodified upstream bearer tokens across service hops.

Prohibited Anti-Pattern: Ambient Authority Propagation via Direct Upstream Bearer Token Forwarding

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: RFC 8693 Token Exchange: Mandatory Audience and Scope Attenuation at Inter-Service Hops - Enforces cryptographic audience, scope, and lifetime downscoping at every distributed microservice boundary using RFC 8693 OAuth 2.0 Token Exchange. Prevents lateral ambient authority and confused deputy vulnerabilities by strictly forbidding the propagation of unmodified upstream bearer tokens across service hops.
globs: src/**/clients/**/*.{ts,js,py,go}, src/**/middleware/**/*.{ts,js,py,go}, src/**/services/**/*.{ts,js,py,go}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/rfc-8693-workload-token-downscoping-invariant"
---

# RFC 8693 Token Exchange: Mandatory Audience and Scope Attenuation at Inter-Service Hops

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Ambient Authority Propagation via Direct Upstream Bearer Token Forwarding

## System Constraints
You are a Principal Security Architect enforcing zero-trust invariants in microservice architectures. Under no circumstances may an AI agent or engineer forward an incoming HTTP Authorization bearer token directly to a downstream internal microservice. All inter-service calls that execute on behalf of an incoming identity MUST use RFC 8693 OAuth 2.0 Token Exchange to obtain an attenuated token. The exchanged token MUST strictly narrow the audience ('aud') to the single downstream recipient, reduce scopes to the minimal required subset, and clamp maximum token expiration (TTL) to the downstream transaction window.

## Strict Guidelines
- Services MUST NEVER forward unmodified incoming HTTP Authorization bearer tokens directly to downstream dependencies.
- Engineers MUST ALWAYS execute an RFC 8693 token exchange (grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange') before dispatching outbound requests on behalf of a caller.
- The downstream request token MUST restrict the 'audience' claim explicitly to the immediate downstream service's unique Service Principal Name (SPN) or URI.
- Downscoped token scopes MUST be a strict, monotonic mathematical subset of the incoming token scopes.
- Token lifetime (exp) for the downscoped token MUST be attenuated to the minimal operational window (e.g., <= 60 seconds).
- If the incoming token cannot satisfy the required sub-scope or audience boundary, the service MUST reject the request immediately with an HTTP 403 Forbidden.
- Outbound clients MUST preserve the delegation chain audit trail by populating the 'actor_token' parameter during token exchange when transitively delegating authority.

## Bad vs Good Implementations
### Downstream Service Call Attenuation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Forwarding the incoming caller's bearer token directly creates ambient authority across the call graph. A compromised downstream service can reuse this wide-scoped token to call other administrative or internal services on behalf of the user.
```typescript
import axios from 'axios';
import { Request, Response } from 'express';

export async function handleOrderCreation(req: Request, res: Response) {
  // VULNERABLE: Direct bearer token forwarding retains wide scope and broad audience
  // Allows Inventory Service to laterally impersonate caller against Billing or Identity
  const inventoryResponse = await axios.post(
    'https://inventory.internal.net/v1/reserve',
    req.body.items,
    {
      headers: {
        Authorization: req.headers.authorization,
      },
    }
  );
  return res.json(inventoryResponse.data);
}
```

#### Production Standard (Correct)
> **Standard**: Implements RFC 8693 token exchange. The outbound request carries an ephemeral access token restricted exclusively to 'https://inventory.internal.net', constrained to the single scope 'inventory:reserve', with a TTL bounded to 30 seconds.
```typescript
import axios from 'axios';
import { Request, Response } from 'express';
import { exchangeToken } from '../auth/tokenExchange';

const INVENTORY_AUDIENCE = 'https://inventory.internal.net';
const INVENTORY_REQUIRED_SCOPE = 'inventory:reserve';

export async function handleOrderCreation(req: Request, res: Response) {
  const subjectToken = req.headers.authorization?.replace(/^Bearer\s+/i, '');
  if (!subjectToken) {
    return res.status(401).json({ error: 'Missing bearer authorization' });
  }

  // INVARIANT: Exchange and downscope audience, scope, and lifetime per RFC 8693
  const downscopedToken = await exchangeToken({
    subjectToken,
    subjectTokenType: 'urn:ietf:params:oauth:token-type:access_token',
    audience: INVENTORY_AUDIENCE,
    scope: INVENTORY_REQUIRED_SCOPE,
    expiresInSeconds: 30,
  });

  const inventoryResponse = await axios.post(
    `${INVENTORY_AUDIENCE}/v1/reserve`,
    req.body.items,
    {
      headers: {
        Authorization: `Bearer ${downscopedToken}`,
      },
    }
  );
  return res.json(inventoryResponse.data);
}
```

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: RFC 8693 Token Exchange: Mandatory Audience and Scope Attenuation at Inter-Service Hops

RFC 8693 Token Exchange: Mandatory Audience and Scope Attenuation at Inter-Service Hops defines an industrial-grade behavioral standard for security engineering. Enforces cryptographic audience, scope, and lifetime downscoping at every distributed microservice boundary using RFC 8693 OAuth 2.0 Token Exchange. Prevents lateral ambient authority and confused deputy vulnerabilities by strictly forbidding the propagation of unmodified upstream bearer tokens across service hops. 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: Ambient Authority Propagation via Direct Upstream Bearer Token Forwarding 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 DriftAmbient Authority Propagation via Direct Upstream Bearer Token ForwardingCritical
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 NEVER forward unmodified incoming HTTP Authorization bearer tokens directly to downstream dependencies.

Services MUST NEVER forward unmodified incoming HTTP Authorization bearer tokens directly to downstream dependencies.

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 execute an RFC 8693 token exchange (grant_type

Engineers MUST ALWAYS execute an RFC 8693 token exchange (grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange') before dispatching outbound requests on behalf of a caller.

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

The downstream request token MUST restrict the 'audience' claim explicitly to the immediate downstream service's unique Service Principal Name (SPN) or URI.

The downstream request token MUST restrict the 'audience' claim explicitly to the immediate downstream service's unique Service Principal Name (SPN) or URI.

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

Downscoped token scopes MUST be a strict, monotonic mathematical subset of the incoming token scopes.

Downscoped token scopes MUST be a strict, monotonic mathematical subset of the incoming token scopes.

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

Token lifetime (exp) for the downscoped token MUST be attenuated to the minimal operational window (e.g., <= 60 seconds).

Token lifetime (exp) for the downscoped token MUST be attenuated to the minimal operational window (e.g., <= 60 seconds).

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

If the incoming token cannot satisfy the required sub-scope or audience boundary, the service MUST reject the request immediately with an HTTP 403 Forbidden.

If the incoming token cannot satisfy the required sub-scope or audience boundary, the service MUST reject the request immediately with an HTTP 403 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.
7

Outbound clients MUST preserve the delegation chain audit trail by populating the 'actor_token' parameter during token exchange when transitively delegating authority.

Outbound clients MUST preserve the delegation chain audit trail by populating the 'actor_token' parameter during token exchange when transitively delegating authority.

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 RFC 8693 Token Exchange: Mandatory Audience and Scope Attenuation at Inter-Service Hops critical for AI coding assistants?

Enforces cryptographic audience, scope, and lifetime downscoping at every distributed microservice boundary using RFC 8693 OAuth 2.0 Token Exchange. Prevents lateral ambient authority and confused deputy vulnerabilities by strictly forbidding the propagation of unmodified upstream bearer tokens across service hops. 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 (Ambient Authority Propagation via Direct Upstream Bearer Token Forwarding) 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

RFC