Lucene search

K
osvGoogleOSV:GHSA-7M8G-FPRR-47FX
HistoryFeb 05, 2024 - 8:22 p.m.

phpMyFAQ vulnerable to stored XSS on attachments filename

2024-02-0520:22:05
Google
osv.dev
9
phpmyfaq
xss
attachment security
javascript
file rendering
payload
security vulnerability
database storage
user impact
fix proposal
pull request
attack scenario
file upload
table listing
client-side execution
sanitization
hierarchy impact
application crashing.

6.5 Medium

CVSS3

Attack Vector

NETWORK

Attack Complexity

LOW

Privileges Required

NONE

User Interaction

NONE

Scope

UNCHANGED

Confidentiality Impact

LOW

Integrity Impact

NONE

Availability Impact

LOW

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:L

6.3 Medium

AI Score

Confidence

High

0.001 Low

EPSS

Percentile

29.6%

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>
          <td>&lt;?= $item-&gt;id ?&gt;</td>
          <td>&lt;?= $item-&gt;filename ?&gt;</td>
          <td>&lt;?= $item-&gt;record_lang ?&gt;</td>
          <td>&lt;?= Utils::formatBytes($item-&gt;filesize) ?&gt;</td>
          <td>&lt;?= $item-&gt;mime_type ?&gt;</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>&lt;?= Strings::htmlentities($item-&gt;filename); ?&gt;</td>
<td>&lt;?= Strings::htmlentities($item-&gt;record_lang); ?&gt;</td>
<td>&lt;?= Utils::formatBytes($item-&gt;filesize) ?&gt;</td>
<td>&lt;?= Strings::htmlentities($item-&gt;mime_type); ?&gt;</td>

Propose fixing on that pull request https://github.com/thorsten/phpMyFAQ/pull/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

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

6.5 Medium

CVSS3

Attack Vector

NETWORK

Attack Complexity

LOW

Privileges Required

NONE

User Interaction

NONE

Scope

UNCHANGED

Confidentiality Impact

LOW

Integrity Impact

NONE

Availability Impact

LOW

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:L

6.3 Medium

AI Score

Confidence

High

0.001 Low

EPSS

Percentile

29.6%

Related for OSV:GHSA-7M8G-FPRR-47FX