Skip to content

OTF-001: Improper Input Sanitation: The path parameter of the requested URL is not sanitized before being passed to the QT frontend

High severity GitHub Reviewed Published Jan 18, 2022 in onionshare/onionshare • Updated Jan 29, 2023

Package

pip onionshare-cli (pip)

Affected versions

< 2.5

Patched versions

2.5

Description

Between September 26, 2021 and October 8, 2021, Radically Open Security conducted a penetration test of OnionShare 2.4, funded by the Open Technology Fund's Red Team lab. This is an issue from that penetration test.

  • Vulnerability ID: OTF-001
  • Vulnerability type: Improper Input Sanitization
  • Threat level: Elevated

Description:

The path parameter of the requested URL is not sanitized before being passed to the QT frontend.

Technical description:

The path parameter is not sanitized before being passed to the constructor of the QLabel.

https://github.com/onionshare/onionshare/blob/d08d5f0f32f755f504494d80794886f346fbafdb/desktop/src/onionshare/tab/mode/__init__.py#L499-L509

https://github.com/onionshare/onionshare/blob/d08d5f0f32f755f504494d80794886f346fbafdb/desktop/src/onionshare/tab/mode/history.py#L456-L483

https://doc.qt.io/qt-5/qlabel.html#details

Warning: When passing a QString to the constructor or calling setText(), make sure to sanitize your input, as QLabel tries to guess whether it displays the text as plain text or as rich text, a subset of HTML 4 markup. You may want to call setTextFormat() explicitly, e.g. in case you expect the text to be in plain format but cannot control the text source (for instance when displaying data loaded from the Web).

This path is used in all components for displaying the server access history. This leads to a rendered HTML4 Subset (QT RichText editor) in the Onionshare frontend.

In the following example an adversary injects a crafted image file into an Onionshare instance with receive mode and renders it in the history component of the Onionshare application.

The only requirement is another visit to the shared site with the following parameter attached to the path of the URL:

<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAFElEQVQY02Nk+M+ABzAxMIxKYwIAQC0BEwZFOw4AAAAASUVORK5CYII=' />

This will be rendered as a green square in the history tab where the path value is supposed to be (the value itself is shown at the bottom of the page).

otf-001

Possible scenarios where this could lead to remote code execution would be a 0-day in libpng or other internal image rendering (OTF-014 (page 12)) of the QT framework.

The QT documentation indicates that external files could be rendered, but we were unable to find a QT code path allowing for it.

Impact:

An adversary with knowledge of the Onion service address in public mode or with authentication in private mode can render arbitrary HTML (QT-HTML4 Subset) in the server desktop application. This requires the desktop application with rendered history, therefore the impact is only elevated.

Recommendation:

  • Manually define the text format of the QLabel via setTextFormat()

References

@micahflee micahflee published to onionshare/onionshare Jan 18, 2022
Published by the National Vulnerability Database Jan 18, 2022
Reviewed Jan 19, 2022
Published to the GitHub Advisory Database Jan 21, 2022
Last updated Jan 29, 2023

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
Low
User interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
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:L/UI:R/S:C/C:H/I:H/A:N

EPSS score

0.053%
(22nd percentile)

Weaknesses

CVE ID

CVE-2022-21690

GHSA ID

GHSA-ch22-x2v3-v6vq

Source code

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