CVE-2022-21699: Ipython Execution With Unnecessary Privileges Vulnerability

HIGH
Advisory Identifier: GHSA-pq7m-3gw7-gq5x
CVSS 8.2
CWE-279 CWE-269 CWE-250
Published
Advisory Summary

CVE-2022-21699 is a HIGH (CVSS 8.2) execution with unnecessary privileges vulnerability (CWE-279: Incorrect Execution-Assigned Permissions) affecting Ipython libraries in the PyPI ecosystem. The issue involves execution with unnecessary privileges in ipython. Remediation is available by upgrading affected packages to version 5.11, 7.16.3, 7.31.1, 8.0.1.

CVE-2022-21699 at a Glance

CVE Identifier CVE-2022-21699
GHSA Identifier GHSA-pq7m-3gw7-gq5x
Severity HIGH
CVSS v3.1 Base Score 8.2
CWE Classification CWE-279: Incorrect Execution-Assigned Permissions
Affected Product Ipython
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.2

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

Attack Vector Local (AV:L)
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 High (A:H)

How to Fix CVE-2022-21699

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

ipython fixed: 5.11
pip install ipython>=5.11
ipython fixed: 7.16.3
pip install ipython>=7.16.3
ipython fixed: 7.31.1
pip install ipython>=7.31.1
ipython fixed: 8.0.1
pip install ipython>=8.0.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 ipython

How to Check if You Are Affected

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

pip show ipython

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-279: Incorrect Execution-Assigned Permissions, where while it is executing, the product sets the permissions of an object in a way that violates the intended permissions that have been specified by the user. In Ipython, 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

We’d like to disclose an arbitrary code execution vulnerability in IPython that stems from IPython executing untrusted files in CWD. This vulnerability allows one user to run code as another. Proof of concept User1: ``` mkdir -m 777 /tmp/profile_default mkdir -m 777 /tmp/profile_default/startup echo 'print("stealing your private secrets")' > /tmp/profile_default/startup/foo.py ``` User2: ``` cd /tmp ipython ``` User2 will see: ``` Python 3.9.7 (default, Oct 25 2021, 01:04:21) Type 'copyright', 'credits' or 'license' for more information IPython 7.29.0 -- An enhanced Interactive Python. Type '?' for help. stealing your private secrets ``` ## Patched release and documentation See https://ipython.readthedocs.io/en/stable/whatsnew/version8.html#ipython-8-0-1-cve-2022-21699, Version 8.0.1, 7.31.1 for current Python version are recommended. Version 7.16.3 has also been published for Python 3.6 users, Version 5.11 (source only, 5.x branch on github) for older Python versions.

CVE-2022-21699 Affected Ipython Versions

4 component(s)
Fixed Versions:
5.117.16.37.31.18.0.1
Product / Package Ecosystem Affected Versions Fixed Version
ipython
PyPI
< 5.11
5.11
ipython
PyPI
≥ 6.0.0
< 7.16.3
7.16.3
ipython
PyPI
≥ 7.17.0
< 7.31.1
7.31.1
ipython
PyPI
≥ 8.0.0
< 8.0.1
8.0.1

References

Frequently Asked Questions

What is CVE-2022-21699?
CVE-2022-21699 is a security vulnerability in Ipython involving Execution with Unnecessary Privileges in ipython under CWE-279: Incorrect Execution-Assigned Permissions.
Which Ipython versions are affected?
Affected versions include releases prior to 5.11, 7.16.3, 7.31.1, 8.0.1 across affected packages: ipython.
What version fixes CVE-2022-21699?
Upgrading to 5.11, 7.16.3, 7.31.1, 8.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is ipython affected?
Yes, ipython is affected in releases prior to 5.11, 7.16.3, 7.31.1, 8.0.1. Upgrade your dependency to 5.11, 7.16.3, 7.31.1, 8.0.1 or later.
What is the CVSS score of CVE-2022-21699?
CVE-2022-21699 has a CVSS v3.1 base score of 8.2 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2022-21699?
CVE-2022-21699 is classified under CWE-279: Incorrect Execution-Assigned Permissions (While it is executing, the product sets the permissions of an object in a way that violates the intended permissions that have been specified by the user.).
How can I check PyPI dependencies for CVE-2022-21699?
Run the dependency tree command: 'pip show ipython'. 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-pq7m-3gw7-gq5x",
  "modified" : "2024-09-27T17:22:07Z",
  "published" : "2022-01-21T18:55:30Z",
  "aliases" : [ "CVE-2022-21699" ],
  "summary" : "Execution with Unnecessary Privileges in ipython",
  "details" : "We’d like to disclose an arbitrary code execution vulnerability in IPython that stems from IPython executing untrusted files in CWD. This vulnerability allows one user to run code as another.\n \nProof of concept\n\nUser1:\n```\nmkdir -m 777 /tmp/profile_default\nmkdir -m 777 /tmp/profile_default/startup\necho 'print(\"stealing your private secrets\")' > /tmp/profile_default/startup/foo.py\n```\n\nUser2:\n```\ncd /tmp\nipython\n```\n\n \n\nUser2 will see:\n```\nPython 3.9.7 (default, Oct 25 2021, 01:04:21)\nType 'copyright', 'credits' or 'license' for more information\nIPython 7.29.0 -- An enhanced Interactive Python. Type '?' for help.\nstealing your private secrets\n```\n\n\n## Patched release and documentation\n\nSee https://ipython.readthedocs.io/en/stable/whatsnew/version8.html#ipython-8-0-1-cve-2022-21699, \n\nVersion 8.0.1, 7.31.1 for current Python version are recommended. \nVersion 7.16.3 has also been published for Python 3.6 users, \nVersion 5.11 (source only, 5.x branch on github) for older Python versions.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:A/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/E:P"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "ipython"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.11"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "ipython"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.0.0"
      }, {
        "fixed" : "7.16.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "ipython"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "7.17.0"
      }, {
        "fixed" : "7.31.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "ipython"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "8.0.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ipython/ipython/security/advisories/GHSA-pq7m-3gw7-gq5x"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-21699"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ipython/ipython/commit/46a51ed69cdf41b4333943d9ceeb945c4ede5668"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ipython/ipython/commit/5fa1e409d2dc126c456510c16ece18e08b524e5b"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ipython/ipython/commit/67ca2b3aa9039438e6f80e3fccca556f26100b4d"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ipython/ipython/commit/a06ca837273271b4acb82c29be97c0b6d12a30ea"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ipython/ipython"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/ipython/PYSEC-2022-12.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://ipython.readthedocs.io/en/stable/whatsnew/version8.html#ipython-8-0-1-cve-2022-21699"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2022/01/msg00021.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/CRQRTWHYXMLDJ572VGVUZMUPEOTPM3KB"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/DZ7LVZBB4D7KVSFNEQUBEHFO3JW6D2ZK"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-250", "CWE-269", "CWE-279" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-01-19T21:26:17Z",
    "nvd_published_at" : "2022-01-19T22:15:00Z"
  }
}