Junglewise Threat Intelligence

CVE-2026-55558: aiosmtplib STARTTLS response injection

CVE-2026-55558 · Severity: medium · CVSS 5.9 · Published 2026-08-27

Executive brief

aiosmtplib is a Python library for sending emails via SMTP. When upgrading a plaintext connection to encrypted (STARTTLS), the library fails to discard buffered data from before the encryption handshake, allowing an attacker on the network to inject forged server responses that appear to come from inside the encrypted session. This could enable an attacker to manipulate email commands and deceive the application about server capabilities or authentication status.

Technical details

This is a protocol injection vulnerability (CWE-74) in aiosmtplib's STARTTLS handling. When the client sends a STARTTLS command to upgrade to TLS, the library reads the server's 220 acknowledgement reply, then immediately performs the TLS handshake while leaving any additional data in the receive buffer untouched. A network-positioned attacker can send the legitimate 220 reply followed by injected SMTP response lines (e.g., fake capabilities or authentication methods) in a single packet. The protocol object and its buffer persist across the plaintext-to-TLS boundary, so these pre-staged plaintext bytes are later parsed as if they arrived inside the encrypted session, desynchronizing all subsequent command/response pairs. The attack requires an active man-in-the-middle (network compromise); passive eavesdropping cannot exploit it. The fix, released in version 5.1.2, treats any buffered data after the 220 response and before the TLS handshake as a protocol violation per RFC 3207 §4.2.

Affected products

  • cole aiosmtplib <= 5.1.1

Timeline

  • 2026-06-20: disclosed: Advisory published by cole/aiosmtplib
  • 2026-06-20: patched: Fix released in version 5.1.2
  • 2026-08-27: advisory: Published to GitHub Advisory Database

References

Related threats