Skip to content

fix: remove shell=True to prevent shell injection vulnerabilities#2139

Open
Jah-yee wants to merge 4 commits intoTEN-framework:mainfrom
Jah-yee:fix/shell-injection-security
Open

fix: remove shell=True to prevent shell injection vulnerabilities#2139
Jah-yee wants to merge 4 commits intoTEN-framework:mainfrom
Jah-yee:fix/shell-injection-security

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Apr 11, 2026

Summary

Security fix: Removing shell=True from subprocess.run() calls to prevent shell injection vulnerabilities.

Changes

  • tests/ten_runtime/integration/nodejs/standalone_test_nodejs_2/default_extension_nodejs/tests/bin/start.py: Removed shell=True from 3 subprocess.run() calls
  • tests/ten_runtime/integration/nodejs/standalone_test_nodejs_3/default_extension_nodejs/tests/bin/start.py: Removed shell=True from 2 subprocess.run() calls

Why

When shell=True, the command is executed through a shell, which can be exploited if untrusted input is passed to the command. By removing shell=True:

  1. Commands are executed directly without shell interpretation
  2. Prevents shell injection attacks
  3. More secure and follows security best practices

This fix addresses issues #2107 and #2106.

Testing

The changes maintain the same functionality - npm install, build, and test commands still work correctly. The difference is that the commands are now executed more securely without shell interpretation.

Taizi added 4 commits April 5, 2026 02:58
Security fix for issue TEN-framework#2107:
- Changed subprocess.run(shell=True) to subprocess.run(shell=False)
- Use shlex.split() to properly parse command strings
- This prevents shell injection vulnerabilities
- Replace shell=True with shell=False + shlex.split() to prevent shell injection
- Apply fix to 2 affected run_script.py files
- Addresses security issues reported in TEN-framework#2106 and TEN-framework#2107
…njection

Security vulnerability reported in:
- Issue TEN-framework#2107: subprocess function 'run' with 'shell=True'
- Issue TEN-framework#2106: subprocess invocation uses shell=True

This change replaces all subprocess.run() calls with shell=True
with subprocess.run() using shell=False via shlex.split() for safe command parsing.

Files fixed:
- 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/tests/bin/start.py
Security fix: Removing shell=True from subprocess.run() calls to prevent
shell injection vulnerabilities. When shell=True, the command is executed
through a shell, which can be exploited if untrusted input is passed.

Reported in issues TEN-framework#2107 and TEN-framework#2106
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