Description
aiosmtplib is an asynchronous SMTP client for use with asyncio. Prior to 5.1.2, SMTPProtocol.start_tls in src/aiosmtplib/protocol.py consumes the server's 220 response and starts the TLS handshake without clearing SMTPProtocol._buffer. An active network attacker can place attacker-chosen SMTP response lines after the plaintext 220 response in the same network segment. The method then calls loop.start_tls; those bytes survive the transport upgrade and are parsed as the first response from inside the TLS session, desynchronizing subsequent SMTP command and response pairs. Connections using start_tls=True or opportunistic STARTTLS are affected, while connections using use_tls=True are not. This issue is fixed in version 5.1.2.
Published: 2026-08-20
Score: 5.9 Medium
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

The flaw occurs when the aiosmtplib library starts a TLS handshake after receiving the server’s 220 greeting without clearing the internal buffer. This allows an active network attacker to place additional SMTP response lines between the plaintext 220 reply and the TLS upgrade. Those injected bytes are then parsed as the first response inside the encrypted session, breaking the correspondence between subsequent SMTP commands and responses and opening the door to unintended command execution inside the TLS channel. The weakness is an input handling flaw identified as CWE-74.

Affected Systems

The vulnerability affects Python applications that use the aiosmtplib library prior to version 5.1.2 when configuring the client with start_tls=True or opportunistic STARTTLS for a secure connection. Connections that use the use_tls=True option are unaffected. Any system – such as mail relays, automated email senders, or services relying on aiosmtplib for email delivery – that embeds a vulnerable library version is at risk.

Risk and Exploitability

With a CVSS score of 5.9 the risk is moderate; the EPSS score is not published, and the vulnerability is not listed in the CISA KEV catalog. The likely attack vector is a network attacker on the same segment who can inject additional response lines before the TLS layer is established. Exploitation requires the ability to observe and modify the SMTP traffic between the client and the server, which is feasible on insecure or shared networks. As a result, an attacker could interfere with mail flow or potentially execute arbitrary SMTP commands in an encrypted session.

Generated by OpenCVE AI on August 20, 2026 at 22:00 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade aiosmtplib to version 5.1.2 or newer to eliminate the buffer handling bug
  • Reconfigure the client to use use_tls=True or establish TLS immediately instead of opportunistic STARTTLS, thereby avoiding the vulnerable start_tls path
  • Implement network segmentation or firewall rules to isolate the client–SMTP server path, and consider an additional secure tunnel (VPN) so that attackers cannot inject response lines between the plaintext 220 and the TLS upgrade

Generated by OpenCVE AI on August 20, 2026 at 22:00 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-vxj7-4xrp-5vr4 aiosmtplib: STARTTLS response injection
History

Fri, 21 Aug 2026 12:30:00 +0000

Type Values Removed Values Added
First Time appeared Cole
Cole aiosmtplib
Vendors & Products Cole
Cole aiosmtplib

Thu, 20 Aug 2026 20:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}


Thu, 20 Aug 2026 14:45:00 +0000

Type Values Removed Values Added
Description aiosmtplib is an asynchronous SMTP client for use with asyncio. Prior to 5.1.2, SMTPProtocol.start_tls in src/aiosmtplib/protocol.py consumes the server's 220 response and starts the TLS handshake without clearing SMTPProtocol._buffer. An active network attacker can place attacker-chosen SMTP response lines after the plaintext 220 response in the same network segment. The method then calls loop.start_tls; those bytes survive the transport upgrade and are parsed as the first response from inside the TLS session, desynchronizing subsequent SMTP command and response pairs. Connections using start_tls=True or opportunistic STARTTLS are affected, while connections using use_tls=True are not. This issue is fixed in version 5.1.2.
Title aiosmtplib: STARTTLS response injection
Weaknesses CWE-74
References
Metrics cvssV3_1

{'score': 5.9, 'vector': 'CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N'}


cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-08-20T20:00:21.869Z

Reserved: 2026-06-16T23:11:20.213Z

Link: CVE-2026-55558

cve-icon Vulnrichment

Updated: 2026-08-20T20:00:18.930Z

cve-icon NVD

Status : Received

Published: 2026-08-20T15:17:31.980

Modified: 2026-08-20T20:17:35.560

Link: CVE-2026-55558

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-08-21T12:09:19Z

Weaknesses
  • CWE-74

    Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')