CVE-2016-10045

CRITICAL9.8/ 10.0
Share:
Published: December 30, 2016 at 07:59 PM
Modified: April 12, 2025 at 10:46 AM
Source: cve@mitre.org

Vulnerability Description

The isMail transport in PHPMailer before 5.2.20 might allow remote attackers to pass extra parameters to the mail command and consequently execute arbitrary code by leveraging improper interaction between the escapeshellarg function and internal escaping performed in the mail function in PHP. NOTE: this vulnerability exists because of an incorrect fix for CVE-2016-10033.

CVSS Metrics

Base Score
9.8
Severity
CRITICAL
Vector String
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Weaknesses (CWE)

Source: nvd@nist.gov

AI Security Analysis

01 // Technical Summary

PHPMailer versions prior to 5.2.20 are vulnerable to a critical remote code execution (RCE) flaw. This vulnerability allows attackers to inject arbitrary commands into the mail function via the isMail transport, potentially leading to complete system compromise.

02 // Vulnerability Mechanism

Step 1: Payload Injection: The attacker crafts a malicious email address or other input containing shell commands, designed to be passed to the mail command via PHPMailer's isMail transport.

Step 2: Input Processing: The attacker's crafted input is passed to PHPMailer's isMail transport, where it's intended to be sanitized by escapeshellarg.

Step 3: Incomplete Sanitization: escapeshellarg fails to completely sanitize the input, leaving exploitable characters in place.

Step 4: Command Execution: The sanitized (but still malicious) input is passed to the PHP mail function. The mail function, due to its internal handling of arguments, interprets the injected commands as part of its execution, leading to arbitrary code execution on the server.

03 // Deep Technical Analysis

The vulnerability stems from an incorrect fix for CVE-2016-10033. The isMail transport in PHPMailer uses escapeshellarg to sanitize user-supplied input before passing it to the mail function in PHP. However, the interaction between escapeshellarg and the internal escaping performed by the mail function itself is flawed. Specifically, escapeshellarg does not fully prevent malicious characters from being passed to the underlying mail command. Attackers can craft a malicious email address or other input that, when processed by escapeshellarg and then the mail function, results in the execution of arbitrary shell commands. The root cause is a command injection vulnerability due to insufficient input validation and escaping, allowing for shell command injection through the mail function's parameters. This bypasses the intended security measures.

References & Intelligence

http://openwall.com/lists/oss-security/2016/12/28/1
Source: cve@mitre.org
Mailing ListPatch
http://packetstormsecurity.com/files/140286/PHPMailer-Remote-Code-Execution.html
Source: cve@mitre.org
ExploitThird Party AdvisoryVDB Entry
http://packetstormsecurity.com/files/140350/PHPMailer-Sendmail-Argument-Injection.html
Source: cve@mitre.org
ExploitThird Party AdvisoryVDB Entry
http://seclists.org/fulldisclosure/2016/Dec/81
Source: cve@mitre.org
Mailing ListPatchThird Party Advisory
http://www.rapid7.com/db/modules/exploit/multi/http/phpmailer_arg_injection
Source: cve@mitre.org
ExploitThird Party Advisory
http://www.securityfocus.com/archive/1/539967/100/0/threaded
Source: cve@mitre.org
Third Party AdvisoryVDB Entry
http://www.securityfocus.com/bid/95130
Source: cve@mitre.org
ExploitThird Party AdvisoryVDB Entry
http://www.securitytracker.com/id/1037533
Source: cve@mitre.org
Third Party AdvisoryVDB Entry
https://developer.joomla.org/security-centre/668-20161205-phpmailer-security-advisory.html
Source: cve@mitre.org
Third Party Advisory
https://github.com/PHPMailer/PHPMailer/releases/tag/v5.2.20
Source: cve@mitre.org
PatchVendor Advisory
https://github.com/PHPMailer/PHPMailer/wiki/About-the-CVE-2016-10033-and-CVE-2016-10045-vulnerabilities
Source: cve@mitre.org
PatchVendor Advisory
https://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10045-Vuln-Patch-Bypass.html
Source: cve@mitre.org
ExploitPatchThird Party Advisory
https://www.exploit-db.com/exploits/40969/
Source: cve@mitre.org
ExploitThird Party AdvisoryVDB Entry
https://www.exploit-db.com/exploits/40986/
Source: cve@mitre.org
Third Party AdvisoryVDB Entry
https://www.exploit-db.com/exploits/42221/
Source: cve@mitre.org
Third Party AdvisoryVDB Entry
http://openwall.com/lists/oss-security/2016/12/28/1
Source: af854a3a-2127-422b-91ae-364da2661108
Mailing ListPatch
http://packetstormsecurity.com/files/140286/PHPMailer-Remote-Code-Execution.html
Source: af854a3a-2127-422b-91ae-364da2661108
ExploitThird Party AdvisoryVDB Entry
http://packetstormsecurity.com/files/140350/PHPMailer-Sendmail-Argument-Injection.html
Source: af854a3a-2127-422b-91ae-364da2661108
ExploitThird Party AdvisoryVDB Entry
http://seclists.org/fulldisclosure/2016/Dec/81
Source: af854a3a-2127-422b-91ae-364da2661108
Mailing ListPatchThird Party Advisory
http://www.rapid7.com/db/modules/exploit/multi/http/phpmailer_arg_injection
Source: af854a3a-2127-422b-91ae-364da2661108
ExploitThird Party Advisory
http://www.securityfocus.com/archive/1/539967/100/0/threaded
Source: af854a3a-2127-422b-91ae-364da2661108
Third Party AdvisoryVDB Entry
http://www.securityfocus.com/bid/95130
Source: af854a3a-2127-422b-91ae-364da2661108
ExploitThird Party AdvisoryVDB Entry
http://www.securitytracker.com/id/1037533
Source: af854a3a-2127-422b-91ae-364da2661108
Third Party AdvisoryVDB Entry
https://developer.joomla.org/security-centre/668-20161205-phpmailer-security-advisory.html
Source: af854a3a-2127-422b-91ae-364da2661108
Third Party Advisory
https://github.com/PHPMailer/PHPMailer/releases/tag/v5.2.20
Source: af854a3a-2127-422b-91ae-364da2661108
PatchVendor Advisory
https://github.com/PHPMailer/PHPMailer/wiki/About-the-CVE-2016-10033-and-CVE-2016-10045-vulnerabilities
Source: af854a3a-2127-422b-91ae-364da2661108
PatchVendor Advisory
https://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10045-Vuln-Patch-Bypass.html
Source: af854a3a-2127-422b-91ae-364da2661108
ExploitPatchThird Party Advisory
https://www.exploit-db.com/exploits/40969/
Source: af854a3a-2127-422b-91ae-364da2661108
ExploitThird Party AdvisoryVDB Entry
https://www.exploit-db.com/exploits/40986/
Source: af854a3a-2127-422b-91ae-364da2661108
Third Party AdvisoryVDB Entry
https://www.exploit-db.com/exploits/42221/
Source: af854a3a-2127-422b-91ae-364da2661108
Third Party AdvisoryVDB Entry
CVE-2016-10045 - CRITICAL Severity (9.8) | Free CVE Database | 4nuxd