CVE-2025-25186
Medium · 6.5CVSS
6.5
EPSS
0.6%
Published
Feb 10, 2025
CISA due date
—
Cloudanix analysis
A malicious mail server can crash some Ruby-based mail clients by sending a specially crafted response that makes them run out of memory.
- Exploitation
- Requires User Interaction
- Attacker needs
- None
- Complexity
- Low
- Impact
- Denial Of Service
- Component
- Library
- Class
- Denial of service
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
The flaw is a remote denial-of-service condition in the Ruby net-imap client library response parser. A malicious or compromised IMAP server can send a syntactically small UID-set or range expression that expands to an extremely large set of integers. Vulnerable versions convert those ranges with Range#to_a without enforcing an expansion limit, causing the Ruby process to allocate excessive memory. The likely result is severe memory pressure, process termination, container restart, worker crash, or host-level instability if resource limits are weak. The issue affects net-imap versions starting at 0.3.2 and before 0.3.8, 0.4.19, and 0.5.6.
Why it matters to the business
Applications that use Ruby net-imap to connect to external, user-supplied, third-party, or potentially compromised IMAP servers can be made unavailable by a hostile server response. This can interrupt mail ingestion, ticket creation, notification processing, account synchronization, or any workflow that depends on IMAP polling. The vulnerability is not known to be in CISA KEV, is not reported as ransomware-used, and has a low EPSS score, but it is simple to trigger when an attacker can influence the IMAP server endpoint or compromise a mailbox provider. Because the issue was published in February 2025 and has had fixed releases available for an extended period, remaining exposure is primarily a patch hygiene and dependency-management risk.
How an attack unfolds
An attacker first needs a Ruby application using a vulnerable net-imap version to connect to an IMAP server the attacker controls or has compromised. This may happen when an application lets users configure mailboxes, when test or integration systems connect to attacker-controlled IMAP endpoints, or when a legitimate IMAP server is compromised. After the client authenticates or otherwise establishes an IMAP session, the server sends a response containing a highly compressed UID-set or range that is small on the wire but expands to a very large number of integers. The vulnerable receiver thread automatically reads the response, and the parser converts the range into an array using Range#to_a. Memory consumption spikes rapidly until the Ruby process is killed by the runtime, operating system, container orchestrator, or out-of-memory protection. The attacker does not gain code execution or data access from the flaw itself; the impact is availability loss.
How to fix it
Upgrade the Ruby net-imap dependency to a fixed release: 0.3.8 or later for the 0.3.x line, 0.4.19 or later for the 0.4.x line, or 0.5.6 or later for the 0.5.x line. If consuming directly from Git, use a revision containing commit 38ce681e594e0a12b46fda77b9729c85e090dc13 or a later trusted commit. Rebuild and redeploy applications so the fixed gem/library version is actually loaded at runtime. If immediate upgrade is not possible, reduce exposure by disallowing user-controlled IMAP server destinations, allowlisting trusted IMAP hosts, enforcing strict connection egress controls, placing Ruby workers in memory-limited containers, configuring supervisor restart backoff, and isolating mail ingestion workers from critical application processes. Resource limits are mitigation only; they do not correct the parser flaw.
How to confirm the fix worked
Confirm dependency resolution with package inventory and runtime checks, not only source manifests. Review Gemfile.lock, gemspecs, bundled gems, container images, and SBOMs for net-imap versions earlier than 0.3.8, 0.4.19, or 0.5.6. In a running application, verify the loaded net-imap version using Ruby dependency introspection such as `Gem.loaded_specs['net-imap']&.version`. Confirm direct Git dependencies include commit 38ce681e594e0a12b46fda77b9729c85e090dc13 or later. After upgrading, run application IMAP integration tests and monitor memory behavior while parsing large but bounded IMAP UID-set responses. Exposure remains if any deployed image, worker, scheduled job, or mail-processing component still loads a vulnerable net-imap version.
Typical attack path
- Identify or lure a Ruby application using vulnerable net-imap versions 0.3.2 through versions before 0.3.8, 0.4.19, or 0.5.6 into connecting to an IMAP server under attacker control.
- Allow the IMAP TCP/TLS session to be established and keep the client connected long enough for the client receiver thread to process server responses.
- Send an IMAP response containing a compact but extremely large UID-set/range expression.
- Trigger the vulnerable response parser to expand the UID-set into a large Ruby array using Range#to_a.
- Exhaust process memory, causing the mail-processing worker, application process, container, or host service to crash or restart.
- Repeat the malicious response after reconnects to create a persistent denial of service.
How to detect it
Look for evidence of abnormal memory exhaustion in Ruby processes that use net-imap, especially mail ingestion workers or background jobs that maintain IMAP sessions. Useful sources include application logs, Ruby exception logs, container stdout/stderr, process supervisor logs, system OOM-killer logs, Kubernetes pod events, endpoint telemetry, and network/proxy logs for IMAP/IMAPS connections. Investigate NoMemoryError, abrupt worker exits, container OOMKilled events, repeated restarts, or host OOM events that occur during or shortly after IMAP sessions. Correlate crashes with outbound connections to new, unusual, user-supplied, or low-reputation IMAP servers on ports 143 or 993. If packet capture or mail protocol logging is available, search for IMAP responses containing unusually large UID-set ranges, especially compact numeric ranges with very large upper bounds. Because exploitation does not require dropping files or spawning attacker tooling, detection is primarily behavioral: memory spikes plus IMAP response parsing activity plus a suspicious server endpoint.
- NoMemoryError
- failed to allocate memory
- Range#to_a
- net/imap
- net-imap
- OOMKilled
- Out of memory: Killed process
- Killed process ruby
- signal 9 (SIGKILL)
- exit status 137
- port 143
- port 993
- UID 1:4294967295
- 1:4294967295
- 1:2147483647
- VANISHED 1:4294967295
- ESEARCH UID
What your security team should do
- Inventory all Ruby applications, background workers, mail ingestion services, and automation jobs that use net-imap, including transitive dependencies and bundled gems.
- Prioritize upgrades for systems that connect to user-configurable, third-party, internet-hosted, or otherwise untrusted IMAP servers.
- Pin net-imap to fixed versions 0.3.8, 0.4.19, 0.5.6, or later, and redeploy all affected runtime artifacts.
- Add dependency-scanning policy to block net-imap versions >=0.3.2 and <0.3.8, >=0.4.0 and <0.4.19, and >=0.5.0 and <0.5.6.
- Restrict outbound IMAP/IMAPS connections to approved providers where business requirements allow.
- Apply memory limits and restart controls to mail-processing workers to contain availability impact if a malicious server response is encountered.
- Review recent crash, OOM, and mail-worker restart events for signs of prior exploitation, especially where failures correlate with specific IMAP server connections.
- Because this is not currently KEV-listed and has low EPSS, treat it as moderate-priority unless the application connects to untrusted IMAP endpoints, in which case patch promptly.
The record
Net::IMAP implements Internet Message Access Protocol (IMAP) client functionality in Ruby. Starting in version 0.3.2 and prior to versions 0.3.8, 0.4.19, and 0.5.6, there is a possibility for denial of service by memory exhaustion in `net-imap`'s response parser. At any time while the client is connected, a malicious server can send can send highly compressed `uid-set` data which is automatically read by the client's receiver thread. The response parser uses `Range#to_a` to convert the `uid-set` data into arrays of integers, with no limitation on the expanded size of the ranges. Versions 0.3.8, 0.4.19, 0.5.6, and higher fix this issue. Additional details for proper configuration of fixed versions and backward compatibility are available in the GitHub Security Advisory.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| RubyGems | net-imap | 0.3.2 | 0.3.8 |
| RubyGems | net-imap | 0.4.0 | 0.4.19 |
| RubyGems | net-imap | 0.5.0 | 0.5.6 |
| AlmaLinux:10 | ruby | 0 | 3.3.8-10.el10_0 |
| AlmaLinux:10 | ruby-bundled-gems | 0 | 3.3.8-10.el10_0 |
| AlmaLinux:10 | ruby-default-gems | 0 | 3.3.8-10.el10_0 |
| AlmaLinux:10 | ruby-devel | 0 | 3.3.8-10.el10_0 |
| AlmaLinux:10 | ruby-doc | 0 | 3.3.8-10.el10_0 |
| AlmaLinux:10 | ruby-libs | 0 | 3.3.8-10.el10_0 |
| AlmaLinux:10 | rubygem-bigdecimal | 0 | 3.1.5-10.el10_0 |
| AlmaLinux:10 | rubygem-bundler | 0 | 2.5.22-10.el10_0 |
| AlmaLinux:10 | rubygem-io-console | 0 | 0.7.1-10.el10_0 |
| AlmaLinux:10 | rubygem-irb | 0 | 1.13.1-10.el10_0 |
| AlmaLinux:10 | rubygem-json | 0 | 2.7.2-10.el10_0 |
| AlmaLinux:10 | rubygem-minitest | 0 | 5.20.0-10.el10_0 |
| AlmaLinux:10 | rubygem-power_assert | 0 | 2.0.3-10.el10_0 |
| AlmaLinux:10 | rubygem-psych | 0 | 5.1.2-10.el10_0 |
| AlmaLinux:10 | rubygem-racc | 0 | 1.7.3-10.el10_0 |
| AlmaLinux:10 | rubygem-rake | 0 | 13.1.0-10.el10_0 |
| AlmaLinux:10 | rubygem-rbs | 0 | 3.4.0-10.el10_0 |
| AlmaLinux:10 | rubygem-rdoc | 0 | 6.6.3.1-10.el10_0 |
| AlmaLinux:10 | rubygem-rexml | 0 | 3.3.9-10.el10_0 |
| AlmaLinux:10 | rubygem-rss | 0 | 0.3.1-10.el10_0 |
| AlmaLinux:10 | rubygem-test-unit | 0 | 3.6.1-10.el10_0 |
| AlmaLinux:10 | rubygem-typeprof | 0 | 0.21.9-10.el10_0 |
| AlmaLinux:10 | rubygems | 0 | 3.5.22-10.el10_0 |
| AlmaLinux:10 | rubygems-devel | 0 | 3.5.22-10.el10_0 |
| AlmaLinux:8 | ruby | 0 | 3.3.8-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | ruby-bundled-gems | 0 | 3.3.8-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | ruby-default-gems | 0 | 3.3.8-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | ruby-devel | 0 | 3.3.8-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | ruby-doc | 0 | 3.3.8-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | ruby-libs | 0 | 3.3.8-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-abrt | 0 | 0.4.0-1.module_el8.10.0+3799+191214cc |
| AlmaLinux:8 | rubygem-abrt-doc | 0 | 0.4.0-1.module_el8.10.0+3799+191214cc |
| AlmaLinux:8 | rubygem-bigdecimal | 0 | 3.1.5-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-bundler | 0 | 2.5.22-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-io-console | 0 | 0.7.1-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-irb | 0 | 1.13.1-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-json | 0 | 2.7.2-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-minitest | 0 | 5.20.0-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-mysql2 | 0 | 0.5.5-1.module_el8.10.0+3799+191214cc |
| AlmaLinux:8 | rubygem-mysql2-doc | 0 | 0.5.5-1.module_el8.10.0+3799+191214cc |
| AlmaLinux:8 | rubygem-pg | 0 | 1.5.4-1.module_el8.10.0+3799+191214cc |
| AlmaLinux:8 | rubygem-pg-doc | 0 | 1.5.4-1.module_el8.10.0+3799+191214cc |
| AlmaLinux:8 | rubygem-power_assert | 0 | 2.0.3-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-psych | 0 | 5.1.2-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-racc | 0 | 1.7.3-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-rake | 0 | 13.1.0-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-rbs | 0 | 3.4.0-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-rdoc | 0 | 6.6.3.1-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-rexml | 0 | 3.3.9-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-rss | 0 | 0.3.1-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-test-unit | 0 | 3.6.1-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygem-typeprof | 0 | 0.21.9-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygems | 0 | 3.5.22-4.module_el8.10.0+4022+8b66723c |
| AlmaLinux:8 | rubygems-devel | 0 | 3.5.22-4.module_el8.10.0+4022+8b66723c |
| Chainguard | graalvm-23 | 0 | 23.0.2-r7 |
| Chainguard | graalvm-23-ce | 0 | 23.0.2-r7 |
| Chainguard | graalvm-23-ce-dbg | 0 | 23.0.2-r7 |
| Chainguard | graalvm-23-ce-default-jdk | 0 | 23.0.2-r7 |
| Chainguard | graalvm-23-ce-jmods | 0 | 23.0.2-r7 |
| Chainguard | graalvm-23-ce-nodejs | 0 | 23.0.2-r7 |
| Chainguard | graalvm-23-ce-nodejs-dbg | 0 | 23.0.2-r7 |
| Chainguard | graalvm-23-ce-nodejs-default-jdk | 0 | 23.0.2-r7 |
| Chainguard | graalvm-23-ce-nodejs-jmods | 0 | 23.0.2-r7 |
| Chainguard | graalvm-23-graalpy | 0 | 23.0.2-r7 |
| Chainguard | graalvm-23-graalpy-venv | 0 | 23.0.2-r7 |
| Chainguard | kube-fluentd-operator | 0 | 1.18.2-r23 |
| Chainguard | kube-fluentd-operator-compat | 0 | 1.18.2-r23 |
| Chainguard | kube-fluentd-operator-default-config | 0 | 1.18.2-r23 |
| Chainguard | kube-fluentd-operator-oci-entrypoint | 0 | 1.18.2-r23 |
| Chainguard | logstash-8 | 0 | 8.17.2-r1 |
| Chainguard | logstash-8-bitnami-compat | 0 | 8.17.2-r1 |
| Chainguard | logstash-8-compat | 0 | 8.17.2-r1 |
| Chainguard | logstash-8-env2yaml | 0 | 8.17.2-r1 |
| Chainguard | logstash-8-iamguarded-compat | 0 | 8.17.2-r1 |
| Chainguard | logstash-8-with-output-opensearch | 0 | 8.17.2-r1 |
| Chainguard | logstash-jre-bcfips | 0 | 8.17.3-r0 |
| Chainguard | logstash-jre-bcfips-compat | 0 | 8.17.3-r0 |
| Chainguard | logstash-jre-bcfips-env2yaml | 0 | 8.17.3-r0 |
| Chainguard | logstash-jre-bcfips-with-output-opensearch | 0 | 8.17.3-r0 |
| Chainguard | ruby3.2-net-imap | 0 | 0.5.6-r0 |
| Chainguard | ruby3.2-rails-7.1 | 0 | 7.1.5.1-r2 |
| Chainguard | ruby3.2-rails-7.1-compat | 0 | 7.1.5.1-r2 |
| Chainguard | ruby3.2-rails-7.2 | 0 | 7.2.2.1-r2 |
| Chainguard | ruby3.2-rails-7.2-compat | 0 | 7.2.2.1-r2 |
| Chainguard | ruby3.2-rails-8.0 | 0 | 8.0.1-r2 |
| Chainguard | ruby3.2-rails-8.0-compat | 0 | 8.0.1-r2 |
| Chainguard | ruby3.3-net-imap | 0 | 0.5.6-r0 |
| Chainguard | ruby3.3-rails-7.1 | 0 | 7.1.5.1-r2 |
| Chainguard | ruby3.3-rails-7.1-compat | 0 | 7.1.5.1-r2 |
| Chainguard | ruby3.3-rails-7.2 | 0 | 7.2.2.1-r2 |
| Chainguard | ruby3.3-rails-7.2-compat | 0 | 7.2.2.1-r2 |
| Chainguard | ruby3.3-rails-8.0 | 0 | 8.0.1-r2 |
| Chainguard | ruby3.3-rails-8.0-compat | 0 | 8.0.1-r2 |
| Chainguard | ruby3.4-net-imap | 0 | 0.5.6-r0 |
| Chainguard | ruby3.4-rails-7.1 | 0 | 7.1.5.1-r2 |
| Chainguard | ruby3.4-rails-7.1-compat | 0 | 7.1.5.1-r2 |
| Chainguard | ruby3.4-rails-7.2 | 0 | 7.2.2.1-r2 |
| Chainguard | ruby3.4-rails-7.2-compat | 0 | 7.2.2.1-r2 |
| Chainguard | ruby3.4-rails-8.0 | 0 | 8.0.1-r2 |
| Chainguard | ruby3.4-rails-8.0-compat | 0 | 8.0.1-r2 |
| Debian:12 | ruby3.1 | 0 | No fix |
| Debian:13 | ruby3.3 | 0 | No fix |
| Debian:13 | ruby3.3 | 0 | 3.3.8-1 |
| Mageia:9 | ruby | 0 | 3.1.5-47.mga9 |
| Wolfi | kube-fluentd-operator | 0 | 1.18.2-r23 |
| Wolfi | kube-fluentd-operator-compat | 0 | 1.18.2-r23 |
| Wolfi | kube-fluentd-operator-default-config | 0 | 1.18.2-r23 |
| Wolfi | kube-fluentd-operator-oci-entrypoint | 0 | 1.18.2-r23 |
| Wolfi | logstash-8 | 0 | 8.17.2-r1 |
| Wolfi | logstash-8-bitnami-compat | 0 | 8.17.2-r1 |
| Wolfi | logstash-8-compat | 0 | 8.17.2-r1 |
| Wolfi | logstash-8-env2yaml | 0 | 8.17.2-r1 |
| Wolfi | logstash-8-iamguarded-compat | 0 | 8.17.2-r1 |
| Wolfi | logstash-8-with-output-opensearch | 0 | 8.17.2-r1 |
| Wolfi | ruby3.2-net-imap | 0 | 0.5.6-r0 |
| Wolfi | ruby3.2-rails-8.0 | 0 | 8.0.1-r2 |
| Wolfi | ruby3.2-rails-8.0-compat | 0 | 8.0.1-r2 |
| Wolfi | ruby3.3-net-imap | 0 | 0.5.6-r0 |
| Wolfi | ruby3.3-rails-8.0 | 0 | 8.0.1-r2 |
| Wolfi | ruby3.3-rails-8.0-compat | 0 | 8.0.1-r2 |
| Wolfi | ruby3.4-net-imap | 0 | 0.5.6-r0 |
| Wolfi | ruby3.4-rails-8.0 | 0 | 8.0.1-r2 |
| Wolfi | ruby3.4-rails-8.0-compat | 0 | 8.0.1-r2 |
| gem | net-imap | 0.3.2 | 0.3.8 |
| gem | net-imap | 0.4.0 | 0.4.19 |
| gem | net-imap | 0.5.0 | 0.5.6 |
Related vulnerabilities
- CVE-2025-43857 net-imap rubygem vulnerable to possible DoS by memory exhaustion Also affects net-imap
- CVE-2025-58767 REXML is an XML toolkit for Ruby. Also affects ruby
- CVE-2025-27221 In the URI gem before 1.0.3 for Ruby, the URI handling methods (URI.join, URI#merge… Also affects ruby
- CVE-2024-49761 REXML is an XML toolkit for Ruby. Also affects ruby
- CVE-2024-41946 REXML is an XML toolkit for Ruby. Also affects ruby
- CVE-2024-41123 REXML is an XML toolkit for Ruby. Also affects ruby
- CVE-2024-39908 REXML is an XML toolkit for Ruby. Also affects ruby
- CVE-2024-27281 An issue was discovered in RDoc 6.3.3 through 6.6.2, as distributed in Ruby 3.x through… Also affects ruby