Skip to content

phpMyFAQ vulnerable to stored XSS on attachments filename

Moderate severity GitHub Reviewed Published Feb 5, 2024 in thorsten/phpMyFAQ • Updated Feb 5, 2024

Package

composer phpmyfaq/phpmyfaq (Composer)

Affected versions

< 3.2.5

Patched versions

3.2.5

Description

Summary

Unsafe echo of filename in phpMyFAQ\phpmyfaq\admin\attachments.php leading to allow execute JavaScript code in client side (XSS)

Details

On that snippet code of rendering the file attachments from user tables

<?php foreach ($crumbs as $item) : ?>
        <tr id="attachment_<?= $item->id ?>" title="<?= $item->thema ?>">
          <td><?= $item->id ?></td>
          <td><?= $item->filename ?></td>
          <td><?= $item->record_lang ?></td>
          <td><?= Utils::formatBytes($item->filesize) ?></td>
          <td><?= $item->mime_type ?></td>
          <td>

The data directly rendering with short hand echo without any sanitation first, its recommend to use existing class of Strings::htmlentities on use phpMyFAQ\Strings;

<td><?= Strings::htmlentities($item->filename); ?></td>
<td><?= Strings::htmlentities($item->record_lang); ?></td>
<td><?= Utils::formatBytes($item->filesize) ?></td>
<td><?= Strings::htmlentities($item->mime_type); ?></td>

Propose fixing on that pull request thorsten/phpMyFAQ#2827

PoC

  1. An attacker with permission will upload the attachments image on http://{base_url}/admin/?action=editentry
  2. On endpoint of ajax upload image POST /admin/index.php?action=ajax&ajax=att&ajaxaction=upload
  3. Change the originally name file on parameters filename to a XSS payload
  4. The XSS will trigger on attachment pages /admin/?action=attachments
  • Trigger XSS
    image

  • Payload XSS

image

Impact

This vulnerability will allow an attacker with a permissions of uploading an attachment to storing the payload of XSS on database specific table faqattachment columns filename.

The XSS payload could be rendering on page that listing the file on tables, and impact to others user that on the hierarchy.

The payload XSS have several attack scenario such like

  1. Stealing the cookies (isn’t possible since HttpOnly)
  2. Crashing the application with a looping javascript payload

References

@thorsten thorsten published to thorsten/phpMyFAQ Feb 5, 2024
Published to the GitHub Advisory Database Feb 5, 2024
Reviewed Feb 5, 2024
Published by the National Vulnerability Database Feb 5, 2024
Last updated Feb 5, 2024

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
None
Availability
Low

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:L

EPSS score

0.067%
(31st percentile)

CVE ID

CVE-2024-24574

GHSA ID

GHSA-7m8g-fprr-47fx

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.