Lucene search

K
githubGitHub Advisory DatabaseGHSA-7M8G-FPRR-47FX
HistoryFeb 05, 2024 - 8:22 p.m.

phpMyFAQ vulnerable to stored XSS on attachments filename

2024-02-0520:22:05
CWE-79
CWE-80
GitHub Advisory Database
github.com
10
phpmyfaq
stored xss
filename
sanitation
fix
htmlentities
attachments
upload
payload
impact
table
cookies

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

Affected configurations

Vulners
Node
phpmyfaqphpmyfaqRange<3.2.5
CPENameOperatorVersion
phpmyfaq/phpmyfaqlt3.2.5

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 GHSA-7M8G-FPRR-47FX