Critical Command Injection Vulnerability in Nodemailer Package
Summary
CVE-2020-7769: This affects the package nodemailer before 6.4.16. Affects node-nodemailer across 2 version ranges.
< 6.4.16-1
< ba31c64c910d884579875c52d57ac45acc47aa54
Fixed in 6.4.16-1. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Nodemailer is a popular Node.js module used for sending emails. It simplifies the process of email creation and delivery, supporting various transport methods, including SMTP and sendmail. The package is widely utilized in web applications for sending notifications, alerts, and user communications. However, a vulnerability has been identified in versions prior to 6.4.16, which could allow attackers to exploit crafted recipient email addresses.
Vulnerability Detail
The vulnerability, identified as CVE-2020-7769, arises from the improper handling of recipient email addresses in the sendmail transport method of Nodemailer. Attackers can inject arbitrary command flags through specially crafted email addresses, potentially leading to unauthorized command execution on the server. This could result in data breaches, service disruptions, or unauthorized access to sensitive information. The vulnerability has a CVSS score of 9.8, indicating its critical severity.
How To Fix
Minimum fixed version
6.4.16-1
This is the first release that contains the fix.
sudo apt-get install --only-upgrade node-nodemailer
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If upgrading is not immediately feasible, a temporary workaround is to validate and sanitize recipient email addresses before passing them to the Nodemailer sendmail transport. This can help mitigate the risk of command injection. Example code for validation:
const validateEmail = (email) => {
const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
return regex.test(email);
};
if (validateEmail(recipientEmail)) {
// Proceed with sending email
} else {
// Handle invalid email address
}
Conclusion
The CVE-2020-7769 vulnerability in the Nodemailer package poses a significant risk due to its potential for command injection through email addresses. It is crucial for users to upgrade to version 6.4.16 or later to secure their applications. In the interim, validating email addresses can help mitigate risks.
See every vulnerability recorded for node-nodemailer →
FAQ
CVE-2020-7769 is a critical vulnerability in the Nodemailer package that allows for command injection through crafted recipient email addresses.
You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without any signup.
All versions of Nodemailer prior to 6.4.16 are affected by this vulnerability.
If an immediate upgrade is not possible, validate and sanitize recipient email addresses to mitigate the risk of command injection.
The CVSS score of CVE-2020-7769 is 9.8, indicating a critical level of severity.
Related vulnerabilities
Recent vulnerabilities recorded for node-nodemailer.