-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Description:
Affected File: /home/hejunjie/llm_web_serve/servers1/speechless/speechless/infer/ollama/osh.py
Vulnerability:
The osh.py script, designed to translate natural language prompts into shell commands using Ollama, includes a -y (or --yes) command-line argument. When this flag is used, the script bypasses the user confirmation prompt (Execute ? (y/N/[e]xplain)) and directly executes the command generated by the Large Language Model (LLM) via os.system(cmd) (line 379).
While the script's default behavior requires user confirmation, the -y flag removes this critical safeguard. This creates a potential command execution vulnerability if:
- The Ollama LLM generates malicious or unintended commands: Although LLMs are designed to be helpful, there's a theoretical risk that a compromised or specifically crafted prompt could lead the model to generate harmful shell commands (e.g.,
rm -rf /,curl | sh, or other system-altering commands). - The user executes
osh.pywith-yin an automated or unmonitored environment: In such scenarios, the absence of a manual review step means that any malicious output from the LLM would be executed immediately without intervention.
Impact:
Successful exploitation could lead to arbitrary command execution on the user's system, potentially resulting in data loss, system compromise, or unauthorized access, depending on the nature of the malicious command and the privileges of the user running the script.
Recommendation:
Consider the following measures to mitigate this risk:
- Stronger Warning/Documentation: Emphasize the security implications of using the
-yflag in the documentation and potentially add a more prominent warning when the script is run with this flag. - Command Sanitization/Validation (Advanced): While challenging with LLM-generated content, explore methods to validate or sanitize the generated commands before execution, even when
-yis present. This could involve a whitelist/blacklist approach for commands or arguments, though this is complex and might limit functionality. - Principle of Least Privilege: Advise users to run
osh.pywith the lowest possible user privileges.