BIT-libpython-2025-15366: IMAP command injection in user-controlled commands
The imaplib module, when passed a user-controlled command, can have additional commands injected using newlines. Mitigation rejects commands containing control characters.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
Reject IMAP commands containing control characters, including newlines, before passing user-controlled commands to the imaplib module.
Event History
Frequently Asked Questions
Which applications are exposed?
Applications are exposed when they pass user-controlled values as IMAP commands through Python's imaplib module. Code that does not allow an attacker to influence the command is not described as affected.
What does an attacker need to exploit this issue?
An attacker needs control over an IMAP command value supplied to imaplib and must be able to include newline or other control characters. Those characters can be used to inject additional IMAP commands.
What can be done if the mitigation is not yet deployed?
Do not pass untrusted input directly as an IMAP command. Reject command values containing control characters, including newlines, before they reach imaplib.