CVE-2023-24816: set_term_title command injection in ipython
IPython (Interactive Python) is a command shell for interactive computing in multiple programming languages, originally developed for the Python programming language. Versions prior to 8.1.0 are subject to a command injection vulnerability with very specific prerequisites. This vulnerability requires that the function IPython.utils.terminal.settermtitle be called on Windows in a Python environment where ctypes is not available. The dependency on ctypes in IPython.utils.processwin32 prevents the vulnerable code from ever being reached in the ipython binary. However, as a library that could be used by another tool settermtitle could be called and hence introduce a vulnerability. Should an attacker get untrusted input to an instance of this function they would be able to inject shell commands as current process and limited to the scope of the current process. Users of ipython as a library are advised to upgrade. Users unable to upgrade should ensure that any calls to the IPython.utils.terminal.settermtitle function are done with trusted or filtered input.
Other sources
IPython could allow a local attacker to execute arbitrary commands on the system, caused by a flaw in the IPython.utils.terminal.settermtitle function. By sending a specially-crafted request with ctypes is not available, an attacker could exploit this vulnerability to execute arbitrary commands as current process on the system.
— IBM
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 settermtitle function 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 is not available. The dependency on ctypes in IPython.utils.processwin32 prevents the vulnerable code from ever being reached (making it effectively dead code). However, as a library that could be used by another tool, settermtitle could introduce a vulnerability for dependencies. Currently settermtitle 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.
— GitHub
Affected Software
Remediation
Event History
Frequently Asked Questions
What is CVE-2023-24816?
CVE-2023-24816 is a vulnerability that allows for command injection in the `set_term_title` function in IPython.
What is the severity of CVE-2023-24816?
CVE-2023-24816 has a severity level of 7 (high).
How does CVE-2023-24816 affect IPython?
Versions of IPython prior to 8.10.0 are affected by CVE-2023-24816.
How can I fix CVE-2023-24816?
To fix CVE-2023-24816, upgrade to IPython version 8.10.0 or later.
Are there any references for CVE-2023-24816?
Yes, you can find more information about CVE-2023-24816 in the following references: [Reference 1](https://github.com/ipython/ipython/security/advisories/GHSA-29gw-9793-fvw7), [Reference 2](https://github.com/ipython/ipython/commit/385d69325319a5972ee9b5983638e3617f21cb1f), [Reference 3](https://github.com/ipython/ipython/commit/991849c247fc208628879e7ca2923b3c218a5a75).