Skip to content

security: Fix Shell Injection Vulnerabilities (CWE-78) - 29 instances across subprocess calls #1320

@praisonai-triage-agent

Description

@praisonai-triage-agent

Security Vulnerability Report: Shell Injection (CWE-78)

Background Context

Following the security audit conducted for PR #1319, 29 instances of shell injection vulnerabilities remain unaddressed across the PraisonAI codebase. These were identified by semgrep security scanning using the OWASP Top 10 and Python security rulesets.

Related Work: PR #1319 successfully fixed 29 MD5/debug vulnerabilities, but deliberately excluded these shell injection issues as they require architectural decisions from maintainers.

Vulnerability Summary

Category Count CWE Risk Level
subprocess with user input 14 CWE-78 HIGH
subprocess(..., shell=True) 10 CWE-78 HIGH
Tainted env args in subprocess 5 CWE-78 MEDIUM
TOTAL 29

Technical Details

1. Subprocess with User Input (14 instances)

Risk: Direct user input passed to subprocess.run() without proper sanitization.
Impact: Attackers can inject arbitrary commands through user-controlled parameters.

2. Subprocess with shell=True (10 instances)

Risk: Using shell=True enables command injection if any part of the command string is attacker-controlled.
Impact: Full command execution with application privileges.

3. Tainted Environment Args (5 instances)

Risk: User-controlled environment variables passed to subprocess calls.
Impact: Environment variable injection leading to command execution.

Recommended Remediation Strategy

Phase 1: Immediate Fixes (Low Risk)

  1. Replace shell=True with shell=False where possible
  2. Input validation and sanitization using shlex.quote()

Phase 2: Architectural Review (Medium Risk)

  1. Review command construction patterns across CLI, tools, agents
  2. Consider subprocess alternatives - library APIs, allow-lists, wrappers

Phase 3: Security Hardening (Long-term)

  1. Implement security controls - detection, logging, monitoring

References

Success Criteria

  • All 29 shell injection instances remediated
  • Security scan shows 0 CWE-78 findings
  • All functionality tested and working
  • Documentation updated with secure coding practices

Priority: HIGH | Effort: Medium to Large

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentationsecurity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions