# CVE-2025-43857: net-imap rubygem 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 large literal byte counts.

- **Severity:** Medium 6.0 (`CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N`)
- **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:** 28 Apr 2025
- **Updated:** 28 Apr 2025
- **Also known as:** ALPINE-CVE-2025-43857, DEBIAN-CVE-2025-43857, ECHO-d252-3984-4cf6, GHSA-j3g3-5qv5-52mj, MINI-mfwq-779c-vj46, MINI-mj9j-p5vp-f5jh, MINI-w3r4-vv49-vf4r, MINI-xgxc-h9pc-qvf6, OESA-2025-1640, UBUNTU-CVE-2025-43857

## What is CVE-2025-43857?

CVE-2025-43857 is a medium-severity denial of service vulnerability in ruby net-imap, published on 28 Apr 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. Prior to versions 0.5.7, 0.4.20, 0.3.9, and 0.2.5, there is a possibility for denial of service by memory exhaustion when net-imap reads server responses. At any time while the client is connected, a malicious server can send can send a "literal" byte count, which is automatically read by the client's receiver thread. The response reader immediately allocates memory for the number of bytes indicated by the server response. This should not be an issue when securely connecting to trusted IMAP servers that are well-behaved. It can affect insecure connections and buggy, untrusted, or compromised servers (for example, connecting to a user supplied hostname). This issue has been patched in versions 0.5.7, 0.4.20, 0.3.9, and 0.2.5.

Weakness: CWE-770 (Allocation of Resources Without Limits or Throttling), CWE-789 (Memory Allocation with Excessive Size Value), CWE-405 (Asymmetric Resource Consumption (Amplification)), CWE-400 (Uncontrolled Resource Consumption)

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

8 open source packages ship an affected version, including net-imap. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `net-imap` | RubyGems | All versions | 0.2.5 |
| `net-imap` | RubyGems | All versions | 0.2.5 |
| `net-imap` | RubyGems | From 0.3.0 | 0.3.9 |
| `net-imap` | RubyGems | From 0.3.0 | 0.3.9 |
| `net-imap` | RubyGems | From 0.4.0 | 0.4.20 |
| `net-imap` | RubyGems | From 0.4.0 | 0.4.20 |
| `net-imap` | RubyGems | From 0.5.0 | 0.5.7 |
| `net-imap` | RubyGems | From 0.5.0 | 0.5.7 |

Products: Ruby-Lang Net\.

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

Upgrade net-imap to a fixed version for your release line: 0.2.5, 0.3.9, 0.4.20 or 0.5.7.

## Is CVE-2025-43857 being exploited?

There is no known exploitation of CVE-2025-43857 in the wild and no public exploit code.

## Other vulnerabilities in ruby net-imap

- [CVE-2026-42246](https://insights.sbomify.com/CVE-2026-42246/): net-imap vulnerable to STARTTLS stripping via invalid response timing (high 7.6)
- [CVE-2026-42256](https://insights.sbomify.com/CVE-2026-42256/): net-imap: Denial of service via high iteration count for `SCRAM-*` authentication (medium 6.0)
- [CVE-2026-42257](https://insights.sbomify.com/CVE-2026-42257/): net-imap: Command Injection via "raw" arguments to multiple commands (medium 5.8)
- [CVE-2026-42258](https://insights.sbomify.com/CVE-2026-42258/): net-imap: Command Injection via unvalidated Symbol inputs (medium 5.8)
- [CVE-2026-42245](https://insights.sbomify.com/CVE-2026-42245/): net-imap: Quadratic complexity when reading response literals (low 2.3)

## Fix prompt for AI coding agents

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

What it is: CVE-2025-43857 is a medium-severity denial of service vulnerability in ruby net-imap, published on 28 Apr 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: There is no known exploitation of CVE-2025-43857 in the wild and no public exploit code.

Affected packages and fixed versions:
- net-imap (RubyGems): affected all versions; fixed in 0.2.5
- net-imap (RubyGems): affected all versions; fixed in 0.2.5
- net-imap (RubyGems): affected from 0.3.0; fixed in 0.3.9
- net-imap (RubyGems): affected from 0.3.0; fixed in 0.3.9
- net-imap (RubyGems): affected from 0.4.0; fixed in 0.4.20
- net-imap (RubyGems): affected from 0.4.0; fixed in 0.4.20
- net-imap (RubyGems): affected from 0.5.0; fixed in 0.5.7
- net-imap (RubyGems): affected from 0.5.0; fixed in 0.5.7

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-43857/ (Markdown: https://insights.sbomify.com/CVE-2025-43857/index.md)
```

## Sources

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

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