Skip to content

Conversation

@paipeline
Copy link

Fixes critical RCE vulnerability in Bash tool exposed to LLM agents.

  • Add command validation with safe allowlist
  • Block dangerous patterns (curl, wget, rm -rf, sudo, etc.)
  • Comprehensive tests (22 cases, all passing)
  • Maintains backward compatibility

Fixes #1931

…njection

- Add command validation with safe command allowlist
- Block dangerous patterns (curl, wget, rm -rf, sudo, etc.)
- Prevent shell metacharacters and command substitution
- Add comprehensive validation tests
- Fixes issue FoundationAgents#1931 - Command Injection via Bash.run() LLM Tool Registration

The Bash class was previously exposed to LLM agents without any validation,
allowing arbitrary command execution via prompt injection attacks. This fix
implements strict input validation while preserving legitimate functionality.

Security improvements:
- Allowlist of safe commands (ls, git, python3, custom shell functions, etc.)
- Regex patterns to detect dangerous commands and shell metacharacters
- Proper error messages when commands are blocked
- Comprehensive test coverage for validation logic

This maintains backward compatibility for legitimate uses while preventing
Remote Code Execution attacks via malicious LLM prompts.
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.

Command Injection via Bash.run() LLM Tool Registration

2 participants