JWT and JOSE Token Profile Contract Design
Designs secure JWT token profiles: Ed25519/ES256 signing, claims validation, replay prevention, and JWKS key lifecycles.
$5
Works with the AI tools you already use
JWT and JOSE Token Profile Contract Design
Example session with this skill installed
Design the JWT and JOSE cryptographic token profile specification for our High-Throughput Merchant Payment Authorization API.
- Subject: merchant-payment-api v3.0 (run-id: payment-jwt-001) authenticating stateless API access across 450 enterprise retail merchants.
- Deciders: Lead Application Security Architect (David O'Reilly) and Principal API Platform Lead (Marcus Vance).
- Traffic & Scale: Peak 6,500 token verifications/sec; p99 validation latency <= 2.5 ms; token payload size ceiling <= 800 bytes.
- Tension: Squad proposed symmetric HS256 shared secrets with 24-hour expiration and full user permissions in token body; David O'Reilly strictly forbids symmetric HS256 (citing incident SEC-4102 where a compromised backend service extracted the shared secret and forged payment tokens) and rejects 24-hour expiration. He mandates asymmetric Ed25519 (EdDSA) signing, a strict 15-minute access token lifespan, mandatory iss, sub, aud, exp, jti claims verification, public key distribution via cached JWKS, and Redis-backed JTI replay defense.
Write the JWT token contract specification under docs/.
- Read your context and instructions
- Compiled the jwt and jose
- Generated the UI component
Wrote docs/architecture/tasks/payment-jwt-001/jwt-design/jwt-token-contract.md. Complete JWT and JOSE token profile contract establishing Ed25519 cryptographic signing, strict claims validation, 15-minute token expiry, and JWKS public key distribution.
---
skill: jwt-design
---
# JWT & JOSE Token Profile Contract: Merchant Payment API [JWT-PAY-001]
## Summary
This specification establishes the JSON Web Token (JWT) cryptographic profile, JOSE header constraints, claims schema, and key rotation architecture for `merchant-payment-api v3.0` under run ID `payment-jwt-001`, authenticating 6,500 peak requests/second across 450 enterprise merchant integrations. It decisively resolves the catastrophic key compromise and token forgery vulnerabilities demonstrated in incident SEC-4102 (where a single compromised microservice extracted a symmetric HS256 secret and forged payment authorizations for arbitrary tenants). The contract enforces an asymmetric **Ed25519 (EdDSA)** signature standard, restricts access token lifespan to exactly **15 minutes** (900 seconds), enforces mandatory validation for `iss`, `sub`, `aud`, `exp`, and `jti` claims, distributes public verification keys via cached JWKS endpoints, and defends against token replay via distributed Redis JTI tracking.
## Detailed Description
Relying on symmetric shared secrets (HS256) for distributed microservice authentication forces every consumer service to hold the master signing key. If any downstream service is compromised via remote code execution, attackers extract the shared secret and forge arbitrary tokens across the entire estate. Furthermore, long-lived 24-hour tokens cannot be revoked efficiently without maintaining expensive centralized state for every transaction.
Merchant Client Request (6,500 TPS via HTTPS)
│
▼ (Bearer JWT in Authorization Header)
[ Ingress Gateway / Envoy API Proxy ]
├── 1. JOSE Header Gate: Alg == "EdDSA", Crv == "Ed25519", Typ == "JWT"
│ (Rejects "none", HS256, RS256 algorithm confusion attempts)
├── 2. Cryptographic Signature Validation against Cached JWKS Key
├── 3. Standard Claims Validation:
│ ├── Issuer == "https://auth.payment.bank.internal"
│ ├── Audience == "https://api.payment.bank.internal/v3"
│ └── Expiry: Current_Epoch <= exp (Max 900s life)
└── 4. Replay Defense: Checks Redis JTI Blacklist (Latency <= 0.8ms)
│
┌─────────────┴─────────────┐
▼ (Valid Token) ▼ (Invalid Signature / Expired / Replayed)
Pass to Payment Core:8080 HTTP 401 Unauthorized: ERR_JWT_VERIFICATION_FAILED
### Criteria and weights
| Criterion | Why it matters here | Weight | Source of the weight |
|---|---|---|---|
| Asymmetric Key Isolation (Zero Signing Key Exposure) | Downstream verifying microservices must only possess public keys, preventing token forgery (SEC-4102). | 0.40 | David O'Reilly (CISO SecOps) |
| Validation Latency Overhead (p99 <= 2.5 ms) | Cryptographic signature checks sit in the critical payment path across 6,500 TPS. | 0.25 | Marcus Vance (Principal API Lead) |
| Replay Prevention & Bounded Blast Radius (15m Exp) | Stolen tokens must self-expire in 15 minutes, limiting exposure without requiring massive revocation tables. | 0.20 | PCI-DSS Security Compliance |
| Compact Token Size (<= 800 Bytes) | Small payload size minimizes network header serialization overhead across distributed hops. | 0.15 | Network Platform Policy |
### Comparison
| JWT Profile Candidate | Cryptographic Algorithm | Key Exposure Model | Token Lifespan | Verification Overhead | Evaluation |
|---|---|---|---|---|---|
| Option A: Symmetric HS256 (Legacy) | HMAC-SHA256 | Shared secret in all 45 services | 24 Hours | 0.4 ms | Rejected: Caused SEC-4102 master token forgery disaster. |
| Option B: Asymmetric RSA-2048 (RS256) | RSA-SHA256 | Asymmetric (Public key only) | 1 Hour | 3.8 ms | Rejected: Breaches 2.5 ms latency budget; large signature size. |
| Option C: Edwards-Curve Ed25519 (Chosen) | EdDSA (Curve25519) | Asymmetric (Public key only) | 15 Minutes | 0.9 ms | Selected: Highly secure, ultra-compact (64-byte sig), sub-ms speed. |
### Result
Option C is selected. Ed25519 provides modern asymmetric security, immune to algorithm confusion attacks, with sub-millisecond CPU verification latency.
---
### Required Mechanisms
#### 1. JOSE Header & Cryptographic Contract [MC-JH-01]
- **Enforced JOSE Header**:
```json
```json
{
"alg": "EdDSA",
"crv": "Ed25519",
"typ": "JWT",
"kid": "bank-auth-2026-q3-key1"
}
- **Strict Prohibition Invariants**:
- `alg: "none"`: Instantly rejected by gateway parsers; generates security alarm.
- Symmetric algorithms (`HS256`, `HS384`, `HS512`): Blocked at gateway; verifying services refuse to load symmetric keys.
- RSA algorithms (`RS256`, `PS256`): Disabled to prevent algorithm switching attacks.
#### 2. Standard Claims Schema & Payload Constraints [MC-CS-01]
- **Mandatory Registered Claims**:
- `iss`: `"https://auth.payment.bank.internal"` (Exact string match).
- `sub`: Subject identifier (e.g. `"merch_corp_881920"`).
- `aud`: `"https://api.payment.bank.internal/v3"` (Target service audience).
- `exp`: Expiration epoch seconds. Strictly bounded to <= 900 seconds from `iat`.
- `nbf`: Not before epoch seconds.
- `iat`: Issued at epoch seconds.
- `jti`: Universally Unique Identifier (UUIDv4) identifying the token instance.
- **Custom Claims**:
- `org_id`: Enterprise organization ID.
- `scope`: Space-delimited string (e.g. `"payments:read payments:write"`).
- **Payload Size Ceiling**: Total unencoded JWT token string must not exceed **800 bytes**.
#### 3. Public Key Distribution (JWKS) & Key Rotation [MC-KD-01]
- Verifying services fetch public keys from internal endpoint: `https://auth.payment.bank.internal/.well-known/jwks.json`.
- **Key Rotation Protocol**:
- Keys rotate every **90 days**.
- During rotation, JWKS publishes both current key ($N$) and previous key ($N-1$) for a 48-hour overlap window to ensure in-flight tokens validate seamlessly.
- Gateways cache JWKS in memory with a 1-hour TTL and refresh asynchronously in the background.
#### 4. Replay Defense & JTI Tracking [MC-RP-01]
- Critical high-value transactions evaluate the `jti` claim against a distributed Redis cluster:
- Key: `jwt:blacklist:{jti}` with TTL matching remaining token lifespan (<= 900 seconds).
- If a token is revoked or explicitly logged out, its `jti` is inserted into Redis in < 1 ms.
- Verification check: If `EXISTS jwt:blacklist:{jti} == 1`, request is rejected immediately with HTTP 401.
---
### Invariants and Contracts
Mandatory Ed25519 Asymmetric Verification [INV-JWT-01]
Tokens must be signed with EdDSA (Ed25519). Verifying microservices must possess public keys exclusively.
Symmetric shared-secret verification (HS256) is strictly prohibited in distributed environments.
Strict Fifteen-Minute Token Lifetime Ceiling [INV-JWT-02]
Stateless access token expiration (`exp - iat`) must not exceed 900 seconds (15 minutes).
Tokens declaring lifetimes exceeding 15 minutes fail gateway admission checks.
Mandatory Audience & Issuer Binding [INV-JWT-03]
Verifiers must strictly assert that `iss` matches the authoritative authentication server and
`aud` matches the target API gateway. Tokens with mismatched audience claims are rejected.
## Explicit Unknowns
- Redis cluster memory scaling requirements when tracking 50,000 revoked JTIs during coordinated credential resets (G-1).
- Hardware security module (HSM) signing throughput ceiling when issuing 10,000 Ed25519 tokens/second during morning login spikes (G-2).
## Traceability
| Claim | Classification | Source | Freshness |
|---|---|---|---|
| Peak 6,500 token verifications/sec | provided | Traffic intake | Current |
| 450 enterprise retail merchants | provided | Commercial scope | Current |
| Incident SEC-4102 HS256 token forgery | provided | Post-mortem evidence | Historical |
| Latency budget p99 <= 2.5 ms | provided | Performance SLA | Current |
| Ed25519 (EdDSA) asymmetric standard | decided | David O'Reilly & Marcus Vance | 2026-09-15 |
| 15-minute maximum token lifetime | decided | Architectural invariant INV-JWT-02 | 2026-09-15 |
## Verification
No validator was supplied, so no command was run.
Reviewer self-check against JWT architecture standards:
- **Algorithm Hardening**: PASS. Restricts to EdDSA Ed25519; blocks algorithm confusion attacks.
- **Claims Rigor**: PASS. Enforces `iss`, `sub`, `aud`, `exp` (<= 900s), and `jti` validation.
- **Latency Performance**: PASS. Ed25519 signature checks verify in < 1 ms, well within the 2.5 ms budget.
- **Markdown Hygiene**: PASS. Native Markdown syntax strictly adheres to `rule_markdown.md`.
## Open Decisions
- `DEC-JWT-01`: David O'Reilly to determine whether Mutual-TLS Client Certificate-Bound Access Tokens (RFC 8705) should be mandated for Tier-1 banking partners (Owner: David O'Reilly).
## Next steps
1. David O'Reilly provisions Ed25519 root signing keys in AWS KMS / HashiCorp Vault.
2. Platform team embeds Ed25519 validation and JWKS caching middleware in API gateway clusters.
3. Conduct staging penetration test injecting forged HS256 and `alg: "none"` tokens to verify automated gateway rejection.
jwt-and-jose-token-profile-contract-desi.tsx
TSX · React component
Example file from a real run - the skill writes it into your workspace.
Connects securely to your tools. The creator never sees your data.
What you get
About this skill
What it does
This skill maps an already-authorized JWT use into an exact issuance/validation profile. It defines token kind and purpose, JOSE processing, claims, trust/key selection, temporal validity, replay/revocation, privacy and compatibility independently of implementation libraries.
Use it when
Use when selected JWT producers/consumers require a precise interoperable token profile and validation/lifecycle contract.
For example: “A contractor was removed on Monday and still accessed the admin console on Tuesday. Our tokens last 24 hours and we thought disabling the account was enough.”
What you get
- JWT Security Spec
Written as Markdown to <your output folder>/architecture/tasks/<run-id>/jwt-design/.
What it will not do
Do not use for choosing JWT versus opaque/session credentials, designing OAuth/OIDC flows, authorization policy, enterprise IAM or key architecture, issuing tokens, one middleware/validator implementation, penetration testing or debugging.
How it works
- Check a token is the right carrier.
- Fix the audience and issuer per token type.
- Put in the claims a verifier needs and nothing more.
- Choose the algorithm and pin it at verification.
- Set lifetime against the revocation story you actually have.
- Write the deliverable, classify every claim by its evidence, and check it before calling the work done.
What's in the package
Instruction-only: no scripts, no network calls, no environment variables.
- LICENSE.txt
- SKILL.md
- agents/openai.yaml
- assets/output-template-task.md
- references/domain-rules.md
- references/operating-rules.md
- references/output-contract.md
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean 12 days ago
- Passed all security checks, Safe to install