The vulnerability is a code injection weakness in the llm command-line tool, specifically affecting version 0.27.1 and earlier. The root cause lies in the handling of the --functions command-line argument, which is intended for users to define custom Python functions as tools for the language model. The application fails to properly sanitize or restrict the input provided to this argument.
The user-provided string is passed to the _tools_from_code function within llm/cli.py. This function directly uses the exec() function to execute the input string as Python code. This allows an attacker to inject and execute arbitrary Python code on the system running the llm tool. The vulnerability can be triggered through several commands that accept the --functions argument, including llm prompt, llm chat, and llm tools list. An attacker could exploit this by tricking a user into executing a malicious llm command, leading to a full compromise of the user's system.