# CVE-2026-42257: net-imap: Command Injection via "raw" arguments to multiple commands

> Attackers can inject arbitrary IMAP commands via raw string arguments in the Ruby net-imap library if input is user-controlled.

- **Severity:** Medium 5.8 (`CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:P/VC:N/VI:H/VA:L/SC:N/SI:N/SA:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 9 May 2026
- **Updated:** 13 May 2026
- **Also known as:** ALPINE-CVE-2026-42257, BELL-CVE-2026-42257, CLEANSTART-2026-NN77724, CLEANSTART-2026-SU72949, CLSA-2026-1791456473, DEBIAN-CVE-2026-42257, ECHO-54d2-f1b2-3225, GHSA-hm49-wcqc-g2xg, MINI-2w53-gf47-wj4h, MINI-36cp-92qw-vh35, MINI-3ffj-h54c-g7w6, MINI-3v8r-c24p-4675, MINI-446q-5h9j-h69v, MINI-4r4w-2v6v-gg66, MINI-66jr-5vr4-5r5w, MINI-694r-4jr4-f9j8, MINI-9c6f-w5vx-fmv5, MINI-c95p-hp4w-pq5q, MINI-fmr7-v8jc-2m8x, MINI-qpwr-58qj-86x9, MINI-rcvv-cfvc-34j9, MINI-rmwp-fw9r-427f, MINI-vxrf-gq2q-j23r, MINI-wcg5-2m96-6q68, MINI-xw9c-44mh-qcfp, UBUNTU-CVE-2026-42257, USN-8431-1, USN-8478-1

## What is CVE-2026-42257?

CVE-2026-42257 is a medium-severity command injection vulnerability in ruby net-imap, published on 9 May 2026. It can only be exploited from the same machine or local network, 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.4.24, 0.5.14, and 0.6.4, several Net::IMAP commands accept a raw string argument that is sent to the server without validation or escaping. If this string is derived from user-controlled input, it may contain contain CRLF sequences, which an attacker can use to inject arbitrary IMAP commands. This issue has been patched in versions 0.4.24, 0.5.14, and 0.6.4.

Weakness: CWE-93 (Improper Neutralization of CRLF Sequences), CWE-77 (Improper Neutralization of Special Elements used in a Command)

## Which versions are affected by CVE-2026-42257?

6 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.4.24 |
| `net-imap` | RubyGems | All versions | 0.4.24 |
| `net-imap` | RubyGems | From 0.5.0 | 0.5.14 |
| `net-imap` | RubyGems | From 0.5.0 | 0.5.14 |
| `net-imap` | RubyGems | From 0.6.0 | 0.6.4 |
| `net-imap` | RubyGems | From 0.6.0 | 0.6.4 |

Products: Ruby-Lang Net\.

## How do I fix CVE-2026-42257?

Upgrade net-imap to a fixed version for your release line: 0.4.24, 0.5.14 or 0.6.4.

## Is CVE-2026-42257 being exploited?

There is no known exploitation of CVE-2026-42257 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-2025-43857](https://insights.sbomify.com/CVE-2025-43857/): net-imap rubygem vulnerable to possible DoS by memory exhaustion (medium 6.0)
- [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-2026-42257 and fix it if it is affected.

What it is: CVE-2026-42257 is a medium-severity command injection vulnerability in ruby net-imap, published on 9 May 2026. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2026-42257 in the wild and no public exploit code.

Affected packages and fixed versions:
- net-imap (RubyGems): affected all versions; fixed in 0.4.24
- net-imap (RubyGems): affected all versions; fixed in 0.4.24
- net-imap (RubyGems): affected from 0.5.0; fixed in 0.5.14
- net-imap (RubyGems): affected from 0.5.0; fixed in 0.5.14
- net-imap (RubyGems): affected from 0.6.0; fixed in 0.6.4
- net-imap (RubyGems): affected from 0.6.0; fixed in 0.6.4

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

## Sources

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

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