Exploit database

GH-6fd12ff79584a171424451cd851e397e

ecomyseo/ecom_blockrceflaws

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-109618

412 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files5
ecomyseo/ecom_blockrceflawsRevision 0374726b6c6d

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

classes/EcomBlockrceflawsHardening.php

PHP · 5,134 bytes
<?php
/**
 * Ecom BlockRceFlaws - Ajustes de php.ini en .user.ini y .htaccess.
 *
 * Escribe un bloque propio delimitado por marcas, sin tocar nada de lo que ya exista, y deja
 * una copia de seguridad antes del primer cambio. Apaga session.upload_progress (el mecanismo
 * senalado de uno de los dos fallos) y activa session.use_strict_mode.
 *
 * @author    Ecom Experts <[email protected]>
 * @copyright 2026 Ecom Experts
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License (AFL 3.0)
 */
if (!defined('_PS_VERSION_')) {
    exit;
}

class EcomBlockrceflawsHardening
{
    const MARK_START = '~~ ecom_blockrceflaws start ~~';
    const MARK_END = '~~ ecom_blockrceflaws end ~~';

    /** @var Module */
    protected $module;

    public function __construct($module)
    {
        $this->module = $module;
    }

    public function getRootPath()
    {
        return rtrim(_PS_ROOT_DIR_, '/\\') . DIRECTORY_SEPARATOR;
    }

    public function getUserIniPath()
    {
        return $this->getRootPath() . '.user.ini';
    }

    public function getHtaccessPath()
    {
        return $this->getRootPath() . '.htaccess';
    }

    public function apply()
    {
        $this->applyUserIni();
        $this->applyHtaccessOnly();
    }

    public function remove()
    {
        $this->stripBlock($this->getUserIniPath(), true);
        $this->stripBlock($this->getHtaccessPath(), false);
    }

    public function isApplied()
    {
        $ini = @file_get_contents($this->getUserIniPath());
        return is_string($ini) && strpos($ini, self::MARK_START) !== false;
    }

    protected function applyUserIni()
    {
        $path = $this->getUserIniPath();
        // En un .user.ini el comentario valido es ";", nunca "#".
        $block = '; ' . self::MARK_START . "\n"
            . "; Mitigacion CVE-2026-109618 / CVE-2026-109619 (PHP RCE). No borrar: lo gestiona el módulo.\n"
            . "session.upload_progress.enabled=0\n"
            . "session.use_strict_mode=1\n"
            . '; ' . self::MARK_END . "\n";
        $this->writeBlock($path, $block, false);
    }

    /**
     * El .htaccess: el bloque va en formato Apache, dentro de <IfModule mod_php...>, para que en
     * servidores con PHP-FPM (donde php_flag daria error 500) simplemente se ignore.
     */
    public function applyHtaccessOnly()
    {
        $path = $this->getHtaccessPath();
        $block = '# ' . self::MARK_START . "\n"
            . "# Mitigacion CVE-2026-109618 / CVE-2026-109619 (PHP RCE). No borrar: lo gestiona el módulo.\n"
            . "<IfModule mod_php7.c>\n"
            . "    php_flag session.upload_progress.enabled off\n"
            . "    php_flag session.use_strict_mode on\n"
            . "</IfModule>\n"
            . "<IfModule mod_php.c>\n"
            . "    php_flag session.upload_progress.enabled off\n"
            . "    php_flag session.use_strict_mode on\n"
            . "</IfModule>\n"
            . '# ' . self::MARK_END . "\n";
        $this->writeBlock($path, $block, true);
    }

    /**
     * Escribe o reemplaza nuestro bloque. En el .htaccess lo coloca al PRINCIPIO del fichero,
     * antes de las marcas de PrestaShop, para que su regeneracion no se lo lleve por delante
     * (PrestaShop solo conserva lo anterior a "# ~~start~~", y ahi es justo donde queda).
     */
    protected function writeBlock($path, $block, $prepend)
    {
        $existing = '';
        if (is_file($path)) {
            $existing = (string) @file_get_contents($path);
            $this->backupOnce($path, $existing);
        }

        $clean = $this->stripBlockFromString($existing);

        if ($prepend) {
            $new = $block . "\n" . ltrim($clean, "\n");
        } else {
            $sep = ($clean !== '' && substr($clean, -1) !== "\n") ? "\n" : '';
            $new = $clean . $sep . $block;
        }

        @file_put_contents($path, $new, LOCK_EX);
    }

    protected function stripBlock($path, $removeIfEmpty)
    {
        if (!is_file($path)) {
            return;
        }
        $existing = (string) @file_get_contents($path);
        $clean = $this->stripBlockFromString($existing);
        if ($removeIfEmpty && trim($clean) === '') {
            @unlink($path);
            return;
        }
        @file_put_contents($path, $clean, LOCK_EX);
    }

    protected function stripBlockFromString($content)
    {
        if ($content === '') {
            return '';
        }
        // Consume la linea entera del marcador (con su prefijo ; o # y su salto), tanto en
        // .user.ini como en .htaccess, y todo lo que haya entre inicio y fin.
        $pattern = '/[ \t]*[#;][ \t]*' . preg_quote(self::MARK_START, '/')
            . '.*?' . preg_quote(self::MARK_END, '/') . "[^\n]*\n?/s";
        $out = preg_replace($pattern, '', $content);

        return $out === null ? $content : $out;
    }

    protected function backupOnce($path, $content)
    {
        $bak = $path . '.ecombrf.bak';
        if (!is_file($bak) && strpos($content, self::MARK_START) === false) {
            @file_put_contents($bak, $content, LOCK_EX);
        }
    }
}