CVE-2022-1642

7.5 HIGH

📋 TL;DR

A type mismatch vulnerability in Swift's JSONDecoder can cause deterministic crashes when processing malicious JSON documents with floating-point values where integers are expected. This affects Swift-based web applications using swift-corelibs-foundation on Linux and Windows systems. The vulnerability allows denial of service attacks by crashing application endpoints.

💻 Affected Systems

Products:
  • Swift applications using swift-corelibs-foundation JSONDecoder
Versions: Swift versions before 5.6.2 for Linux and Windows
Operating Systems: Linux, Windows
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects Linux and Windows Swift implementations. Darwin-based systems (macOS, iOS, etc.) are not affected. Applications must use JSONDecoder with Codable types expecting integer values.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete service unavailability through repeated crashes, potentially triggering cascading failures in dependent systems or violating service invariants.

🟠

Likely Case

Denial of service affecting specific endpoints that process JSON input, requiring service restarts and causing temporary downtime.

🟢

If Mitigated

No impact if patched or if using unaffected platforms (Darwin-based systems).

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Exploitation requires sending crafted JSON to vulnerable endpoints. The advisory includes technical details that make creating exploits straightforward.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Swift 5.6.2 for Linux and Windows

Vendor Advisory: https://github.com/apple/swift-corelibs-foundation/security/advisories/GHSA-239c-6cv2-wwx8

Restart Required: Yes

Instructions:

1. Update Swift toolchain to version 5.6.2 or later. 2. Recompile all affected Swift applications. 3. Redeploy updated applications to production.

🔧 Temporary Workarounds

Input validation wrapper

all

Implement custom JSON parsing with validation to reject floating-point values for integer fields before passing to JSONDecoder

Web application firewall rules

all

Block requests containing JSON with floating-point values in fields expected to be integers

🧯 If You Can't Patch

  • Implement rate limiting on JSON-processing endpoints to reduce DoS impact
  • Deploy redundant services with load balancers to maintain availability during attacks

🔍 How to Verify

Check if Vulnerable:

Check if application uses Swift JSONDecoder with Codable types on Linux/Windows and Swift version is below 5.6.2

Check Version:

swift --version

Verify Fix Applied:

Verify Swift version is 5.6.2 or later and test with crafted JSON containing floating-point values in integer fields

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with abort() calls
  • Repeated failed requests to JSON endpoints
  • Error logs mentioning type mismatch or JSON decoding failures

Network Indicators:

  • HTTP requests with JSON containing floating-point values in fields typically expecting integers
  • Sudden spikes in 500 errors from JSON endpoints

SIEM Query:

source="application.logs" AND ("abort" OR "JSONDecoder" OR "type mismatch") AND status=500

🔗 References

📤 Share & Export