Monitor vulnerabilities like this one. Sign up free to get alerted when software you use is affected.
5.8

CVE-2026-42258: Net::IMAP vulnerable to command injection via unvalidated inputs

GHSA-75xq-5h9v-w6px CVE-2026-42258 GHSA-75xq-5h9v-w6px
Summary

Net::IMAP, a library for working with email servers, has a security issue that allows attackers to inject malicious commands. This is because the library does not properly validate certain types of input. To stay safe, make sure to update to the latest version of Net::IMAP and follow best practices for validating user input. If you're not using the latest version, consider upgrading to avoid potential security risks.

What to do
  • Update shugo maeda net-imap to version 0.6.4.
  • Update shugo maeda net-imap to version 0.5.14.
  • Update shugo maeda net-imap to version 0.4.24.
  • Update net-imap to version 0.4.24.
  • Update net-imap to version 0.6.4.
  • Update net-imap to version 0.5.14.
Affected software
Ecosystem VendorProductAffected versions
rubygems shugo maeda net-imap >= 0.6.0, <= 0.6.3
>= 0.5.0, <= 0.5.13
<= 0.4.23
Fix: upgrade to 0.6.4
rubygems net-imap <= 0.4.23
>= 0.6.0, <= 0.6.3
>= 0.5.0, <= 0.5.13
Fix: upgrade to 0.4.24
RubyGems net-imap >= 0.6.0, < 0.6.4
>= 0.5.0, < 0.5.14
< 0.4.24
Fix: upgrade to 0.6.4
ruby-lang net\ \
cpe:2.3:a:ruby-lang:net\:\:imap:*:*:*:*:*:ruby:*:*
Original title
net-imap vulnerable to command Injection via unvalidated Symbol inputs
Original description
### Summary

Symbol arguments to commands are vulnerable to a CRLF Injection / IMAP Command injection via Symbol arguments passed to IMAP commands.

### Details

Symbol arguments represent IMAP "system flags", which are formatted as "atoms" (with no quoting) with a `"\"` prefix. Vulnerable versions of Net::IMAP sends the symbol name directly to the socket, with no validation.

Because the Symbol input is unvalidated, it could contain invalid `flag` characters, including `SP` and `CRLF`, which could be used to finish the current command and inject new commands.

Although IMAP `flag` arguments are only valid input for a few IMAP commands, most Net::IMAP commands use generic argument handling, and will allow Symbol (`flag`) inputs.

Note also that the list of valid symbol inputs should be restricted to an enumerated set of standard RFC defined flag types, which have each been given specific defined semantics. Any user-provided values outside of that list of standard "system flags" needs to use the IMAP `keyword` syntax, which are sent as atoms, i.e: string inputs. Under no circumstances should `#to_sym` ever be called on unvetted user-provided input: that will always be a bug in the calling code for the simple reason that `user_input_atom` is as `\user_input_atom`.

For forward compatibility with future IMAP extentions, Net::IMAP, does not restrict flag inputs to an enumerated list. That is the responsibility of the calling application code, which knows which flag semantics are valid for its context.

### Impact

If a developer passes user-controlled input as a Symbol to most Net::IMAP commands, an attacker can append CRLF sequence followed by a new IMAP command (like `DELETE mailbox`).

### Mitigation
* Upgrade to a version of Net::IMAP that validates Symbols are valid as an IMAP `flag`.
* User-provided input should never be able to control calling `#to_sym` on string arguments.

For example, do not unsafely serialize and deserialize command arguments (e.g. with YAML or Marshal) in a way that could create unvetted Symbol arguments.
* For the few IMAP commands which do allow `flag` arguments, it may be appropriate to hard-code Symbol arguments or restrict them to an enumerated list which is valid for the calling application.
ghsa CVSS4.0 5.8
Vulnerability type
CWE-77 Command Injection
CWE-93
Published: 4 May 2026 · Updated: 28 May 2026 · First seen: 4 May 2026