Mar 27, 2026·6 min read·33 visits
A critical vulnerability in Nodemailer allows for SMTP command injection. Attackers controlling the `envelope.size` parameter can append CRLF characters to inject unauthorized SMTP commands, leading to unauthorized email routing and potential spam distribution.
Nodemailer, a widely utilized Node.js package for email transmission, contains a critical input validation vulnerability. The software fails to sanitize the `envelope.size` parameter, permitting attackers to inject arbitrary SMTP commands via CRLF sequences. This flaw facilitates unauthorized email distribution, bypassing of application-level recipient controls, and internal SMTP reconnaissance.
Nodemailer operates as a fundamental routing library for Node.js applications requiring electronic mail transmission capabilities. The software interfaces directly with upstream SMTP servers to negotiate message delivery, handling protocol-level commands on behalf of the application. GHSA-C7W3-X93F-QMM8 identifies a critical input validation flaw within the core SMTP connection handler.
The vulnerability allows threat actors to perform SMTP command injection via improper neutralization of CRLF sequences. This class of flaw, categorized under CWE-93, occurs when an application accepts untrusted input containing carriage return and line feed characters without appropriate sanitization. Because SMTP relies on these specific control characters to delineate commands, unsanitized input directly compromises the integrity of the protocol stream.
Applications become vulnerable when they expose the Nodemailer envelope configuration to external input. Threat actors exploit this pathway to append unauthorized commands to the active SMTP session. The resulting exploitation enables actions fundamentally outside the intended design of the vulnerable application, including sending unauthenticated spam or conducting localized reconnaissance.
The vulnerability originates in the lib/smtp-connection/index.js module during the construction of the MAIL FROM command sequence. When an upstream SMTP server advertises support for the SIZE extension (defined in RFC 1870), Nodemailer automatically appends the declared message size to the sender address declaration. The software extracts this size value directly from the user-provided envelope.size property.
The core failure lies in the implementation utilizing direct string concatenation without prior type validation or sanitization. The vulnerable codebase executes args.push('SIZE=' + this._envelope.size). Because the size variable accepts arbitrary strings, it can contain the carriage return and line feed characters (\r\n) required to terminate an SMTP command.
When Nodemailer transmits the concatenated string, the receiving SMTP server processes the injected CRLF sequence as the definitive end of the MAIL FROM transmission. The server immediately interprets any subsequent characters in the string as an entirely new, distinct SMTP command. This structural failure breaks the assumed boundary between application data and protocol control instructions.
The patch resolves the vulnerability by strictly enforcing data types on the envelope.size parameter. The developers replaced the direct string concatenation with a robust type coercion mechanism. The patched implementation passes the input through the standard JavaScript Number() function before evaluation.
// Vulnerable Implementation
if (this._envelope.size && this._supportedExtensions.includes('SIZE')) {
args.push('SIZE=' + this._envelope.size);
}The original code merely checked for the truthiness of this._envelope.size. Any non-empty string, including an injection payload, satisfied this condition and entered the command stream. The updated logic forces the input into a numeric context.
// Patched Implementation
if (this._envelope.size && this._supportedExtensions.includes('SIZE')) {
const sizeValue = Number(this._envelope.size) || 0;
if (sizeValue > 0) {
args.push('SIZE=' + sizeValue);
}
}If an attacker submits a payload containing command injection sequences such as 100\r\nRCPT TO:<evil@example.com>, the Number() coercion evaluates the entire string. Because the string contains non-numeric characters, the evaluation strictly returns NaN (Not-a-Number). The subsequent logical OR operation (|| 0) defaults the result to zero. Finally, the conditional check if (sizeValue > 0) fails, preventing the system from appending the malformed SIZE extension entirely.
Attackers exploit this vulnerability by manipulating application inputs that map directly to the Nodemailer envelope configuration. The primary prerequisite involves locating an application endpoint that accepts arbitrary values for the size parameter and passes them unvalidated to the send() function. This typically manifests in custom mailer integrations or APIs designed to handle complex email routing.
The attacker constructs a targeted payload consisting of a valid integer, a CRLF sequence, and a secondary SMTP command. A standard payload takes the form of 100\r\nRCPT TO:<injected@evil.com>. When the application processes this input, the Nodemailer client transmits a fragmented command string to the upstream mail server.
The receiving SMTP server processes the first segment (MAIL FROM:<legit@app.com> SIZE=100) as a complete, syntactically valid command. It then interprets the subsequent line (RCPT TO:<hacker@evil.com>) as a distinct command originating from the authenticated client. This execution flow entirely bypasses any recipient limitations enforced by the Node.js application layer.
Successful exploitation grants an attacker arbitrary command execution within the context of the established SMTP session. The most direct consequence involves unauthorized email distribution. Threat actors utilize the application's authenticated, trusted SMTP session to originate spam or targeted phishing campaigns, effectively laundering their attacks through the victim's infrastructure.
By injecting supplementary RCPT TO commands, attackers bypass application-level recipient restrictions. Applications designed to send password resets or notifications strictly to registered users can be coerced into delivering those sensitive communications to external, attacker-controlled addresses. This facilitates data exfiltration and account takeover scenarios depending on the email content.
Furthermore, attackers utilize this vector to conduct internal reconnaissance against the SMTP infrastructure. Threat actors can inject commands such as VRFY or EXPN to enumerate internal mailing lists and user accounts. If the SMTP server possesses access to isolated network segments, the vulnerability serves as a pivot point for broader infrastructure mapping.
System administrators and developers must upgrade the nodemailer package to a release incorporating commit 2d7b9710e63555a1eb13d721296c51186d4b5651. This update ensures the library natively coerces the size parameter into a safe numeric format, neutralizing the injection vector at the library level. Organizations should verify their dependency trees to ensure secondary packages utilizing Nodemailer are similarly updated.
As a crucial defense-in-depth measure, applications should implement strict input validation on all user-supplied data destined for the mail envelope. Developers must ensure that all SMTP parameters, including from, to, and size, strictly reject inputs containing carriage return (\r) or line feed (\n) characters. Relying solely on downstream libraries for protocol sanitization violates core secure design principles.
Security operations teams should monitor upstream SMTP server logs for anomalous command sequences. Specifically, defenders should baseline typical application behavior and alert on sessions generating multiple, unexpected MAIL FROM or RCPT TO commands in rapid succession. High volumes of rejected commands within a single authenticated session often indicate active exploitation attempts against this protocol layer.
| Product | Affected Versions | Fixed Version |
|---|---|---|
Nodemailer Nodemailer | < patched release (commit 2d7b9710e6) | Commit 2d7b9710e63555a1eb13d721296c51186d4b5651 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-93, CWE-150, CWE-20 |
| Attack Vector | Network |
| Impact | SMTP Command Injection / Unauthorized Email Routing |
| Vulnerable Component | lib/smtp-connection/index.js (envelope.size handling) |
| Exploit Status | Proof-of-Concept |
| CISA KEV Status | Not Listed |
Improper Neutralization of CRLF Sequences ('CRLF Injection')
CVE-2026-48861 is a client-side HTTP request-line CRLF (Carriage Return Line Feed) injection vulnerability in the popular Elixir HTTP client library, Mint. The vulnerability permits HTTP Request Splitting and HTTP Request Smuggling when an application forwards untrusted, attacker-controlled inputs to Mint's HTTP client requests as either the HTTP request method or target. By embedding CRLF characters within these parameters, an attacker can terminate the request line prematurely, inject malicious headers, or pipeline entirely independent requests. These smuggled requests are then processed by upstream or downstream proxy servers as separate HTTP queries on the same TCP connection. While Mint version 1.7.0 introduced target validation to secure the request target, the HTTP request method parameter remained completely unvalidated. This flaw allows attackers to bypass routing filters, access restricted internal APIs, or poison HTTP caches under default configurations.
An Inconsistent Interpretation of HTTP Requests (HTTP Request/Response Smuggling) vulnerability in the Elixir Mint HTTP client allows attacker-controlled HTTP/1 servers to desynchronize response framing on shared connections due to over-lenient parsing of sign-prefixed Content-Length headers.
An allocation of resources without limits or throttling vulnerability in Elixir Mint allows an attacker-controlled HTTP/2 server to exhaust memory in a Mint client. The vulnerability is exploited by sending a HEADERS frame without the END_HEADERS flag followed by an infinite stream of CONTINUATION frames. Because the client lacks limits on the incoming header-block accumulator, the client continuously consumes memory until an out-of-memory crash occurs.
CVE-2026-48596 is an Improper Neutralization of CRLF Sequences in HTTP Headers (HTTP Request/Response Splitting, CWE-113) in the Elixir Tesla HTTP client. The flaw resides in how multipart content-type parameters are joined and serialized, enabling attackers to inject arbitrary headers or split HTTP requests when applications pass untrusted inputs to the parameters of multipart uploads.
An improper handling of highly compressed data (decompression bomb) vulnerability exists in the Elixir Tesla HTTP client when utilizing response decompression middlewares. By serving highly compressed responses or stacked content-encoding headers, a malicious server can cause arbitrary heap exhaustion, leading to a denial of service (DoS) crash in the BEAM virtual machine.
A high-severity security vulnerability in Elixir's Tesla HTTP client library (CVE-2026-48595) allows unauthenticated remote attackers to harvest sensitive credentials, including Authorization headers and cookies. The flaw resides in the 'Tesla.Middleware.FollowRedirects' component, which performs case-sensitive lookups when stripping credentials during cross-origin redirects. Because HTTP headers are case-insensitive by RFC specifications, standard canonical casing (e.g., 'Authorization') bypasses the lowercase-only blocklist, leaking tokens to untrusted external redirect destinations.