DEV Community

CVE Reports
CVE Reports

Posted on • Originally published at cvereports.com

CVE-2025-15366: CVE-2025-15366: Protocol Command Injection in Python CPython imaplib Standard Library

CVE-2025-15366: Protocol Command Injection in Python CPython imaplib Standard Library

Vulnerability ID: CVE-2025-15366
CVSS Score: 5.9
Published: 2026-01-20

CVE-2025-15366 is a command injection vulnerability in Python's standard imaplib module, occurring due to the improper neutralization of carriage returns (\r), line feeds (\n), and null bytes (\x00). When an application passes user-controlled input into standard IMAP library calls, an attacker can break out of the line-oriented protocol context and execute arbitrary IMAP directives with the privileges of the authenticated session.

TL;DR

A protocol command injection vulnerability exists in Python's standard imaplib library due to a lack of NUL, CR, and LF byte validation in argument serialization. Attackers passing crafted folder or search parameters can inject arbitrary IMAP commands. This has been remediated in updated CPython versions.


⚠️ Exploit Status: POC

Technical Details

  • CWE ID: CWE-77
  • Attack Vector: Network
  • CVSS v4.0 Base Score: 5.9
  • EPSS Score: 0.0036
  • Exploit Status: Proof-of-Concept (PoC)
  • CISA KEV Status: Not Listed
  • Impact: Integrity Compromise (High), Confidentiality (Low)

Affected Systems

  • Python (CPython) Runtime Environment
  • CPython: < 3.13.15 (Fixed in: 3.13.15)
  • CPython: >= 3.14.0, < 3.14.7 (Fixed in: 3.14.7)
  • CPython: >= 3.15.0a1, < 3.15.0a6 (Fixed in: 3.15.0a6)

Code Analysis

Commit: 6262704

Initial patch introducing C0 control character block filter to prevent injection.

Commit: d0921ef

Refined patch narrowing block filter to NUL, CR, and LF, resolving backward compatibility regressions.

Commit: 2981822

Cherry-pick of the refined, narrow fix to the Python 3.14 branch.

Exploit Details

  • GitHub (CPython): Proof-of-Concept testing logic is integrated as part of the official Python test suite within test_imaplib.py

Mitigation Strategies

  • Upgrade the CPython runtime to a patched version (3.13.15+, 3.14.7+, or 3.15.0a6+).
  • Implement a manual validation wrapper that rejects input containing '\x00', '\r', or '\n' prior to invoking imaplib operations.

Remediation Steps:

  1. Identify any usage of python standard library imaplib in the codebase.
  2. Audit external input flows that populate arguments to select, search, or other high-level library calls.
  3. Upgrade the deployment environment's Python interpreter to one of the fixed minor versions.
  4. In corporate setups with legacy code, apply custom sanitization to filter out Carriage Return, Line Feed, and Null byte characters.

References


Read the full report for CVE-2025-15366 on our website for more details including interactive diagrams and full exploit analysis.

Top comments (0)