CVE-2023-24816: Ipython IPython Vulnerable To Command Injection Vulnerability

LOW
Advisory Identifier: GHSA-29gw-9793-fvw7
CVSS 4.5
CWE-78 CWE-20
Published
Advisory Summary

CVE-2023-24816 is a LOW (CVSS 4.5) ipython vulnerable to command injection vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Ipython libraries in the PyPI ecosystem. The issue involves ipython vulnerable to command injection via set_term_title. Remediation is available by upgrading affected packages to version 8.10.0.

CVE-2023-24816 at a Glance

CVE Identifier CVE-2023-24816
GHSA Identifier GHSA-29gw-9793-fvw7
Severity LOW
CVSS v3.1 Base Score 4.5
CWE Classification CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Affected Product Ipython
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 4.5

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

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

How to Fix CVE-2023-24816

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: 8.10.0
pip install ipython>=8.10.0
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-2023-24816, 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 8.10.0), 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-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. 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

IPython provides an interactive Python shell and Jupyter kernel to use Python interactively. Versions prior to 8.10.0 are vulnerable to command injection in the `set_term_title` [function](https://github.com/ipython/ipython/blob/3f0bf05f072a91b2a3042d23ce250e5e906183fd/IPython/utils/terminal.py#L103-L117) under specific conditions. This has been patched in version 8.10.0. ### Impact Users are only vulnerable when calling this function in Windows in a Python environment where [ctypes](https://docs.python.org/3/library/ctypes.html) is not available. The dependency on ctypes in `IPython.utils._process_win32` prevents the vulnerable code from ever being reached (making it effectively dead code). However, as a library that could be used by another tool, `set_term_title` could introduce a vulnerability for dependencies. Currently `set_term_title` is only called with (semi-)trusted input that contain the current working directory of the current IPython session. If an attacker can control directory names, and manage to get a user to `cd` into this directory, then the attacker can execute arbitrary commands contained in the folder names.

CVE-2023-24816 Affected Ipython Versions

1 component(s)
Fixed Versions:
8.10.0
Product / Package Ecosystem Affected Versions Fixed Version
ipython
PyPI
< 8.10.0
8.10.0

References

Frequently Asked Questions

What is CVE-2023-24816?
CVE-2023-24816 is a security vulnerability in Ipython involving IPython vulnerable to command injection via set_term_title under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Which Ipython versions are affected?
Affected versions include releases prior to 8.10.0 across affected packages: ipython.
What version fixes CVE-2023-24816?
Upgrading to 8.10.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is ipython affected?
Yes, ipython is affected in releases prior to 8.10.0. Upgrade your dependency to 8.10.0 or later.
What is the CVSS score of CVE-2023-24816?
CVE-2023-24816 has a CVSS v3.1 base score of 4.5 (LOW) with vector string CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2023-24816?
CVE-2023-24816 is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') (The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.).
How can I check PyPI dependencies for CVE-2023-24816?
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-29gw-9793-fvw7",
  "modified" : "2024-09-24T20:44:43Z",
  "published" : "2023-02-10T19:55:53Z",
  "aliases" : [ "CVE-2023-24816" ],
  "summary" : "IPython vulnerable to command injection via set_term_title",
  "details" : "IPython provides an interactive Python shell and Jupyter kernel to use Python interactively. Versions prior to 8.10.0 are vulnerable to command injection in the `set_term_title` [function](https://github.com/ipython/ipython/blob/3f0bf05f072a91b2a3042d23ce250e5e906183fd/IPython/utils/terminal.py#L103-L117) under specific conditions. This has been patched in version 8.10.0.\n\n### Impact \nUsers are only vulnerable when calling this function in Windows in a Python environment where [ctypes](https://docs.python.org/3/library/ctypes.html) is not available. The dependency on ctypes in `IPython.utils._process_win32` prevents the vulnerable code from ever being reached (making it effectively dead code). However, as a library that could be used by another tool, `set_term_title` could introduce a vulnerability for dependencies. Currently `set_term_title` is only called with (semi-)trusted input that contain the current working directory of the current IPython session. If an attacker can control directory names, and manage to get a user to `cd` into this directory, then the attacker can execute arbitrary commands contained in the folder names.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:P/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "ipython"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "8.10.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ipython/ipython/security/advisories/GHSA-29gw-9793-fvw7"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-24816"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ipython/ipython/commit/385d69325319a5972ee9b5983638e3617f21cb1f"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ipython/ipython/commit/991849c247fc208628879e7ca2923b3c218a5a75"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Carreau/ipython/blob/7557ade0ed927475d5ab5b573d0ea4febfb22683/docs/source/whatsnew/version8.rst#ipython-810"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ipython/ipython"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ipython/ipython/blob/3f0bf05f072a91b2a3042d23ce250e5e906183fd/IPython/utils/terminal.py#L103-L117"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ipython/ipython/blob/56e6925dfa50e2c7f4a6471547b8176275db7c25/IPython/utils/_process_win32.py#L20"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/ipython/PYSEC-2023-17.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20", "CWE-78" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-02-10T19:55:53Z",
    "nvd_published_at" : "2023-02-10T20:15:00Z"
  }
}