CVE-2022-35918: Streamlit Path Traversal Vulnerability

MODERATE
Advisory Identifier: GHSA-v4hr-4jpx-56gc
CVSS 6.5
CWE-22
Published
Advisory Summary

CVE-2022-35918 is a MODERATE (CVSS 6.5) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Streamlit libraries in the PyPI ecosystem. The issue involves streamlit directory traversal vulnerability. Remediation is available by upgrading affected packages to version 1.11.1.

CVE-2022-35918 at a Glance

CVE Identifier CVE-2022-35918
GHSA Identifier GHSA-v4hr-4jpx-56gc
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Streamlit
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.5

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

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

How to Fix CVE-2022-35918

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

streamlit fixed: 1.11.1
pip install streamlit>=1.11.1
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 streamlit

How to Check if You Are Affected

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

pip show streamlit

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Streamlit, 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

### Impact Users hosting Streamlit app(s) that use custom components are vulnerable to a directory traversal attack that could leak data from their web server file-system such as: server logs, world readable files, and potentially other sensitive information. An attacker can craft a malicious URL with file paths and the streamlit server would process that URL and return the contents of that file. ### Patches On July 27th at 2:20PM PST we rolled out a patch in release 1.11.1. This patch ensures that any file operations are restricted only to the custom component directory and cannot traverse outside of that. We strongly recommend users upgrade to v1.11.1 as soon as possible. We have notified the Streamlit community and popular hosting providers about this issue so they can patch quickly. As a precautionary measure, we are also upgrading all users on Streamlit Cloud wherever possible. We continue to check other occurrences of this vulnerability and monitor potential exploits wherever we can. Finally, as a general security practice, we recommend users review custom components for any malicious code before using them in their apps. Following security best practices such as running web servers with low privileges, firewalls, etc. for hosting your apps, helps in mitigating the severity of such exploits. ### Workarounds None. ### References * https://docs.google.com/document/d/e/2PACX-1vRzF9K6gwv9KnQz---1pt0SdHMVt-CHuKMmdTH1uct7xPcK7vToP4FvYdI84aO6rGfCmrBSaViri0Nd/pub ### For more information If you have any questions or comments about this advisory: * Email us at [security@streamlit.io](mailto:security@streamlit.io)

CVE-2022-35918 Affected Streamlit Versions

1 component(s)
Fixed Versions:
1.11.1
Product / Package Ecosystem Affected Versions Fixed Version
streamlit
PyPI
≥ 0.63.0
< 1.11.1
1.11.1

References

Frequently Asked Questions

What is CVE-2022-35918?
CVE-2022-35918 is a security vulnerability in Streamlit involving Streamlit directory traversal vulnerability under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Streamlit versions are affected?
Affected versions include releases prior to 1.11.1 across affected packages: streamlit.
What version fixes CVE-2022-35918?
Upgrading to 1.11.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is streamlit affected?
Yes, streamlit is affected in releases prior to 1.11.1. Upgrade your dependency to 1.11.1 or later.
What is the CVSS score of CVE-2022-35918?
CVE-2022-35918 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2022-35918?
CVE-2022-35918 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check PyPI dependencies for CVE-2022-35918?
Run the dependency tree command: 'pip show streamlit'. 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-v4hr-4jpx-56gc",
  "modified" : "2022-08-06T05:51:50Z",
  "published" : "2022-08-06T05:51:50Z",
  "aliases" : [ "CVE-2022-35918" ],
  "summary" : "Streamlit directory traversal vulnerability",
  "details" : "### Impact\nUsers hosting Streamlit app(s) that use custom components are vulnerable to a directory traversal attack that could leak data from their web server file-system such as: server logs, world readable files, and potentially other sensitive information.\n\nAn attacker can craft a malicious URL with file paths and the streamlit server would process that URL and return the contents of that file.\n\n### Patches\nOn July 27th at 2:20PM PST we rolled out a patch in release 1.11.1. This patch ensures that any file operations are restricted only to the custom component directory and cannot traverse outside of that. We strongly recommend users upgrade to v1.11.1 as soon as possible. We have notified the Streamlit community and popular hosting providers about this issue so they can patch quickly. As a precautionary measure, we are also upgrading all users on Streamlit Cloud wherever possible. We continue to check other occurrences of this vulnerability and monitor potential exploits wherever we can.\n\nFinally, as a general security practice, we recommend users review custom components for any malicious code before using them in their apps. Following security best practices such as running web servers with low privileges, firewalls, etc. for hosting your apps, helps in mitigating the severity of such exploits.\n\n### Workarounds\nNone.\n\n### References\n* https://docs.google.com/document/d/e/2PACX-1vRzF9K6gwv9KnQz---1pt0SdHMVt-CHuKMmdTH1uct7xPcK7vToP4FvYdI84aO6rGfCmrBSaViri0Nd/pub\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Email us at [security@streamlit.io](mailto:security@streamlit.io)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "streamlit"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.63.0"
      }, {
        "fixed" : "1.11.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/streamlit/streamlit/security/advisories/GHSA-v4hr-4jpx-56gc"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-35918"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/streamlit/streamlit/commit/80d9979d5f4a00217743d607078a1d867fad8acf"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/streamlit/PYSEC-2022-248.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/streamlit/streamlit"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-08-06T05:51:50Z",
    "nvd_published_at" : "2022-08-01T22:15:00Z"
  }
}