Skip to content

fix(security): replace shell=True with shell=False in subprocess calls#2111

Open
Jah-yee wants to merge 1 commit intoTEN-framework:mainfrom
Jah-yee:fix/subprocess-shell-security
Open

fix(security): replace shell=True with shell=False in subprocess calls#2111
Jah-yee wants to merge 1 commit intoTEN-framework:mainfrom
Jah-yee:fix/subprocess-shell-security

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Mar 17, 2026

Good day,

This PR addresses security vulnerabilities reported in issues #2107 and #2106.

Problem

Using shell=True in subprocess.run() calls makes command construction bugs easier to exploit by propagating current shell settings and variables. This is a well-known security anti-pattern.

Solution

Replaced shell=True with shell=False and used shlex.split() to properly parse command strings into list arguments.

Changes

  • Added shlex import to properly parse command strings
  • Changed subprocess.run(cmd, shell=True, ...) to subprocess.run(shlex.split(cmd), shell=False, ...)
  • Applied fixes to 5 files with the same vulnerability pattern:
    • ai_agents/agents/examples/voice-assistant-nodejs/tenapp/ten_packages/extension/main_nodejs/tools/run_script.py
    • packages/core_apps/default_app_cpp/tools/run_script.py
    • packages/core_extensions/default_extension_cpp/tools/run_script.py
    • packages/core_extensions/default_extension_nodejs/tools/run_script.py
    • packages/example_apps/transcriber_demo/ten_packages/extension/vtt_nodejs/tools/run_script.py

Testing

The code changes have been reviewed locally. The shlex.split() function correctly handles:

  • Simple commands (npm install)
  • Commands with arguments (npm run build)
  • Commands with multiple arguments

Local testing with Python 3 shows the modified code works correctly with the new approach.


感谢你们的奉献,希望能提供帮助。如果我解决得有问题或有待商妥的地方,请在下面留言,我会来处理。

Warmly,
Jah-yee

This patch addresses security vulnerabilities reported in issues TEN-framework#2107
and TEN-framework#2106 by replacing shell=True with shell=False in subprocess.run()
calls. Using shell=True makes command construction bugs easier to exploit
by propagating current shell settings and variables.

Changes:
- Added shlex import to properly parse command strings
- Changed subprocess.run(cmd, shell=True, ...) to subprocess.run(shlex.split(cmd), shell=False, ...)
- Applied fixes to 5 files with the same vulnerability pattern

Affected files:
- ai_agents/agents/examples/voice-assistant-nodejs/tenapp/ten_packages/extension/main_nodejs/tools/run_script.py
- packages/core_apps/default_app_cpp/tools/run_script.py
- packages/core_extensions/default_extension_cpp/tools/run_script.py
- packages/core_extensions/default_extension_nodejs/tools/run_script.py
- packages/example_apps/transcriber_demo/ten_packages/extension/vtt_nodejs/tools/run_script.py
Jah-yee pushed a commit to Jah-yee/ten-framework that referenced this pull request Mar 18, 2026
…njection

Replaces dangerous shell=True in subprocess.run with shell=False +
shlex.split() to prevent shell injection vulnerabilities in 5 files:
- ai_agents/agents/examples/voice-assistant-nodejs/.../run_script.py
- packages/core_apps/default_app_cpp/tools/run_script.py
- packages/core_extensions/default_extension_cpp/tools/run_script.py
- packages/core_extensions/default_extension_nodejs/tools/run_script.py
- packages/example_apps/transcriber_demo/.../run_script.py

Fixes issues TEN-framework#2107, TEN-framework#2106, TEN-framework#2111, TEN-framework#2113, TEN-framework#2114
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant