惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
博客园 - 司徒正美
D
DataBreaches.Net
宝玉的分享
宝玉的分享
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 【当耐特】
人人都是产品经理
人人都是产品经理
博客园 - Franky
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
腾讯CDC
博客园_首页
The Cloudflare Blog
S
SegmentFault 最新的问题
C
Check Point Blog
美团技术团队
爱范儿
爱范儿
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
A
About on SuperTechFans
Blog — PlanetScale
Blog — PlanetScale

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
PASETO vs JWT: A Token Format That Removes the Footguns
Haven Messenger · 2026-06-19 · via DEV Community

Haven Messenger

JSON Web Tokens are everywhere, and most of their famous vulnerabilities trace back to a single design choice: the token tells the verifier which algorithm to use. PASETO was built by people who got tired of cleaning up after that decision. It is worth understanding even if you never adopt it — because it shows what a token format looks like when security is the default, not a configuration option.

A bearer token is a short string a client presents to prove it is allowed to do something. The server issued it, signed or encrypted it, and trusts it on sight because the cryptography says it has not been tampered with. JSON Web Tokens (JWT) are the dominant format for this, baked into OAuth, OpenID Connect, and countless session systems. PASETO — Platform-Agnostic Security Tokens — is a deliberate alternative, designed by Scott Arciszewski of the Paragon Initiative as a response to the recurring ways JWT implementations get broken.

The two formats solve the same problem. The difference is philosophy: JWT gives you a flexible cryptographic toolbox and trusts you to wield it safely. PASETO hands you exactly one safe option per version and refuses to let you negotiate.

The header is where JWT goes wrong

A JWT carries a header object that declares its own algorithm — {"alg": "RS256"}, for example. The verifier reads that field and uses the named algorithm to check the signature. This is the root of JWT's two most infamous attack classes.

The first is the "none" algorithm. The JWT spec includes alg: none for unsigned tokens. A naive verifier that honors the header will accept a token with no signature at all if an attacker sets alg to none and strips the signature. Whole authentication systems have been bypassed this way.

The second is algorithm confusion. Suppose a server verifies RS256 tokens using an RSA public key — which, being public, is not secret. An attacker changes the header to HS256 (HMAC) and signs the forged token using that public key as the HMAC secret. If the verifier sees HS256 and dutifully runs HMAC with its RSA public key as the key, the signature checks out. The public key was never meant to be a secret, but the token format let it become one.

The core lesson: Both attacks exist because the verifier lets the attacker-supplied token choose the verification algorithm. The cryptographic primitives are fine. The protocol around them hands control to the wrong party.

PASETO's answer: version and purpose, not negotiation

A PASETO looks like v4.public.<payload>.<optional-footer>. The two leading segments are not negotiable algorithm fields — they are a fixed version and a fixed purpose, and the cryptography for each is hard-coded into the library.

  • Version pins the entire cryptographic suite. There is no menu. A v4 token uses exactly the v4 primitives.
  • Purpose is either local (symmetric authenticated encryption with a shared secret key) or public (asymmetric digital signature, readable by anyone but forgeable by no one).

There is no none. There is no algorithm field for an attacker to rewrite. A v4 verifier configured to accept v4.public tokens will only ever run Ed25519 signature verification; it cannot be tricked into running HMAC because the format gives it nowhere to express that request.

What the versions actually use

PASETO defines paired versions so you can pick a NIST-friendly suite or a modern one:

Version local (encryption) public (signature)
v3 (NIST) AES-256-CTR + HMAC-SHA-384 ECDSA over P-384
v4 (modern) XChaCha20 + BLAKE2b keyed MAC Ed25519

The modern v4 suite is the recommended default for new systems. The NIST-based v3 exists for environments with compliance requirements that mandate FIPS-style algorithms. Older v1/v2 versions are deprecated in favor of these two.

Pre-authentication encoding closes the canonicalization gap

Even with a fixed algorithm, signature schemes can be undermined by ambiguity in what gets signed. If a token concatenates several fields before signing, an attacker who can shift a byte from one field into another may produce a different logical message with the same signed bytes — a canonicalization attack.

PASETO addresses this with Pre-Authentication Encoding (PAE): before signing or encrypting, every piece (header, payload, footer, and in v3/v4 an optional implicit assertion) is length-prefixed and packed unambiguously. The signature commits to the exact structure, not just a concatenation, so fields cannot be smuggled across boundaries.

The footer is authenticated but not encrypted — useful for data a verifier needs to read before decrypting, like a key identifier. Anything secret belongs in the payload, never the footer.

So should you switch?

Not reflexively. JWT is not broken when implemented correctly: pin the expected algorithm server-side, reject none, never let the token choose, and use a well-maintained library that does these things by default. Mature ecosystems — OAuth providers, identity platforms — speak JWT, and interoperability is a real constraint. PASETO has fewer libraries and less tooling around it.

PASETO earns its place when you control both ends of the system and want the secure path to be the only path. For internal service-to-service tokens, session tokens in a first-party app, or any greenfield design where you are not bound to an existing JWT consumer, it removes an entire category of misconfiguration. The point is not that PASETO programmers are smarter — it is that the format gives them less rope.

Either way: Tokens are bearer credentials: whoever holds one can use it. Keep lifetimes short, transmit only over TLS, store them where script injection cannot reach them, and have a revocation story. No token format fixes a stolen token.

Originally published at havenmessenger.com