Vulnerabilities > CVE-2017-7692 - Improper Input Validation vulnerability in Squirrelmail 1.4.22

047910
CVSS 9.0 - CRITICAL
Attack vector
NETWORK
Attack complexity
LOW
Privileges required
SINGLE
Confidentiality impact
COMPLETE
Integrity impact
COMPLETE
Availability impact
COMPLETE
network
low complexity
squirrelmail
CWE-20
critical
nessus
exploit available

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

Part Description Count
Application
Squirrelmail
1

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

descriptionSquirrelMail < 1.4.22 - Remote Code Execution. CVE-2017-7692. Remote exploit for Linux platform
fileexploits/linux/remote/41910.sh
idEDB-ID:41910
last seen2017-04-25
modified2017-04-23
platformlinux
port
published2017-04-23
reporterExploit-DB
sourcehttps://www.exploit-db.com/download/41910/
titleSquirrelMail < 1.4.22 - Remote Code Execution
typeremote

Nessus

  • NASL familyGentoo Local Security Checks
    NASL idGENTOO_GLSA-201709-13.NASL
    descriptionThe 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 seen2020-06-01
    modified2020-06-02
    plugin id103281
    published2017-09-18
    reporterThis script is Copyright (C) 2017-2019 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/103281
    titleGLSA-201709-13 : SquirrelMail: Remote Code Execution
  • NASL familyFedora Local Security Checks
    NASL idFEDORA_2017-0B6DA97AA5.NASL
    descriptionfix 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 seen2020-06-05
    modified2017-06-05
    plugin id100603
    published2017-06-05
    reporterThis script is Copyright (C) 2017-2020 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/100603
    titleFedora 24 : squirrelmail (2017-0b6da97aa5)
  • NASL familyFedora Local Security Checks
    NASL idFEDORA_2017-F85C37AE3D.NASL
    descriptionfix 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 seen2020-06-05
    modified2017-06-05
    plugin id100609
    published2017-06-05
    reporterThis script is Copyright (C) 2017-2020 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/100609
    titleFedora 25 : squirrelmail (2017-f85c37ae3d)
  • NASL familyFedora Local Security Checks
    NASL idFEDORA_2017-A7161EB173.NASL
    descriptionfix 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 seen2020-06-05
    modified2017-07-17
    plugin id101697
    published2017-07-17
    reporterThis script is Copyright (C) 2017-2020 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/101697
    titleFedora 26 : squirrelmail (2017-a7161eb173)
  • NASL familyFreeBSD Local Security Checks
    NASL idFREEBSD_PKG_E1DE77E8C45E48D788665A6F943046DE.NASL
    descriptionSquirrelMail 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 seen2020-06-01
    modified2020-06-02
    plugin id102691
    published2017-08-23
    reporterThis script is Copyright (C) 2017-2019 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/102691
    titleFreeBSD : SquirrelMail -- post-authentication remote code execution (e1de77e8-c45e-48d7-8866-5a6f943046de)
  • NASL familyDebian Local Security Checks
    NASL idDEBIAN_DLA-941.NASL
    descriptionDawid 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 seen2020-03-17
    modified2017-05-16
    plugin id100176
    published2017-05-16
    reporterThis script is Copyright (C) 2017-2020 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/100176
    titleDebian DLA-941-1 : squirrelmail security update
  • NASL familyDebian Local Security Checks
    NASL idDEBIAN_DSA-3852.NASL
    descriptionDawid 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 seen2020-06-01
    modified2020-06-02
    plugin id100166
    published2017-05-15
    reporterThis script is Copyright (C) 2017-2019 and is owned by Tenable, Inc. or an Affiliate thereof.
    sourcehttps://www.tenable.com/plugins/nessus/100166
    titleDebian DSA-3852-1 : squirrelmail - security update

Packetstorm

Seebug

bulletinFamilyexploit
descriptionSquirrelmail 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 ```
idSSV:93005
last seen2017-11-19
modified2017-04-22
published2017-04-22
reporterRoot
sourcehttps://www.seebug.org/vuldb/ssvid-93005
titleSquirrelmail 1.4.22 Remote Code Execution (CVE-2017-7692)