CVE-2020-15694

7.5 HIGH

📋 TL;DR

This vulnerability in Nim's standard library httpClient allows malicious servers to provide negative Content-Length values, which the client fails to validate properly. This can lead to memory corruption, denial of service, or potentially arbitrary code execution. Applications using Nim's httpClient to fetch data from untrusted sources are affected.

💻 Affected Systems

Products:
  • Nim programming language standard library
Versions: Nim 1.2.4 and earlier versions
Operating Systems: All platforms where Nim runs
Default Config Vulnerable: ⚠️ Yes
Notes: Only applications using the httpClient module's contentLength() method or similar response parsing are vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution through memory corruption when processing malformed server responses, potentially allowing full system compromise.

🟠

Likely Case

Denial of service through application crashes or resource exhaustion when processing invalid Content-Length values.

🟢

If Mitigated

Application instability or crashes without privilege escalation if proper sandboxing and input validation are in place.

🌐 Internet-Facing: HIGH - Applications fetching data from external servers are directly exposed to malicious responses.
🏢 Internal Only: MEDIUM - Internal services could still be vulnerable if they fetch data from compromised internal servers.

🎯 Exploit Status

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

Exploitation requires controlling the server response or intercepting client-server communication. Public proof-of-concept demonstrates the vulnerability.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Nim 1.2.6 and later

Vendor Advisory: https://nim-lang.org/blog/2020/07/30/versions-126-and-108-released.html

Restart Required: No

Instructions:

1. Update Nim to version 1.2.6 or later. 2. Recompile all applications using the httpClient module. 3. Redeploy updated applications.

🔧 Temporary Workarounds

Input validation wrapper

all

Add custom validation for Content-Length values before processing

# In Nim code, add validation:
let contentLen = client.get().contentLength()
if contentLen < 0:
    raise newException(ValueError, "Invalid Content-Length")

Use alternative HTTP library

all

Replace httpClient with a third-party HTTP library that properly validates responses

# Add alternative HTTP library via Nimble:
nimble install httpbeast

🧯 If You Can't Patch

  • Implement network segmentation to restrict httpClient access to trusted servers only
  • Deploy web application firewalls to inspect and block malicious server responses

🔍 How to Verify

Check if Vulnerable:

Check if application uses Nim's httpClient module and runs on Nim <=1.2.4

Check Version:

nim --version

Verify Fix Applied:

Verify Nim version is >=1.2.6 and test with negative Content-Length responses

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with memory access violations
  • Unusual Content-Length values in HTTP logs

Network Indicators:

  • HTTP responses with negative Content-Length headers
  • Unusual traffic patterns to/from Nim applications

SIEM Query:

source="http_logs" AND content_length < 0

🔗 References

📤 Share & Export