Dart Smtp Unencrypted Connection
Description
This vulnerability detector identifies SMTP connections that are not encrypted in Dart applications. Unencrypted SMTP connections transmit authentication credentials and email content in plain text, making them vulnerable to man-in-the-middle attacks and credential theft.
Detection Strategy
• Identifies imports of SMTP server functionality from mailer packages in Dart code
• Locates method calls or expressions that create SMTP server connections
• Analyzes the connection configuration to determine if encryption (SSL/TLS) is disabled or not specified
• Reports vulnerabilities when SMTP connections are configured without proper encryption protocols
Vulnerable code example
import 'package:mailer/mailer.dart';
Future<void> sendMail() async {
// VULNERABLE: allowInsecure enables cleartext communication
final server = SmtpServer('smtp.example.com', allowInsecure: true);
await send(Message(), server);
}✅ Secure code example
import 'package:mailer/mailer.dart';
Future<void> sendMail() async {
// SAFE: allowInsecure omitted - enforces STARTTLS and aborts on insecure channels
final server = SmtpServer('smtp.example.com');
await send(Message(), server);
}Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.