Skip to content

Preview in WYSIWYG editor allows accessing any PDF document as the last author

High
ChiuchiuSorin published GHSA-hph4-7j37-7c97 Nov 13, 2024

Package

maven com.xwiki.pdfviewer:macro-pdfviewer-ui (Maven)

Affected versions

>= 1.6.2

Patched versions

2.5.6

Description

Impact

The PDF Viewer macro allows an attacker to view any attachment using the "Delegate my view right" feature as long as the attacker can view a page whose last author has access to the attachment.

For this, the attacker only needs to provide the reference to a PDF file to the macro. To obtain the reference of the desired attachment, the attacker can access the Page Index, Attachments tab. Even if the UI shows N/A, the user can inspect the page and check the HTTP request that fetches the live data entries. The attachment URL is available in the returned JSON for all attachments, including protected ones and allows getting the necessary values.

To reproduce, create a page "Secret Page" with an attachment "secret-attachment.pdf" as admin and restrict view access to admins. As a simple user who doesn't have access to "Secret Page", then edit any page you can edit that has been edited by a user with access to the secret attachment before. For example, any of the Sandbox pages should fulfill these conditions by default. Insert the "PDF Viewer" macro, set the file to "Secret [email protected]" and set "Delegate my view right" to 1:

image

Submit the macro editing dialog but don't save the document. The PDF document should be displayed in the editor if the instance is vulnerable.

This attack can also be carried out without edit right using the HTMLConverter used by the WYSIWYG editor. To reproduce, open any page that has been last edited by a user with access to the attachment and execute the following JavaScript snippet in the browser's console, replacing the attachment reference in the last line as desired:

(function (text) {
  const url = new URL(document.location);
  url.searchParams.append('sheet', 'CKEditor.HTMLConverter');
  url.searchParams.append('formToken', document.documentElement.dataset.xwikiFormToken);
  url.searchParams.append('toHTML', 'true');
  url.searchParams.append('text', text);
 document.location = url;
})('{{pdfviewer file="Secret [email protected]" asAuthor="1"/}}');

When supplying an attachment reference that is not a PDF file, there will be an error displaying the file, but it is still possible to use the URL from the browser's developer tools to manually download the attachment content.

Patches

Fixed in version 2.5.6

Workarounds

As a workaround, the document XWiki.PDFViewerService can be deleted as "superadmin", thereby removing the possibility to delegate the view right.

Severity

High

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
High
Integrity
None
Availability
None

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:H/I:N/A:N

CVE ID

CVE-2024-52298

Weaknesses

No CWEs