Security Vulnerability Report
中文
CVE-2026-41319 CVSS 6.5 MEDIUM

CVE-2026-41319

Published: 2026-04-24 04:16:20
Last Modified: 2026-05-21 19:39:07

Description

MailKit is a cross-platform mail client library built on top of MimeKit. A STARTTLS Response Injection vulnerability in versions prior to 4.16.0 allows a Man-in-the-Middle attacker to inject arbitrary protocol responses across the plaintext-to-TLS trust boundary, enabling SASL authentication mechanism downgrade (e.g., forcing PLAIN instead of SCRAM-SHA-256). The internal read buffer in `SmtpStream`, `ImapStream`, and `Pop3Stream` is not flushed when the underlying stream is replaced with `SslStream` during STARTTLS upgrade, causing pre-TLS attacker-injected data to be processed as trusted post-TLS responses. Version 4.16.0 patches the issue.

CVSS Details

CVSS Score
6.5
Severity
MEDIUM
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N

Configurations (Affected Products)

cpe:2.3:a:jstedfast:mailkit:*:*:*:*:*:*:*:* - VULNERABLE
MailKit < 4.16.0

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
/* * Conceptual PoC for STARTTLS Response Injection * This script demonstrates how a MITM can inject data before TLS. */ // Simulating the vulnerable flow in MailKit before 4.16.0 // 1. Client reads data into buffer (Attacker injects here) // 2. Client calls StartTls() // 3. Internal Stream is replaced by SslStream // 4. Buffer is NOT flushed (Vulnerability) // 5. Client reads from buffer, getting Attacker's injected response using System; using System.IO; using System.Net.Sockets; using System.Text; public class VulnerableSmtpClient { Stream networkStream; Stream tlsStream; StringBuilder readBuffer = new StringBuilder(); // Simulating internal buffer public void Connect(string host, int port) { var tcp = new TcpClient(host, port); networkStream = tcp.GetStream(); } // Simulating the read operation that buffers data public string ReadResponse() { // In a real attack, MITM injects "SASL PLAIN" here before TLS byte[] buffer = new byte[1024]; int bytesRead = networkStream.Read(buffer, 0, buffer.Length); string response = Encoding.UTF8.GetString(buffer, 0, bytesRead); readBuffer.Append(response); // Data stays in buffer return response; } public void StartTls() { // Upgrade stream tlsStream = new SslStream(networkStream); ((SslStream)tlsStream).AuthenticateAsClient("example.com"); // VULNERABILITY: readBuffer is not cleared here // The injected data from 'networkStream' is still in 'readBuffer' } public string ReadPostTlsResponse() { // Client expects data from TLS stream, but gets buffered injected data if (readBuffer.Length > 0) { string data = readBuffer.ToString(); readBuffer.Clear(); return data; // Returns injected data thinking it's from secure server } // Read actual TLS data... return ""; } }

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-41319", "sourceIdentifier": "[email protected]", "published": "2026-04-24T04:16:20.400", "lastModified": "2026-05-21T19:39:07.493", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "MailKit is a cross-platform mail client library built on top of MimeKit. A STARTTLS Response Injection vulnerability in versions prior to 4.16.0 allows a Man-in-the-Middle attacker to inject arbitrary protocol responses across the plaintext-to-TLS trust boundary, enabling SASL authentication mechanism downgrade (e.g., forcing PLAIN instead of SCRAM-SHA-256). The internal read buffer in `SmtpStream`, `ImapStream`, and `Pop3Stream` is not flushed when the underlying stream is replaced with `SslStream` during STARTTLS upgrade, causing pre-TLS attacker-injected data to be processed as trusted post-TLS responses. Version 4.16.0 patches the issue."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "baseScore": 6.5, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "REQUIRED", "scope": "UNCHANGED", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "availabilityImpact": "NONE"}, "exploitabilityScore": 2.8, "impactScore": 3.6}, {"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N", "baseScore": 5.9, "baseSeverity": "MEDIUM", "attackVector": "NETWORK", "attackComplexity": "HIGH", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "NONE", "integrityImpact": "HIGH", "availabilityImpact": "NONE"}, "exploitabilityScore": 2.2, "impactScore": 3.6}]}, "weaknesses": [{"source": "[email protected]", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-74"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:jstedfast:mailkit:*:*:*:*:*:*:*:*", "versionEndExcluding": "4.16.0", "matchCriteriaId": "93C4C88D-7A8F-468C-90DE-0BBD8B916D6A"}]}]}], "references": [{"url": "https://github.com/jstedfast/MailKit/security/advisories/GHSA-9j88-vvj5-vhgr", "source": "[email protected]", "tags": ["Exploit", "Vendor Advisory"]}, {"url": "https://github.com/jstedfast/MailKit/security/advisories/GHSA-9j88-vvj5-vhgr", "source": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "tags": ["Exploit", "Vendor Advisory"]}]}}