Executive brief
A vulnerability in Python's standard IMAP library could allow an attacker to inject unauthorized commands into an email session. If an application uses this library to process user-provided input without proper validation, an attacker could potentially manipulate email data or perform unauthorized actions on a mail server. This issue primarily affects systems where users can influence the specific commands sent to an IMAP server.
Technical details
A command injection vulnerability exists in the imaplib module of CPython. The module failed to properly neutralize control characters, specifically newlines (CR/LF), when processing user-supplied input for IMAP commands. An attacker with the ability to influence command arguments can inject additional, unintended IMAP commands into the protocol stream. The fix involves implementing a check that rejects commands containing NUL, CR, or LF characters. This vulnerability is tracked as CWE-77 (Command Injection).
Affected products
- Python Software Foundation CPython < 3.15.0a6
Timeline
- 2026-01-16: disclosed: Issue reported and initial PR created in CPython repository.
- 2026-01-20: patched: Initial fix merged into CPython main branch.
- 2026-01-20: advisory: Official security announcement via Python security-announce mailing list.
References
- https://github.com/python/cpython/commit/6262704b134db2a4ba12e85ecfbd968534f28b45
- https://github.com/python/cpython/commit/d0921efb665aff26b378f495e5ff84f7e3fe649d
- https://github.com/python/cpython/commit/f2cd7ef89aa8a0dcbc7283bbd39548b76f2a736a
- https://github.com/python/cpython/issues/143921
- https://github.com/python/cpython/pull/143922
- https://mail.python.org/archives/list/security-announce@python.org/thread/DD7C7JZJYTBXMDOWKCEIEBJLBRU64OMR/