The setFrom function in the Sendmail adapter in the zend-mail component before 2.4.11, 2.5.x, 2.6.x, and 2.7.x before 2.7.2, and Zend Framework before 2.4.11 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.
Critical vulnerability in Zend Framework's Sendmail adapter allows remote attackers to execute arbitrary code on the server. By crafting a malicious email address containing a backslash-escaped double quote, attackers can inject commands into the mail command, leading to complete system compromise.
Step 1: Payload Delivery: The attacker crafts a malicious email address containing a backslash-escaped double quote and a shell command (e.g., attacker@example.com" -oQ/tmp/ -X/var/www/html/shell.php).
Step 2: Injection: The attacker submits this crafted email address through an application using the vulnerable Zend Framework's Sendmail adapter.
Step 3: Command Execution: The setFrom function in the Sendmail adapter passes the crafted email address to the mail command without proper sanitization.
Step 4: Code Execution: The mail command interprets the injected shell command, leading to the execution of arbitrary code, such as writing a web shell to a publicly accessible directory or executing a reverse shell.
The vulnerability stems from improper input validation in the setFrom function of the Sendmail adapter within the zend-mail component. Specifically, the code fails to properly sanitize the email address provided by the user before passing it to the mail command. This lack of sanitization allows an attacker to inject shell metacharacters, such as backslashes and double quotes, into the email address. The backslash-escaped double quote (\") is used to break out of the email address string and inject arbitrary commands. The mail command, when executed with these injected commands, then executes the attacker's code with the privileges of the web server user. The root cause is a command injection vulnerability due to insufficient input validation.