# CVE-2025-25186: Net::IMAP vulnerable to possible DoS by memory exhaustion

> A malicious IMAP server can cause memory exhaustion and denial of service in the Ruby Net::IMAP client by sending highly compressed uid-set data.

- **Severity:** Medium 6.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 10 Feb 2025
- **Updated:** 12 Feb 2025
- **Also known as:** AZL-56555, BELL-CVE-2025-25186, DEBIAN-CVE-2025-25186, GHSA-7fc5-f82f-cx69, MINI-44mx-vwr4-8c9p, OESA-2025-1195, OESA-2025-1196, UBUNTU-CVE-2025-25186

## What is CVE-2025-25186?

CVE-2025-25186 is a medium-severity denial of service vulnerability in ruby net-imap, published on 10 Feb 2025. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

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.

Weakness: CWE-770 (Allocation of Resources Without Limits or Throttling), CWE-409 (Improper Handling of Highly Compressed Data (Data Amplification)), CWE-789 (Memory Allocation with Excessive Size Value), CWE-405 (Asymmetric Resource Consumption (Amplification)), CWE-400 (Uncontrolled Resource Consumption), CWE-1287 (Improper Validation of Specified Type of Input)

## Which versions are affected by CVE-2025-25186?

6 open source packages ship an affected version, including net-imap.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `net-imap` | RubyGems | From 0.3.2 | 0.3.8 |
| `net-imap` | RubyGems | From 0.3.2 | 0.3.8 |
| `net-imap` | RubyGems | From 0.4.0 | 0.4.19 |
| `net-imap` | RubyGems | From 0.4.0 | 0.4.19 |
| `net-imap` | RubyGems | From 0.5.0 | 0.5.6 |
| `net-imap` | RubyGems | From 0.5.0 | 0.5.6 |

## How do I fix CVE-2025-25186?

Upgrade net-imap to a fixed version for your release line: 0.3.8, 0.4.19 or 0.5.6.

## Is CVE-2025-25186 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-25186 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-25186 and fix it if it is affected.

What it is: CVE-2025-25186 is a medium-severity denial of service vulnerability in ruby net-imap, published on 10 Feb 2025. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-25186 exists.

Affected packages and fixed versions:
- net-imap (RubyGems): affected from 0.3.2; fixed in 0.3.8
- net-imap (RubyGems): affected from 0.3.2; fixed in 0.3.8
- net-imap (RubyGems): affected from 0.4.0; fixed in 0.4.19
- net-imap (RubyGems): affected from 0.4.0; fixed in 0.4.19
- net-imap (RubyGems): affected from 0.5.0; fixed in 0.5.6
- net-imap (RubyGems): affected from 0.5.0; fixed in 0.5.6

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2025-25186/ (Markdown: https://insights.sbomify.com/CVE-2025-25186/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2025-25186
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-25186
- OSV: https://osv.dev/vulnerability/CVE-2025-25186

---
From sbomify Insights: https://insights.sbomify.com/CVE-2025-25186/
Summaries are generated and may contain mistakes; the official description above is the record.
