CVE-2022-25851

7.5 HIGH

📋 TL;DR

CVE-2022-25851 is a denial-of-service vulnerability in jpeg-js library where specially crafted JPEG images cause infinite processing loops, consuming all available CPU resources. This affects any application using vulnerable versions of jpeg-js for JPEG image processing, particularly web applications and services that process user-uploaded images.

💻 Affected Systems

Products:
  • jpeg-js
  • applications using jpeg-js library
Versions: All versions before 0.4.4
Operating Systems: All platforms running Node.js
Default Config Vulnerable: ⚠️ Yes
Notes: Any application that processes JPEG images using jpeg-js is vulnerable

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete service unavailability due to CPU exhaustion, potentially affecting multiple services on shared infrastructure

🟠

Likely Case

Degraded performance or temporary unavailability of image processing functionality

🟢

If Mitigated

Minimal impact with proper input validation and resource limits

🌐 Internet-Facing: HIGH - User-uploaded images are common attack vector
🏢 Internal Only: MEDIUM - Internal users could still trigger DoS

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploit requires only a malicious JPEG file; trivial to weaponize

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 0.4.4 and later

Vendor Advisory: https://github.com/jpeg-js/jpeg-js/security/advisories/GHSA-4j6c-4wq9-5q49

Restart Required: Yes

Instructions:

1. Update package.json to require jpeg-js >=0.4.4
2. Run 'npm update jpeg-js' or 'yarn upgrade jpeg-js'
3. Restart all affected applications

🔧 Temporary Workarounds

Input validation and size limits

all

Implement strict validation of JPEG files before processing

// JavaScript example: validate file size and type before processing

Process timeout

all

Set timeout limits for image processing operations

// Use setTimeout or process timeouts in your image processing code

🧯 If You Can't Patch

  • Implement strict file upload restrictions and validation
  • Deploy resource monitoring and automatic restart for hung processes

🔍 How to Verify

Check if Vulnerable:

Check package.json or run 'npm list jpeg-js' to see installed version

Check Version:

npm list jpeg-js | grep jpeg-js

Verify Fix Applied:

Confirm version is 0.4.4 or higher with 'npm list jpeg-js'

📡 Detection & Monitoring

Log Indicators:

  • High CPU usage spikes
  • Process timeouts in image processing
  • Repeated process restarts

Network Indicators:

  • Increased uploads of JPEG files
  • Service degradation after image uploads

SIEM Query:

source="application" AND ("CPU usage" > 90% OR "timeout" OR "image processing")

🔗 References

📤 Share & Export