Security Advisory – Node.js – Nodemailer
Nodemailer Vulnerability Fix: GHSA-p6gq-j5cr-w38f – File Read and Full-Response SSRF via the raw Option
This Nodemailer vulnerability fix is one every Node.js team sending email needs to apply now. Advisory
GHSA-p6gq-j5cr-w38f
discloses a high-severity vulnerability that allows attackers to read arbitrary files from your server and perform full-response SSRF – all through the message-level raw option. The fix itself is one command per project. The hard part is knowing where all your Nodemailer installs are.
What Is the Nodemailer Vulnerability Fix for GHSA-p6gq-j5cr-w38f?
The Nodemailer vulnerability fix for GHSA-p6gq-j5cr-w38f addresses a security flaw in how Nodemailer handles the message-level raw option. This option is designed to allow passing a pre-formed raw email message directly to the transport layer. The problem is that in unpatched versions, using raw at the message level bypasses the disableFileAccess and disableUrlAccess security flags entirely.
These flags exist specifically to prevent Nodemailer from reading local files or making outbound HTTP requests during email composition. When an attacker can influence the raw field of an outgoing message – whether directly through an API parameter or indirectly through a template, subject line, or any user-controlled input that reaches email composition – they can:
- Read arbitrary files from the server – including
.envfiles containing database credentials and API keys, private TLS certificates,/etc/passwd, SSH keys, and any other file accessible to the Node.js process - Perform full-response SSRF – force the server to make HTTP requests to internal services (localhost APIs, internal databases, cloud metadata endpoints like the AWS EC2 instance metadata service at
169.254.169.254) and receive the complete response back through the email
Critical Point
Setting disableFileAccess: true or disableUrlAccess: true does not protect against this vulnerability in unpatched versions. The raw option bypass was the entire issue – those flags were rendered ineffective at the message level. The only Nodemailer vulnerability fix is upgrading to version 9.0.1 or above.
Nodemailer Version Status at a Glance
No CVE has been assigned to GHSA-p6gq-j5cr-w38f as of publication, so it is tracked only by its GitHub Security Advisory ID. That also means npm audit may not surface it consistently – checking your installed version directly is the more reliable way to confirm the Nodemailer vulnerability fix is in place.
| Version | Branch | Status |
|---|---|---|
| nodemailer 6.x | v6 | Vulnerable |
| nodemailer 7.x | v7 | Vulnerable |
| nodemailer 8.x | v8 | Vulnerable |
| nodemailer ≤ 9.0.0 | v9 | Vulnerable |
| nodemailer 9.0.1+ | v9 | Patched |
Are You Affected? How to Confirm You Need the Nodemailer Vulnerability Fix
You are affected if any of the following apply:
- Your project uses Nodemailer version 9.0.0 or below – this includes every 6.x, 7.x, and 8.x release, not just older ones
- You set
disableFileAccessordisableUrlAccessand rely on those flags for security - User-supplied data can reach the
rawmessage option – even indirectly through template variables, dynamic subject lines, or any email composition parameter
Check your installed version
Check Nodemailer version – inside your project directory
# Check the version in your project npm list nodemailer # Or read the package.json directly cat node_modules/nodemailer/package.json | grep '"version"'
Scan the entire server for all Nodemailer installs
This is the step most teams skip – and the one that leaves servers exposed. Nodemailer may be installed in multiple projects, backup directories, staging environments, or old project copies on the same server. A single unpatched install is a risk, even if the vulnerability has no CVE attached to draw attention to it.
Full server scan – finds every Nodemailer install
# Find all Nodemailer installations on the server find / -path "*/node_modules/nodemailer" -type d 2>/dev/null # Check the version of every install found for dir in $(find / -path "*/node_modules/nodemailer" -type d 2>/dev/null); do echo "--- $dir ---" cat "$dir/package.json" | grep '"version"' | head -1 done
Why This Matters
Attackers do not care which environment they exploit. A vulnerable Nodemailer install in a staging directory or old project backup on the same server has access to the same filesystem and internal network as your production application. Scan everything.
How to Apply the Nodemailer Vulnerability Fix – Step by Step
Update Nodemailer in each affected project
Run this inside each project directory. This upgrades straight to the patched 9.0.1+ release regardless of which older major version you are currently on.
Single project update
cd /var/www/your-project npm install nodemailer@latest # Verify the version after update npm list nodemailer # Should show 9.0.1 or higher
Update across multiple projects at once
If Nodemailer is installed in multiple projects on the same server, update them all in one pass rather than manually switching directories.
Batch update across multiple projects
for dir in \ "/var/www/project1" \ "/var/www/project2" \ "/var/www/project3"; do echo "--- Updating $dir ---" cd "$dir" && npm install nodemailer@latest done
Verify every install has the fix
After updating, confirm no vulnerable installs remain on the server. This scan covers your project directories – adjust the path to match your server layout.
Verification scan after patching
for dir in $(find /var/www -path "*/node_modules/nodemailer" \
-type d 2>/dev/null); do
echo "--- $dir ---"
cat "$dir/package.json" | grep '"version"' | head -1
done
# Every result should show 9.0.1 or higher
Run a full npm audit while you are at it
A security incident is the right time to surface everything else in your dependency tree that needs attention. Run a full audit on each project – but remember npm audit alone may not catch GHSA-p6gq-j5cr-w38f since it currently has no CVE, so don’t treat a clean audit as confirmation the Nodemailer vulnerability fix is applied.
Full dependency audit
# Surface all vulnerabilities in the dependency tree npm audit # Fix issues that can be resolved without breaking changes npm audit fix # Fix remaining issues that require major version bumps # WARNING: test your app after running this npm audit fix --force
Before Running –force
npm audit fix --force may introduce breaking changes. Common ones on Node.js projects include bcrypt upgrading from v5 to v6 – which drops support for Node.js versions below 18 – and major version bumps in nodemon, imap, and other dependencies. Always run your test suite after using --force on a production codebase.
Test bcrypt if it was upgraded
If npm audit fix --force upgraded bcrypt from v5 to v6, verify it is working correctly before restarting production processes. bcrypt v6 requires Node.js 18 or higher.
bcrypt verification test
node -e "
const bcrypt = require('bcrypt');
bcrypt.hash('test', 10)
.then(h => bcrypt.compare('test', h))
.then(r => console.log(
r ? 'bcrypt working correctly' : 'bcrypt broken - check Node.js version'
));
"
Restart your Node.js processes
Updated packages do not take effect until the Node.js process is restarted. The old vulnerable version remains loaded in memory until you do this.
Restart commands by process manager
# PM2 - restart all apps pm2 restart all # PM2 - restart a specific app pm2 restart your-app-name # systemctl sudo systemctl restart your-app-name # Docker Compose docker compose down && docker compose up -d
What This Vulnerability Actually Enables – and Why the Nodemailer Fix Matters
The combination of arbitrary file read and full-response SSRF in a single vulnerability makes GHSA-p6gq-j5cr-w38f more dangerous than either capability alone.
Arbitrary file read in practice
A Node.js application’s process has filesystem access scoped to what the OS user running it can read. On many production servers, this includes .env files containing database connection strings and third-party API credentials, SSL/TLS private keys, application secrets and session signing keys, and internal configuration files referencing other services. A successful exploit leaks every credential the application has access to – not just the one the attacker was looking for.
Full-response SSRF in practice
SSRF through Nodemailer returns the complete HTTP response in the email body. This means an attacker gets not just the ability to probe internal network topology – they receive the actual response content from internal services. On cloud infrastructure, this includes AWS EC2 instance metadata at 169.254.169.254/latest/meta-data/, which can expose IAM role credentials, allowing full AWS account compromise from a Node.js email vulnerability.
Attack Chain
Exploit the raw option bypass → read /app/.env → obtain AWS credentials from env vars → assume IAM role → access S3 buckets, RDS instances, and other AWS services. This is a realistic attack chain on common Node.js production infrastructure. The entry point is a Nodemailer version check that was never made.
Four Lessons From This Nodemailer Vulnerability
Security flags are not bulletproof
The disableFileAccess and disableUrlAccess options gave a false sense of security. Setting a security flag and assuming it covers all code paths is the kind of assumption that produces vulnerabilities like this one. Always validate and sanitize user input before it reaches any email composition logic regardless of what flags are set.
Scan all installs, not just the obvious ones
A library installed in a backup directory, staging environment, or old project copy is just as exploitable as the production install. The full server scan command above catches everything. Run it now even if you think you already applied the Nodemailer vulnerability fix elsewhere – it takes under 10 seconds.
No CVE doesn’t mean no urgency
GHSA-p6gq-j5cr-w38f has no CVE assigned, which means some scanners and dependency feeds may not flag it automatically. A vulnerability disclosed today affects packages installed months ago whether or not it has a CVE number. Running npm audit plus a manual version check as part of every deployment pipeline surfaces issues like this before attackers find them first.
Node.js version matters for patched packages
Running Node.js 18 or higher gives access to the latest patched versions of ecosystem packages including bcrypt v6. As of mid-2026, Node.js 22 is in Maintenance LTS and Node.js 24 is Active LTS – either is a reasonable production target, with 24 the safer long-term choice. Running an end-of-life Node.js version (18 and 20 are both now past their EOL dates) constrains which security patches you can install without breaking your dependency tree.
Nodemailer Vulnerability Fix: Frequently Asked Questions
What is the Nodemailer vulnerability GHSA-p6gq-j5cr-w38f?
GHSA-p6gq-j5cr-w38f is a high-severity vulnerability where the message-level raw option in Nodemailer bypasses the disableFileAccess and disableUrlAccess security flags. An attacker who can influence the raw field can read arbitrary files from the server and perform full-response SSRF. The Nodemailer vulnerability fix is available in version 9.0.1; all versions 9.0.0 and below are affected, and no CVE has been assigned.
Which Nodemailer versions need the fix?
All versions 9.0.0 and below are vulnerable – that covers every 6.x, 7.x, 8.x, and pre-9.0.1 release, not just old ones. Run npm list nodemailer in your project directory to check. The Nodemailer vulnerability fix landed in version 9.0.1, so anything below that needs updating.
Does setting disableFileAccess protect against this vulnerability?
No. The vulnerability exists specifically because the raw option bypasses both disableFileAccess and disableUrlAccess in unpatched versions. These flags are ineffective at the message level in affected versions. The only Nodemailer vulnerability fix is upgrading to version 9.0.1 or above.
Can the vulnerability be exploited if user input never directly touches the raw option?
The risk depends on whether user-supplied data can reach email composition logic anywhere in the request path. Template variables, subject lines, attachment content, and any user-controlled input that populates message construction may create an indirect path to the raw option through a library wrapper or template engine. After applying the Nodemailer vulnerability fix, audit all code paths where user input influences outgoing email construction.
What is SSRF and why is it dangerous here?
Server-Side Request Forgery forces a server to make HTTP requests on an attacker’s behalf. In GHSA-p6gq-j5cr-w38f, the full response is returned through the email – meaning attackers can reach internal services inaccessible from the public internet, including cloud metadata endpoints like the AWS EC2 instance metadata service at 169.254.169.254, which can expose IAM credentials and lead to full cloud account compromise.
Do I need to restart my app after applying the Nodemailer vulnerability fix?
Yes. Updated npm packages do not take effect until the Node.js process is restarted. The old vulnerable version remains loaded in memory. Use pm2 restart all for PM2-managed apps, sudo systemctl restart your-app-name for systemctl, or docker compose down && docker compose up -d for Docker.
Has a CVE been assigned to this vulnerability?
No. As of publication, GHSA-p6gq-j5cr-w38f has no CVE and is tracked only by its GitHub Security Advisory ID. That means npm audit and some dependency scanners may not surface it automatically – checking your installed Nodemailer version directly is the safest way to confirm the fix is in place.
Running Node.js Applications in Production?
The Orange Club builds and maintains production Node.js applications for businesses in Dubai and the UAE – with dependency auditing, security patching, and monitoring built into every engagement. If your Node.js stack needs the Nodemailer vulnerability fix applied, or a broader security review, talk to our web development team.
See Our Web Development Services →
Leave a Reply