CVE-2021-38189
Description
An issue was discovered in the lettre crate before 0.9.6 for Rust. In an e-mail message body, an attacker can place a . character after two sequences and then inject arbitrary SMTP commands.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
SMTP command injection in lettre crate before 0.9.6 allows attackers to inject arbitrary SMTP commands via a crafted message body with double CRLF sequences.
Vulnerability
The lettre crate for Rust (versions prior to 0.9.6 and prior to 0.10.0-rc.3) contains a SMTP command injection vulnerability in its ClientCodec module. The code that escapes lines starting with a period (.) did not properly handle multiple consecutive ` sequences. By placing a period after two ` sequences in the email body, an attacker could break out of the message data and inject arbitrary SMTP commands. [2][3][4]
Exploitation
An attacker can send a crafted email message containing a body that includes two consecutive `` sequences followed by a period and then arbitrary SMTP commands. No special authentication or network position is required beyond being able to send an email via an application using the vulnerable lettre versions. The attacker controls the message body content, and the injection occurs during the SMTP transmission when the library encodes the message. [2][4]
Impact
Successful exploitation allows the attacker to inject arbitrary SMTP commands into the SMTP session, potentially enabling actions such as sending additional emails, bypassing authentication, or performing other SMTP-level operations depending on the server's capabilities. This is a high-severity issue with CVSS score not specified but categorized as a format injection vulnerability. [3][4]
Mitigation
The vulnerability is fixed in lettre versions 0.9.6 and 0.10.0-rc.3. Users should upgrade to these or later versions. For versions before 0.7.0, the issue may not apply as per advisory. No workaround is available other than patching. [3][4]
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
lettrecrates.io | >= 0.7.0, < 0.9.6 | 0.9.6 |
Affected products
2- lettre/lettredescription
Patches
18bfc20506cc5fix(transport-smtp): Fix transparency codec - 0.9.x (#628)
1 file changed · +11 −2
lettre/src/smtp/client/mod.rs+11 −2 modified@@ -51,7 +51,15 @@ impl ClientCodec { match self.escape_count { 0 => self.escape_count = if *byte == b'\r' { 1 } else { 0 }, 1 => self.escape_count = if *byte == b'\n' { 2 } else { 0 }, - 2 => self.escape_count = if *byte == b'.' { 3 } else { 0 }, + 2 => { + self.escape_count = if *byte == b'.' { + 3 + } else if *byte == b'\r' { + 1 + } else { + 0 + } + } _ => unreachable!(), } if self.escape_count == 3 { @@ -286,6 +294,7 @@ mod test { let mut buf: Vec<u8> = vec![]; assert!(codec.encode(b"test\r\n", &mut buf).is_ok()); + assert!(codec.encode(b"test\r\n\r\n", &mut buf).is_ok()); assert!(codec.encode(b".\r\n", &mut buf).is_ok()); assert!(codec.encode(b"\r\ntest", &mut buf).is_ok()); assert!(codec.encode(b"te\r\n.\r\nst", &mut buf).is_ok()); @@ -296,7 +305,7 @@ mod test { assert!(codec.encode(b"test", &mut buf).is_ok()); assert_eq!( String::from_utf8(buf).unwrap(), - "test\r\n..\r\n\r\ntestte\r\n..\r\nsttesttest.test\n.test\ntest" + "test\r\ntest\r\n\r\n..\r\n\r\ntestte\r\n..\r\nsttesttest.test\n.test\ntest" ); }
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
6- github.com/advisories/GHSA-qc36-q22q-cjw3ghsaADVISORY
- github.com/lettre/lettre/commit/8bfc20506cc5e098fe6eb3d1cafe3bea791215ceghsaWEB
- github.com/lettre/lettre/pull/627/commits/93458d01fed0ec81c0e7b4e98e6f35961356fae2ghsaWEB
- github.com/lettre/lettre/security/advisories/GHSA-qc36-q22q-cjw3ghsaWEB
- raw.githubusercontent.com/rustsec/advisory-db/main/crates/lettre/RUSTSEC-2021-0069.mdmitrex_refsource_MISC
- rustsec.org/advisories/RUSTSEC-2021-0069.htmlghsax_refsource_MISCWEB
News mentions
0No linked articles in our index yet.