Summary
Email::Sender::Transport::Sendmail can allow arbitrary command execution on Windows when envelope addresses are incorporated into a shell command. An attacker who controls sender or recipient address data may execute commands with the privileges of the sending process when the message is transmitted.
Affected context
The vulnerability occurs in Email::Sender::Transport::Sendmail on Windows systems before the affected behavior was corrected. On MSWin32, the transport combines the envelope sender and recipients into a command string that is passed through a shell. When no explicit envelope is supplied, Email::Sender::Simple may derive these values from the From, To, and Cc headers, making attacker-controlled message addresses relevant to exploitation.
Exploit preconditions
- Attack surface: Email sending through the Sendmail transport on Windows
- Required access: Ability to influence an envelope address or, when the envelope is omitted, relevant From, To, or Cc header values
- Trigger point: Message transmission through the Windows
_sendmail_pipepath - Why exploitation is possible: Address data is incorporated into a shell-interpreted command string rather than being passed as safely separated process arguments
Why this happens
The underlying bug is command construction from untrusted address data. On Windows, the transport passes a single command string to open(), allowing shell metacharacters or command syntax contained in envelope addresses to be interpreted by the operating system. This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, commonly called OS command injection. Other platforms use a list-form invocation, which avoids this specific shell interpretation pattern.
Potential impact
- An attacker could execute arbitrary commands on the sending host
- The sending process could be used to access local files, credentials, or services
- The application account could be compromised
- Malicious activity could affect downstream mail workflows or connected systems
- A compromised service could be used for lateral movement, depending on its privileges and network access
General mitigation guidance
Mitigation focuses on preventing message-derived address data from becoming shell syntax.
Common defensive patterns include:
- Using direct process execution with separated argument lists rather than shell-interpreted command strings
- Treating envelope and header addresses as untrusted input, even when they originate from a message model
- Applying strict address parsing, normalization, and allowlist-based validation before invoking external mail transports
- Separating transport configuration from user-controlled message fields
- Running mail-sending processes with the minimum filesystem, network, and operating-system privileges
- Applying platform-specific security policies that prevent unnecessary shell access
These controls reduce exposure without relying solely on input filtering.
How teams detect issues like this
Detection can include static analysis and review rules that flag:
- Construction of shell command strings from email headers or envelope addresses
- Use of
open()or equivalent APIs in command-string mode - External process execution where user-controlled values are concatenated into arguments
- Platform-specific branches that invoke a shell instead of a list-form process API
Code review should trace address data from message creation through transport invocation. Runtime monitoring can also alert on unexpected child processes spawned by mail-sending services, while CI policy checks can prohibit shell-based process execution for untrusted values. Automated code review tools may help identify these patterns.

