CVE-2025-25186

6.5 MEDIUM

📋 TL;DR

This vulnerability in Ruby's Net::IMAP library allows a malicious IMAP server to cause denial of service through memory exhaustion. When a client connects to a malicious server, the server can send highly compressed uid-set data that causes the client's response parser to create excessively large arrays, consuming all available memory. This affects Ruby applications using net-imap versions 0.3.2 through 0.3.7, 0.4.0 through 0.4.18, and 0.5.0 through 0.5.5.

💻 Affected Systems

Products:
  • Ruby net-imap library
Versions: 0.3.2 through 0.3.7, 0.4.0 through 0.4.18, 0.5.0 through 0.5.5
Operating Systems: All operating systems running Ruby
Default Config Vulnerable: ⚠️ Yes
Notes: Any Ruby application using the vulnerable net-imap versions is affected when connecting to IMAP servers.

⚠️ Manual Verification Required

This CVE does not have specific version information in our database, so automatic vulnerability detection cannot determine if your system is affected.

Why? The CVE database entry doesn't specify which versions are vulnerable (no version ranges provided by the vendor/NVD).

🔒 Custom verification scripts are available for registered users. Sign up free to download automated test scripts.

Recommended Actions:
  1. Review the CVE details at NVD
  2. Check vendor security advisories for your specific version
  3. Test if the vulnerability is exploitable in your environment
  4. Consider updating to the latest version as a precaution

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete system memory exhaustion leading to application crash, service disruption, and potential system instability affecting other processes.

🟠

Likely Case

IMAP client application crashes or becomes unresponsive when connecting to a malicious server, disrupting email functionality.

🟢

If Mitigated

Minimal impact with proper patching or network controls preventing connections to untrusted IMAP servers.

🌐 Internet-Facing: MEDIUM - Risk exists when connecting to external IMAP servers, but requires a malicious server rather than client-side exploitation.
🏢 Internal Only: LOW - Internal IMAP servers are typically trusted, reducing attack surface unless compromised.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW - Malicious server simply needs to send specially crafted uid-set data.

Exploitation requires a malicious IMAP server that the client connects to, not client-side code execution.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 0.3.8, 0.4.19, 0.5.6 or higher

Vendor Advisory: https://github.com/ruby/net-imap/security/advisories/GHSA-7fc5-f82f-cx69

Restart Required: Yes

Instructions:

1. Update net-imap gem: `gem update net-imap` 2. Update Gemfile to specify patched version 3. Restart all Ruby applications using net-imap 4. Verify update with `gem list net-imap`

🔧 Temporary Workarounds

Network segmentation

all

Restrict IMAP client connections to trusted servers only

Gem version pinning

all

Pin net-imap to safe versions in Gemfile

gem 'net-imap', '>= 0.3.8', '< 0.4.0'
gem 'net-imap', '>= 0.4.19', '< 0.5.0'
gem 'net-imap', '>= 0.5.6'

🧯 If You Can't Patch

  • Implement network controls to only allow IMAP connections to trusted, verified servers
  • Monitor application memory usage and restart services if abnormal memory consumption is detected

🔍 How to Verify

Check if Vulnerable:

Check net-imap version with: `gem list net-imap` or `bundle show net-imap`

Check Version:

gem list net-imap

Verify Fix Applied:

Confirm version is 0.3.8+, 0.4.19+, or 0.5.6+ with: `gem list net-imap | grep -E '0\.(3\.([8-9]|\d{2,})|4\.(19|[2-9]\d)|5\.([6-9]|\d{2,}))'`

📡 Detection & Monitoring

Log Indicators:

  • Sudden application crashes
  • Out of memory errors in Ruby logs
  • IMAP connection failures

Network Indicators:

  • Connections to unknown or suspicious IMAP servers
  • Unusually large IMAP responses

SIEM Query:

source="ruby_app.log" AND ("out of memory" OR "MemoryError" OR "IMAP connection failed")

🔗 References

📤 Share & Export