CVE-2022-21690: OTF-001 Improper Input Sanitation: The Path Vulnerability

MODERATE
Advisory Identifier: GHSA-ch22-x2v3-v6vq
CVSS 8.7
CWE-79
Published
Advisory Summary

CVE-2022-21690 is a MODERATE (CVSS 8.7) improper input sanitation: the path vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting OTF-001 libraries in the PyPI ecosystem. The issue involves improper input sanitation: the path parameter of the requested url is not sanitized before being passed to the qt frontend. Remediation is available by upgrading affected packages to version 2.5.

CVE-2022-21690 at a Glance

CVE Identifier CVE-2022-21690
GHSA Identifier GHSA-ch22-x2v3-v6vq
Severity MODERATE
CVSS v3.1 Base Score 8.7
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product OTF-001
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2022-21690

To remediate this vulnerability, upgrade all affected OTF-001 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

onionshare-cli fixed: 2.5
pip install onionshare-cli>=2.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show onionshare-cli

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2022-21690, inspect your installed packages using pip:

pip show onionshare-cli

Analyze the terminal output to locate any version of OTF-001 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.5), your application is affected.

Note: The pip show onionshare-cli command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In OTF-001, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Between September 26, 2021 and October 8, 2021, [Radically Open Security](https://www.radicallyopensecurity.com/) conducted a penetration test of OnionShare 2.4, funded by the Open Technology Fund's [Red Team lab](https://www.opentech.fund/labs/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](https://user-images.githubusercontent.com/156128/140665358-ab9e5990-3e13-4e50-85fd-b8a6e323d299.png) 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()`

CVE-2022-21690 Affected OTF-001 Versions

1 component(s)
Fixed Versions:
2.5
Product / Package Ecosystem Affected Versions Fixed Version
onionshare-cli
PyPI
< 2.5
2.5

References

Frequently Asked Questions

What is CVE-2022-21690?
CVE-2022-21690 is a security vulnerability in OTF-001 involving Improper Input Sanitation: The path parameter of the requested URL is not sanitized before being passed to the QT frontend under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which OTF-001 versions are affected?
Affected versions include releases prior to 2.5 across affected packages: onionshare-cli.
What version fixes CVE-2022-21690?
Upgrading to 2.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is onionshare-cli affected?
Yes, onionshare-cli is affected in releases prior to 2.5. Upgrade your dependency to 2.5 or later.
What is the CVSS score of CVE-2022-21690?
CVE-2022-21690 has a CVSS v3.1 base score of 8.7 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N.
What CWE is associated with CVE-2022-21690?
CVE-2022-21690 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check PyPI dependencies for CVE-2022-21690?
Run the dependency tree command: 'pip show onionshare-cli'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-ch22-x2v3-v6vq",
  "modified" : "2024-10-07T16:51:43Z",
  "published" : "2022-01-21T23:20:25Z",
  "aliases" : [ "CVE-2022-21690" ],
  "summary" : "OTF-001: Improper Input Sanitation: The path parameter of the requested URL is not sanitized before being passed to the QT frontend",
  "details" : "Between September 26, 2021 and October 8, 2021, [Radically Open Security](https://www.radicallyopensecurity.com/) conducted a penetration test of OnionShare 2.4, funded by the Open Technology Fund's [Red Team lab](https://www.opentech.fund/labs/red-team-lab/). This is an issue from that penetration test.\n\n- Vulnerability ID: OTF-001\n- Vulnerability type: Improper Input Sanitization\n- Threat level: Elevated\n\n## Description:\n\nThe `path` parameter of the requested URL is not sanitized before being passed to the QT frontend.\n\n## Technical description:\n\nThe `path` parameter is not sanitized before being passed to the constructor of the `QLabel`.\n\nhttps://github.com/onionshare/onionshare/blob/d08d5f0f32f755f504494d80794886f346fbafdb/desktop/src/onionshare/tab/mode/__init__.py#L499-L509\n\nhttps://github.com/onionshare/onionshare/blob/d08d5f0f32f755f504494d80794886f346fbafdb/desktop/src/onionshare/tab/mode/history.py#L456-L483\n\nhttps://doc.qt.io/qt-5/qlabel.html#details\n\n> 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).\n\nThis 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.\n\nIn 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.\n\nThe only requirement is another visit to the shared site with the following parameter attached to the path of the URL:\n\n```\n<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAFElEQVQY02Nk+M+ABzAxMIxKYwIAQC0BEwZFOw4AAAAASUVORK5CYII=' />\n```\n\nThis 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).\n\n![otf-001](https://user-images.githubusercontent.com/156128/140665358-ab9e5990-3e13-4e50-85fd-b8a6e323d299.png)\n\nPossible 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.\n\nThe QT documentation indicates that external files could be rendered, but we were unable to find a QT code path allowing for it.\n\n## Impact:\n\nAn 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.\n\n## Recommendation:\n\n- Manually define the text format of the QLabel via `setTextFormat()`",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:H/SI:H/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "onionshare-cli"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/onionshare/onionshare/security/advisories/GHSA-ch22-x2v3-v6vq"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-21690"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/onionshare/onionshare"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/onionshare/onionshare/releases/tag/v2.5"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/onionshare-cli/PYSEC-2022-41.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-01-19T18:50:06Z",
    "nvd_published_at" : "2022-01-18T23:15:00Z"
  }
}