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

推荐订阅源

雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
D
Docker
Martin Fowler
Martin Fowler
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
M
MIT News - Artificial intelligence
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale
Vercel News
Vercel News
The Cloudflare Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
I
InfoQ
U
Unit 42

Feed

React 19 Performance Optimizations You Need to Know Tesla Recalls 2.2 Million Vehicles Over Autopilot Software Bug Creating Interactive Prototypes in Figma with Smart Animate OpenAI Introduces GPT-4 Turbo with Vision API Building AI-Powered React Components with Vercel AI SDK Figma Introduces AI-Powered Design System Generator The Rise of Local-First Software Development GitHub Copilot Usage Surpasses 1.8 Million Paid Users Building Responsive Layouts with CSS Container Queries Supabase Launches Real-time Multiplayer Engine The Hidden Cost of Technical Debt in Startup Engineering Figma Launches Dev Mode 2.0 with Code Generation Why SaaS Companies Are Moving Away from Microservices Building Faster APIs with Bun and Elysia
Major Security Flaw Discovered in Popular JWT Libraries
Sarah Kim · 2024-07-22 · via Feed
Security

Critical vulnerability in jsonwebtoken and jose libraries affects millions of applications. Attackers can bypass authentication by exploiting algorithm confusion attacks

Major Security Flaw Discovered in Popular JWT Libraries

A critical security vulnerability has been discovered in two of the most widely-used JWT libraries: jsonwebtoken (npm) and jose (npm), collectively downloaded over 50 million times per week. The flaw allows attackers to completely bypass authentication systems.

The Vulnerability Explained

The issue stems from algorithm confusion attacks where malicious actors can manipulate JWT tokens to use weaker signing algorithms than intended.

How it works:

  1. Application expects RS256 (RSA with SHA-256)
  2. Attacker modifies token header to use HS256 (HMAC with SHA-256)
  3. Attacker signs token using the public key as HMAC secret
  4. Server validates token successfully, granting unauthorized access

Affected Versions

jsonwebtoken library:

  • Versions 8.0.0 through 9.0.1
  • Over 25 million weekly downloads

jose library:

  • Versions 4.0.0 through 4.14.5
  • Over 8 million weekly downloads

This vulnerability has been assigned CVE-2024-28176 with a CVSS score of 9.8 (Critical). Proof-of-concept exploits are already circulating on security forums.

Real-World Impact

Security researchers have identified vulnerable implementations in:

  • E-commerce platforms handling payment processing
  • Healthcare applications with patient data access
  • Financial services with account management systems
  • Enterprise SaaS platforms with multi-tenant architectures

Technical Details:

// Vulnerable code pattern
const jwt = require('jsonwebtoken');

// BAD: Allows algorithm to be specified in token
jwt.verify(token, publicKey);

// GOOD: Explicitly specify expected algorithm  
jwt.verify(token, publicKey, { algorithms: ['RS256'] });

The vulnerability occurs when developers don't explicitly specify which algorithms are allowed during token verification.


Check Your Dependencies

Run this command to identify vulnerable versions:

npm audit
# or
yarn audit

Look for these specific packages in your dependency tree:

  • jsonwebtoken < 9.0.2
  • jose < 4.15.0

Update Immediately

# Update jsonwebtoken
npm install jsonwebtoken@latest

# Update jose  
npm install jose@latest

💡

Both libraries released patched versions within 6 hours of disclosure. The fixes are backward-compatible and require no code changes for most implementations.

Verify Your Implementation

Ensure your JWT verification explicitly specifies allowed algorithms:

// jsonwebtoken - SECURE
jwt.verify(token, secret, { 
  algorithms: ['RS256'] // Explicitly allow only RS256
});

// jose - SECURE  
await jwtVerify(token, publicKey, {
  algorithms: ['RS256']
});

Additional Security Measures

  • Rotate signing keys if you suspect compromise
  • Review authentication logs for suspicious activity
  • Implement token expiration (short-lived tokens reduce risk)
  • Add rate limiting to authentication endpoints
  • Monitor for unusual login patterns
  • Consider implementing token blacklisting

Industry Response

Major cloud providers have already begun updating their services:

  • AWS Cognito: Patches deployed automatically
  • Auth0: Updates rolling out over 48 hours
  • Firebase Auth: Unaffected (uses different implementation)
  • Okta: Patches applied to all tenants
"This vulnerability demonstrates why security-by-default is crucial in authentication libraries. Developers shouldn't have to remember to specify secure algorithms - it should be the default behavior."
- OWASP Security Researcher

This incident highlights the critical importance of secure defaults in authentication libraries. While the patches are available, the speed of exploitation attempts suggests this vulnerability is being actively targeted.