Skip to content

fix(security): harden subprocess calls against shell injection - #2750

Closed
nidhi-singh02 wants to merge 2 commits into
NousResearch:mainfrom
nidhi-singh02:fix/shell-injection-hardening
Closed

fix(security): harden subprocess calls against shell injection#2750
nidhi-singh02 wants to merge 2 commits into
NousResearch:mainfrom
nidhi-singh02:fix/shell-injection-hardening

Conversation

@nidhi-singh02

Copy link
Copy Markdown
Contributor

Summary

  • Replace shell=True with shlex.split() in tools/transcription_tools.py
  • Use list-based subprocess in mini-swe-agent docker cleanup to prevent injection via container_id
  • Replace assert with RuntimeError in tools/environments/docker.py (assertions stripped by python -O)

Closes #2743

Test Plan

  • Verify local STT transcription still works with the shlex.split() change
  • Verify docker container cleanup terminates containers correctly
  • Verify python -O doesn't bypass the container_id check

Platforms Tested

  • macOS

- Replace shell=True with shlex.split() in transcription_tools.py
- Use list-based subprocess in mini-swe-agent docker cleanup
- Replace assert with RuntimeError in docker environment check
After hardening against shell injection (shlex.split instead of
shell=True), both ffmpeg and whisper commands arrive as lists.
Distinguish them by checking the binary name rather than the
argument type.
@teknium1

teknium1 commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

This is now fixed via PR #5629 (merged), which sanitizes workdir with tilde-aware shlex.quote + an allowlist validator. Thanks for flagging the vulnerability!

@teknium1 teknium1 closed this Apr 6, 2026
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.

[Bug]: Command injection risk via shell=True in subprocess calls

2 participants