Skip to main content
Vulnerability Database/CVE-2026-87864

CVE-2026-87864: curl CURLOPT_CRLF IMAP RCE Vulnerability

CVE-2026-87864 is a remote code execution vulnerability in curl that exploits CURLOPT_CRLF in IMAP APPEND operations, allowing attackers to inject and execute arbitrary IMAP commands. This article covers technical details, affected versions, impact assessment, and mitigation strategies.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-87864 Overview

CVE-2026-87864 affects the curl command-line tool and libcurl library when the CURLOPT_CRLF option is enabled during IMAP APPEND operations. The flaw causes curl to advertise the raw input byte count in the IMAP APPEND {N} literal while actually transmitting line-ending expanded data. Because the server only consumes N bytes as the message payload, the remaining expanded bytes fall outside the literal boundary. The IMAP server then parses those overflow bytes as pipelined commands inside the authenticated session. This creates an authenticated IMAP command injection condition driven entirely by curl's own byte accounting.

Critical Impact

An attacker who controls the message body supplied to a curl IMAP APPEND upload with CURLOPT_CRLF enabled can inject arbitrary IMAP commands that execute in the context of the authenticated session.

Affected Products

  • curl (command-line tool) when using IMAP APPEND with --crlf
  • libcurl when CURLOPT_CRLF is set for IMAP uploads
  • Applications embedding libcurl that forward untrusted content through IMAP APPEND

Discovery Timeline

  • 2026-10-20 - CVE-2026-87864 published to NVD
  • 2026-10-22 - Last updated in NVD database

Technical Details for CVE-2026-87864

Vulnerability Analysis

The IMAP APPEND command uses a literal syntax of the form APPEND INBOX {N} where N declares the exact byte count of the message that follows. The server reads precisely N bytes and then resumes parsing the stream as IMAP protocol commands. Correct client behavior requires N to match the number of bytes actually written on the wire.

When CURLOPT_CRLF is enabled, curl rewrites bare LF bytes in the upload stream to CRLF before transmission. The byte count advertised in the {N} literal is calculated from the original input length, not the expanded output length. Each converted newline therefore adds one byte that the server does not count toward the message payload.

After the server finishes reading N bytes, the trailing expanded bytes remain in the TCP stream. The IMAP parser treats those bytes as a new command line within the already-authenticated session. An attacker who influences the message content can craft input whose expansion yields valid IMAP verbs such as DELETE, RENAME, or LOGOUT.

Root Cause

The root cause is an input-validation and accounting error [CWE-93, CRLF Injection class]. curl computes the APPEND literal size from the pre-translation buffer length while the on-wire representation is larger after LF to CRLF conversion. The declared length and the transmitted length diverge, breaking the framing contract that IMAP literals rely on.

Attack Vector

Exploitation requires that an application pass attacker-influenced content to a curl IMAP APPEND upload with CURLOPT_CRLF enabled and that the session be authenticated. The attacker supplies message bodies containing bare LF sequences positioned so that CRLF expansion pushes crafted bytes past the declared literal boundary. Those bytes are then interpreted by the IMAP server as pipelined commands. Impact scales with the privileges of the authenticated mailbox account, including mailbox modification, message deletion, and session manipulation. Refer to the Curl CVE-2026-87864 Documentation and the HackerOne Report #3972403 for additional protocol-level details.

Stop Remote Code Execution Before It Runs

Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.

Stop Exploit Attempts

Detection Methods for CVE-2026-87864

Indicators of Compromise

  • Unexpected IMAP commands (DELETE, RENAME, LOGOUT, STORE) issued immediately after APPEND completion in server logs.
  • IMAP server protocol errors referencing unknown commands or malformed tags following an APPEND literal.
  • Outbound curl or libcurl traffic to IMAP endpoints where upload payloads contain bare LF bytes in user-controlled sections.

Detection Strategies

  • Inspect application code and configuration for calls that combine CURLOPT_UPLOAD, the imap:// scheme, and CURLOPT_CRLF = 1.
  • Enable IMAP server command auditing and alert on commands that appear within milliseconds of an APPEND literal from the same session.
  • Compare the declared {N} literal size against the measured wire length in network captures of IMAP uploads.

Monitoring Recommendations

  • Forward IMAP server protocol logs to a centralized analytics platform and alert on sequences where APPEND is followed by state-changing verbs without a client tag boundary.
  • Baseline normal curl user-agent IMAP traffic volumes and flag deviations in message-size distributions.
  • Track outbound process executions that invoke curl --crlf with imap:// or imaps:// URLs.

How to Mitigate CVE-2026-87864

Immediate Actions Required

  • Inventory all applications and scripts that call curl or libcurl for IMAP APPEND operations and identify any use of CURLOPT_CRLF or the --crlf flag.
  • Disable CURLOPT_CRLF for IMAP uploads until a patched curl build is deployed; perform any required line-ending normalization before handing the buffer to curl.
  • Restrict IMAP credentials used by curl-based automation to the minimum mailbox scope needed and rotate credentials if misuse is suspected.

Patch Information

Refer to the official Curl CVE-2026-87864 Documentation and the Curl CVE-2026-87864 JSON Data for the fixed version range and upgrade guidance. Upgrade curl and libcurl to the version identified in the advisory as containing the corrected APPEND literal size calculation.

Workarounds

  • Pre-convert LF to CRLF in the message body in application code and leave CURLOPT_CRLF disabled so the advertised and transmitted byte counts match.
  • Avoid using IMAP APPEND with attacker-influenced message content; validate and canonicalize line endings before upload.
  • Where feasible, route message submission through SMTP or an IMAP library that performs correct literal accounting instead of curl with CURLOPT_CRLF.
bash
# Configuration example: safe IMAP APPEND invocation
# Do NOT pass --crlf; normalize line endings in the file first.
awk 'sub(/\r?$/,"\r")' message.eml > message.crlf.eml
curl --url 'imaps://mail.example.com/INBOX' \
     --user 'user:pass' \
     --upload-file message.crlf.eml

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.