Public Vulnerability Reports

SquirrelMail S/MIME Plugin Command Injection Vulnerability

02.07.05

BACKGROUND

Squirrelmail S/MIME plugin enables the viewing of S/MIME-signed messages
of the MIME "multipart/signed" format. More information about the plugin
is available at:

    http://www.squirrelmail.org/plugin_view.php?id=54

DESCRIPTION

Remote exploitation of a command injection vulnerability in the
Squirrelmail S/MIME plugin allows web mail users to execute arbitrary
commands with the privileges of the web server.

The problem specifically exists due to insufficient filtering of
user-provided data in a call to exec(). The following snippet exposes
the offending area of code from viewcert.php:

    if(!isset($cert)) $cert=$_GET['cert'];
    ...
    function x509_open($cert) {
        global $cert_in_dir, $openssl;
        $lines = array();
        exec("$openssl x509 -in $cert_in_dir$cert -subject -issuer
            -dates -serial -fingerprint -noout 2>/tmp/err", $lines);
    ...
    list ($ow, $is, $nb, $na, $sn, $fp) = x509_open($cert);

The variable '$cert' from the above snippet contains unfiltered user
supplied data and can be exploited.

ANALYSIS

Successful exploitation allows authenticated web mail users to execute
arbitrary commands on the underlying system with the privileges of the
web server. This can lead to further compromise and exposure of other
users' mail to the attacker.

DETECTION

iDEFENSE has confirmed the existence of this vulnerability in S/MIME
plugin 0.5 and 0.4. Earlier versions are also suspected to be
vulnerable.

WORKAROUND

PHP provides the escapeshellarg() routine to filter data to be used as
an argument to calls such as exec() and system(). Modify the call to
exec() from:

    exec("$openssl x509 -in $cert_in_dir$cert -subject -issuer -dates
        -serial -fingerprint -noout 2>/tmp/err", $lines);

To:

    $filtered = escapeshellarg("$cert_in_dir$cert");
    exec("$openssl x509 -in $filtered -subject -issuer -dates -serial
        -fingerprint -noout 2>/tmp/err", $lines);

VENDOR RESPONSE

The vendor has released S/MIME plugin 0.6 to address this vulnerability.
The plugin is available for download at:

   http://www.squirrelmail.org/plugin_view.php?id=54

CVE INFORMATION

The Common Vulnerabilities and Exposures (CVE) project has assigned the
names CAN-2005-0239 to these issues. This is a candidate for inclusion
in the CVE list (http://cve.mitre.org), which standardizes names for
security problems.

DISCLOSURE TIMELINE

09/22/2004   Initial vendor notification
09/22/2004   Initial vendor response
02/07/2005   Coordinated public disclosure

CREDIT

Karol Wiesek is credited with this discovery.

Get paid for vulnerability research
http://www.idefense.com/poi/teams/vcp.jsp

LEGAL NOTICES

Copyright © 2005 Verisign, Inc.

Permission is granted for the redistribution of this alert
electronically. It may not be edited in any way without the express
written consent of iDEFENSE. If you wish to reprint the whole or any
part of this alert in any other medium other than electronically, please
email customerservice@idefense.com for permission.

Disclaimer: The information in the advisory is believed to be accurate
at the time of publishing based on currently available information. Use
of the information constitutes acceptance for use in an AS IS condition.
There are no warranties with regard to this information. Neither the
author nor the publisher accepts any liability for any direct, indirect,
or consequential loss or damage arising from use of, or reliance on,
this information.