Attack vector
NETWORK Attack complexity
LOW Privileges required
LOW Confidentiality impact
HIGH Integrity impact
HIGH Availability impact
HIGH Published: 2017-04-20
Updated: 2017-11-04
Summary
SquirrelMail 1.4.22 (and other versions before 20170427_0200-SVN) allows post-authentication remote code execution via a sendmail.cf file that is mishandled in a popen call. It's possible to exploit this vulnerability to execute arbitrary shell commands on the remote server. The problem is in the Deliver_SendMail.class.php with the initStream function that uses escapeshellcmd() to sanitize the sendmail command before executing it. The use of escapeshellcmd() is not correct in this case since it doesn't escape whitespaces, allowing the injection of arbitrary command parameters. The problem is in -f$envelopefrom within the sendmail command line. Hence, if the target server uses sendmail and SquirrelMail is configured to use it as a command-line program, it's possible to trick sendmail into using an attacker-provided configuration file that triggers the execution of an arbitrary command. For exploitation, the attacker must upload a sendmail.cf file as an email attachment, and inject the sendmail.cf filename with the -C option within the "Options > Personal Informations > Email Address" setting.
Vulnerable Configurations
Common Weakness Enumeration (CWE)
Common Attack Pattern Enumeration and Classification (CAPEC)
- Buffer Overflow via Environment Variables
This attack pattern involves causing a buffer overflow through manipulation of environment variables. Once the attacker finds that they can modify an environment variable, they may try to overflow associated buffers. This attack leverages implicit trust often placed in environment variables.
- Server Side Include (SSI) Injection
An attacker can use Server Side Include (SSI) Injection to send code to a web application that then gets executed by the web server. Doing so enables the attacker to achieve similar results to Cross Site Scripting, viz., arbitrary code execution and information disclosure, albeit on a more limited scale, since the SSI directives are nowhere near as powerful as a full-fledged scripting language. Nonetheless, the attacker can conveniently gain access to sensitive files, such as password files, and execute shell commands.
- Cross Zone Scripting
An attacker is able to cause a victim to load content into their web-browser that bypasses security zone controls and gain access to increased privileges to execute scripting code or other web objects such as unsigned ActiveX controls or applets. This is a privilege elevation attack targeted at zone-based web-browser security. In a zone-based model, pages belong to one of a set of zones corresponding to the level of privilege assigned to that page. Pages in an untrusted zone would have a lesser level of access to the system and/or be restricted in the types of executable content it was allowed to invoke. In a cross-zone scripting attack, a page that should be assigned to a less privileged zone is granted the privileges of a more trusted zone. This can be accomplished by exploiting bugs in the browser, exploiting incorrect configuration in the zone controls, through a cross-site scripting attack that causes the attackers' content to be treated as coming from a more trusted page, or by leveraging some piece of system functionality that is accessible from both the trusted and less trusted zone. This attack differs from "Restful Privilege Escalation" in that the latter correlates to the inadequate securing of RESTful access methods (such as HTTP DELETE) on the server, while cross-zone scripting attacks the concept of security zones as implemented by a browser.
- Cross Site Scripting through Log Files
An attacker may leverage a system weakness where logs are susceptible to log injection to insert scripts into the system's logs. If these logs are later viewed by an administrator through a thin administrative interface and the log data is not properly HTML encoded before being written to the page, the attackers' scripts stored in the log will be executed in the administrative interface with potentially serious consequences. This attack pattern is really a combination of two other attack patterns: log injection and stored cross site scripting.
- Command Line Execution through SQL Injection
An attacker uses standard SQL injection methods to inject data into the command line for execution. This could be done directly through misuse of directives such as MSSQL_xp_cmdshell or indirectly through injection of data into the database that would be interpreted as shell commands. Sometime later, an unscrupulous backend application (or could be part of the functionality of the same application) fetches the injected data stored in the database and uses this data as command line arguments without performing proper validation. The malicious data escapes that data plane by spawning new commands to be executed on the host.
Exploit-Db
description | SquirrelMail < 1.4.22 - Remote Code Execution. CVE-2017-7692. Remote exploit for Linux platform |
file | exploits/linux/remote/41910.sh |
id | EDB-ID:41910 |
last seen | 2017-04-25 |
modified | 2017-04-23 |
platform | linux |
port | |
published | 2017-04-23 |
reporter | Exploit-DB |
source | https://www.exploit-db.com/download/41910/ |
title | SquirrelMail < 1.4.22 - Remote Code Execution |
type | remote |
Nessus
NASL family | Gentoo Local Security Checks |
NASL id | GENTOO_GLSA-201709-13.NASL |
description | The remote host is affected by the vulnerability described in GLSA-201709-13 (SquirrelMail: Remote Code Execution) It was discovered that the sendmail.cf file is mishandled in a popen call. Impact : A remote attacker, by enticing a user to open an e-mail attachment, could execute arbitrary shell commands. Workaround : There is no known workaround at this time. |
last seen | 2020-06-01 |
modified | 2020-06-02 |
plugin id | 103281 |
published | 2017-09-18 |
reporter | This script is Copyright (C) 2017-2019 and is owned by Tenable, Inc. or an Affiliate thereof. |
source | https://www.tenable.com/plugins/nessus/103281 |
title | GLSA-201709-13 : SquirrelMail: Remote Code Execution |
NASL family | Fedora Local Security Checks |
NASL id | FEDORA_2017-0B6DA97AA5.NASL |
description | fix insufficient escaping of user-supplied data (CVE-2017-7692) Note that Tenable Network Security has extracted the preceding description block directly from the Fedora update system website. Tenable has attempted to automatically clean and format it as much as possible without introducing additional issues. |
last seen | 2020-06-05 |
modified | 2017-06-05 |
plugin id | 100603 |
published | 2017-06-05 |
reporter | This script is Copyright (C) 2017-2020 and is owned by Tenable, Inc. or an Affiliate thereof. |
source | https://www.tenable.com/plugins/nessus/100603 |
title | Fedora 24 : squirrelmail (2017-0b6da97aa5) |
NASL family | Fedora Local Security Checks |
NASL id | FEDORA_2017-F85C37AE3D.NASL |
description | fix insufficient escaping of user-supplied data (CVE-2017-7692) Note that Tenable Network Security has extracted the preceding description block directly from the Fedora update system website. Tenable has attempted to automatically clean and format it as much as possible without introducing additional issues. |
last seen | 2020-06-05 |
modified | 2017-06-05 |
plugin id | 100609 |
published | 2017-06-05 |
reporter | This script is Copyright (C) 2017-2020 and is owned by Tenable, Inc. or an Affiliate thereof. |
source | https://www.tenable.com/plugins/nessus/100609 |
title | Fedora 25 : squirrelmail (2017-f85c37ae3d) |
NASL family | Fedora Local Security Checks |
NASL id | FEDORA_2017-A7161EB173.NASL |
description | fix insufficient escaping of user-supplied data (CVE-2017-7692) Note that Tenable Network Security has extracted the preceding description block directly from the Fedora update system website. Tenable has attempted to automatically clean and format it as much as possible without introducing additional issues. |
last seen | 2020-06-05 |
modified | 2017-07-17 |
plugin id | 101697 |
published | 2017-07-17 |
reporter | This script is Copyright (C) 2017-2020 and is owned by Tenable, Inc. or an Affiliate thereof. |
source | https://www.tenable.com/plugins/nessus/101697 |
title | Fedora 26 : squirrelmail (2017-a7161eb173) |
NASL family | FreeBSD Local Security Checks |
NASL id | FREEBSD_PKG_E1DE77E8C45E48D788665A6F943046DE.NASL |
description | SquirrelMail developers report : SquirrelMail 1.4.22 (and other versions before 20170427_0200-SVN) allows post-authentication remote code execution via a sendmail.cf file that is mishandled in a popen call. It |
last seen | 2020-06-01 |
modified | 2020-06-02 |
plugin id | 102691 |
published | 2017-08-23 |
reporter | This script is Copyright (C) 2017-2019 and is owned by Tenable, Inc. or an Affiliate thereof. |
source | https://www.tenable.com/plugins/nessus/102691 |
title | FreeBSD : SquirrelMail -- post-authentication remote code execution (e1de77e8-c45e-48d7-8866-5a6f943046de) |
NASL family | Debian Local Security Checks |
NASL id | DEBIAN_DLA-941.NASL |
description | Dawid Golunski and Filippo Cavallarin discovered that squirrelmail, a webmail application, incorrectly handled a user-supplied value. This would allow a logged-in user to run arbitrary commands on the server. For Debian 7 |
last seen | 2020-03-17 |
modified | 2017-05-16 |
plugin id | 100176 |
published | 2017-05-16 |
reporter | This script is Copyright (C) 2017-2020 and is owned by Tenable, Inc. or an Affiliate thereof. |
source | https://www.tenable.com/plugins/nessus/100176 |
title | Debian DLA-941-1 : squirrelmail security update |
NASL family | Debian Local Security Checks |
NASL id | DEBIAN_DSA-3852.NASL |
description | Dawid Golunski and Filippo Cavallarin discovered that squirrelmail, a webmail application, incorrectly handled a user-supplied value. This would allow a logged-in user to run arbitrary commands on the server. |
last seen | 2020-06-01 |
modified | 2020-06-02 |
plugin id | 100166 |
published | 2017-05-15 |
reporter | This script is Copyright (C) 2017-2019 and is owned by Tenable, Inc. or an Affiliate thereof. |
source | https://www.tenable.com/plugins/nessus/100166 |
title | Debian DSA-3852-1 : squirrelmail - security update |
Seebug
bulletinFamily | exploit |
description | Squirrelmail version 1.4.22 (and probably prior) is vulnerable to a remote code execution vulnerability because it fails to sanitize a string before passing it to a popen call. It's possible to exploit this vulnerability to execute arbitrary shell commands on the remote server. The problem is in Deliver_SendMail.class.php on initStream function that uses escapeshellcmd() to sanitize the sendmail command before executing it. The use of escapeshellcmd() is not correct in this case since it don't escapes whitespaces allowing the injection of arbitrary command parameters. $this->sendmail_command = "$sendmail_path $this->sendmail_args -f$envelopefrom"; $stream = popen(escapeshellcmd($this->sendmail_command), "w"); The $envelopefrom variable is controlled by the attacker, hence it's possible to trick sendmail to use an attacker-provided configuration file that triggers the execution of an arbitrary command. In order to exploit this vulnerability the MTA in use must be sendmail and Squirrelmail must be configured to use it as commandline (useSendmail directive of the config file set to true). Also, the edit_identity directive of the config file must be bet to true, but this is the default configuration. To reproduce the issue follow these steps: ``` 1. Create a rogue sendmail.cf that triggers the execution of a /usr/bin/touch: [...] Mlocal, P=/usr/bin/touch, F=lsDFMAw5:/|@qPn9S, S=EnvFromL/HdrFromL, R=EnvToL/HdrToL, T=DNS/RFC822/X-Unix, A=X /tmp/executed 2. Upload it as a mail attachment and get it's remote name (ex: lF51mGPJwdqzV3LEDlCdSVNpohzgF7sD) 3. Go to Options -> Personal Informations and set the following payload as Email Address: <aaa () abc com -OQueueDirectory=/tmp -C /var/local/squirrelmail/attach/lF51mGPJwdqzV3LEDlCdSVNpohzgF7sD> 4. Send an email 5. Verify the execution of the command with "ls /tmp/executed" on the remote server ``` |
id | SSV:93005 |
last seen | 2017-11-19 |
modified | 2017-04-22 |
published | 2017-04-22 |
reporter | Root |
source | https://www.seebug.org/vuldb/ssvid-93005 |
title | Squirrelmail 1.4.22 Remote Code Execution (CVE-2017-7692) |