CVE-2016-10074

Source: cve@mitre.org

HIGH
7.5
Published: December 30, 2016 at 07:59 PM
Modified: April 12, 2025 at 10:46 AM

Vulnerability Description

The mail transport (aka Swift_Transport_MailTransport) in Swift Mailer before 5.4.5 might allow remote attackers to pass extra parameters to the mail command and consequently execute arbitrary code via a \" (backslash double quote) in a crafted e-mail address in the (1) From, (2) ReturnPath, or (3) Sender header.

CVSS Metrics

Base Score
7.5
Severity
HIGH
Vector String
AV:N/AC:L/Au:N/C:P/I:P/A:P

Weaknesses (CWE)

Source: nvd@nist.gov

AI Security Analysis

01 // Technical Summary

Swift Mailer versions prior to 5.4.5 are vulnerable to a critical remote code execution (RCE) flaw. Attackers can inject malicious commands through crafted email headers, leading to complete system compromise by executing arbitrary code on the server.

02 // Vulnerability Mechanism

Step 1: Payload Creation: The attacker crafts an email with a malicious email address in the From, ReturnPath, or Sender header. This crafted address includes a backslash-escaped double quote (\") followed by shell commands (e.g., "; whoami;").

Step 2: Email Submission: The attacker submits the crafted email to a vulnerable application using Swift Mailer.

Step 3: Swift Mailer Processing: The vulnerable Swift Mailer library processes the email and attempts to send it using the mail() command.

Step 4: Command Injection: The mail() command receives the malicious email address as an argument. Due to the lack of proper sanitization, the injected shell commands are executed.

Step 5: Code Execution: The injected shell commands are executed on the server, allowing the attacker to execute arbitrary code and potentially gain full control of the system.

03 // Deep Technical Analysis

The vulnerability stems from insufficient input validation within the Swift_Transport_MailTransport class. Specifically, the code fails to properly sanitize email addresses provided in the From, ReturnPath, or Sender headers before passing them to the mail() command. The use of a backslash-escaped double quote (\") within an email address allows attackers to inject arbitrary shell commands. The mail() command, when processing the crafted email address, interprets the injected characters as command-line arguments, leading to the execution of malicious code. The root cause is a lack of proper input validation and command injection vulnerability.

04 // Exploitation Status

Public PoC. Exploits are readily available and easily adaptable. The vulnerability is considered **Actively exploited**.

05 // Threat Intelligence

While no specific APT groups are definitively linked to this specific CVE, the ease of exploitation and potential for complete system compromise make it attractive to various threat actors. This vulnerability could be leveraged by attackers for initial access, privilege escalation, or data exfiltration. Not listed on CISA KEV due to its age, but still a significant risk.

06 // Detection & Hunting

  • Monitor server logs for suspicious activity related to the mail() command, such as unexpected arguments or command executions.

  • Analyze email headers for unusual characters or patterns, specifically backslash-escaped double quotes (\") in the From, ReturnPath, or Sender headers.

  • Implement intrusion detection systems (IDS) and intrusion prevention systems (IPS) with rules to detect and block malicious email payloads.

  • Review web server logs for requests that trigger email sending functionality, looking for unusual parameters or payloads.

07 // Remediation & Hardening

  • Upgrade Swift Mailer to version 5.4.5 or later.

  • Implement robust input validation to sanitize email addresses before passing them to the mail() command. Specifically, ensure that special characters like backslashes and double quotes are properly escaped or rejected.

  • Use a secure email sending method that does not rely on the mail() command, such as a dedicated SMTP server.

  • Apply the principle of least privilege to the user account running the web server and email sending processes. Limit the account's permissions to only the necessary actions.

  • Regularly update all software and dependencies to the latest versions to patch known vulnerabilities.

08 // Affected Products

Swift Mailer versions prior to 5.4.5

09 // Discovered Proof of Concept Links

Advertisement

References & Intelligence

http://packetstormsecurity.com/files/140290/SwiftMailer-Remote-Code-Execution.html
Source: cve@mitre.org
ExploitThird Party Advisory
http://seclists.org/fulldisclosure/2016/Dec/86
Source: cve@mitre.org
ExploitMailing List
http://www.debian.org/security/2017/dsa-3769
Source: cve@mitre.org
http://www.securityfocus.com/bid/95140
Source: cve@mitre.org
Third Party AdvisoryVDB Entry
https://github.com/swiftmailer/swiftmailer/blob/5.x/CHANGES
Source: cve@mitre.org
PatchVendor Advisory
https://legalhackers.com/advisories/SwiftMailer-Exploit-Remote-Code-Exec-CVE-2016-10074-Vuln.html
Source: cve@mitre.org
ExploitTechnical DescriptionThird Party Advisory
https://www.exploit-db.com/exploits/40972/
Source: cve@mitre.org
ExploitThird Party Advisory
https://www.exploit-db.com/exploits/40986/
Source: cve@mitre.org
https://www.exploit-db.com/exploits/42221/
Source: cve@mitre.org
http://packetstormsecurity.com/files/140290/SwiftMailer-Remote-Code-Execution.html
Source: af854a3a-2127-422b-91ae-364da2661108
ExploitThird Party Advisory
http://seclists.org/fulldisclosure/2016/Dec/86
Source: af854a3a-2127-422b-91ae-364da2661108
ExploitMailing List
http://www.debian.org/security/2017/dsa-3769
Source: af854a3a-2127-422b-91ae-364da2661108
http://www.securityfocus.com/bid/95140
Source: af854a3a-2127-422b-91ae-364da2661108
Third Party AdvisoryVDB Entry
https://github.com/swiftmailer/swiftmailer/blob/5.x/CHANGES
Source: af854a3a-2127-422b-91ae-364da2661108
PatchVendor Advisory
https://legalhackers.com/advisories/SwiftMailer-Exploit-Remote-Code-Exec-CVE-2016-10074-Vuln.html
Source: af854a3a-2127-422b-91ae-364da2661108
ExploitTechnical DescriptionThird Party Advisory
https://www.exploit-db.com/exploits/40972/
Source: af854a3a-2127-422b-91ae-364da2661108
ExploitThird Party Advisory
https://www.exploit-db.com/exploits/40986/
Source: af854a3a-2127-422b-91ae-364da2661108
https://www.exploit-db.com/exploits/42221/
Source: af854a3a-2127-422b-91ae-364da2661108