CVE-2022-25647

7.7 HIGH

📋 TL;DR

CVE-2022-25647 is a deserialization vulnerability in Google's Gson library versions before 2.8.9. Attackers can exploit the writeReplace() method in internal classes to cause denial of service (DoS) attacks by triggering infinite recursion or resource exhaustion. This affects any Java application using vulnerable Gson versions for JSON processing.

💻 Affected Systems

Products:
  • Google Gson library
Versions: All versions before 2.8.9
Operating Systems: All platforms running Java applications
Default Config Vulnerable: ⚠️ Yes
Notes: Any Java application using Gson for JSON serialization/deserialization is vulnerable by default when using affected versions.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete application unavailability due to resource exhaustion, potentially crashing the JVM and requiring service restart.

🟠

Likely Case

Application performance degradation or temporary unavailability from DoS attacks, disrupting service for legitimate users.

🟢

If Mitigated

Minimal impact with proper input validation and resource limits, though some performance degradation may occur.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Exploitation requires sending malicious JSON payloads to applications using Gson. The vulnerability is well-documented in the GitHub pull request.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 2.8.9 and later

Vendor Advisory: https://github.com/google/gson/pull/1991

Restart Required: Yes

Instructions:

1. Update Gson dependency to version 2.8.9 or later in your build configuration (Maven, Gradle, etc.). 2. Rebuild and redeploy your application. 3. Restart affected services.

🔧 Temporary Workarounds

Input validation and sanitization

all

Implement strict input validation to reject unexpected JSON structures before Gson processing

Resource limiting

all

Configure JVM memory limits and implement circuit breakers to prevent resource exhaustion

java -Xmx512m -Xss256k -jar yourapp.jar

🧯 If You Can't Patch

  • Implement network-level protections like WAF rules to block suspicious JSON payloads
  • Isolate vulnerable applications in segmented network zones with strict access controls

🔍 How to Verify

Check if Vulnerable:

Check your project's dependency files (pom.xml, build.gradle) for Gson version <2.8.9

Check Version:

mvn dependency:tree | grep gson OR gradle dependencies | grep gson

Verify Fix Applied:

Verify Gson version is 2.8.9 or higher in dependency files and deployed application

📡 Detection & Monitoring

Log Indicators:

  • StackOverflowError in logs
  • OutOfMemoryError related to Gson processing
  • Unusually high CPU/memory usage during JSON parsing

Network Indicators:

  • Large or deeply nested JSON payloads to endpoints using Gson
  • Repeated JSON requests causing service degradation

SIEM Query:

source="application.logs" AND ("StackOverflowError" OR "OutOfMemoryError") AND "gson"

🔗 References

📤 Share & Export