CVE-2021-38189

9.8 CRITICAL

📋 TL;DR

This vulnerability in the lettre Rust crate allows attackers to inject arbitrary SMTP commands into email message bodies. By placing a period character after two CRLF sequences, attackers can bypass input validation and execute unauthorized commands on SMTP servers. This affects any Rust application using lettre versions before 0.9.6 for sending email.

💻 Affected Systems

Products:
  • lettre Rust crate
Versions: All versions before 0.9.6
Operating Systems: All operating systems running Rust applications with lettre
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications using lettre to send email. Reading/parsing email is not affected.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution on SMTP servers, email spoofing, data exfiltration, or complete system compromise through command injection.

🟠

Likely Case

Email spoofing, unauthorized email sending, SMTP command manipulation leading to service disruption or information disclosure.

🟢

If Mitigated

Limited impact with proper input validation and SMTP server hardening, potentially only causing email formatting issues.

🌐 Internet-Facing: HIGH - Applications sending email to external addresses are directly exposed to attack vectors.
🏢 Internal Only: MEDIUM - Internal email systems could be compromised if attackers gain internal network access.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploit requires ability to control email message body content. Public advisory includes technical details.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: lettre 0.9.6 and later

Vendor Advisory: https://rustsec.org/advisories/RUSTSEC-2021-0069.html

Restart Required: Yes

Instructions:

1. Update Cargo.toml to specify 'lettre = "^0.9.6"' or higher. 2. Run 'cargo update lettre'. 3. Rebuild and redeploy your application. 4. Restart any running services using the updated application.

🔧 Temporary Workarounds

Input validation filter

all

Add custom validation to filter or escape CRLF sequences followed by periods in email message bodies

// Rust code example: let sanitized_body = body.replace("\r\n\r\n.", "\r\n\r\n ");

Use alternative email library

all

Temporarily switch to a different Rust email library while waiting for patching

// In Cargo.toml: replace 'lettre' dependency with alternative like 'rust-imap' or 'async-smtp'

🧯 If You Can't Patch

  • Implement network segmentation to isolate SMTP servers from untrusted networks
  • Deploy WAF or application firewall rules to block email messages containing suspicious CRLF patterns

🔍 How to Verify

Check if Vulnerable:

Check Cargo.lock or run 'cargo tree | grep lettre' to see installed version. If version is below 0.9.6, you are vulnerable.

Check Version:

cargo tree | grep lettre | head -1

Verify Fix Applied:

After update, verify with 'cargo tree | grep lettre' shows version 0.9.6 or higher. Test email sending functionality works correctly.

📡 Detection & Monitoring

Log Indicators:

  • Unusual SMTP commands in email server logs
  • Multiple failed email sending attempts with malformed bodies
  • Unexpected command execution in application logs

Network Indicators:

  • SMTP traffic containing CRLF.CRLF patterns
  • Unusual outbound email volume from applications
  • SMTP command injection patterns in network captures

SIEM Query:

source="*smtp*" AND ("\r\n\r\n." OR "command injection" OR "unexpected command")

🔗 References

📤 Share & Export