subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
f"Invoke-ScriptAnalyzer -Path '{escaped_path}' " "-Severity Warning,Error | ConvertTo-Json" ) result = subprocess.run( ["pwsh", "-Command", ps_command], capture_output=True, text=True,- Confidence
- 84% confidence
- Finding
- Although the outer process call is argv-based, it invokes PowerShell with a dynamically constructed -Command string. The code escapes single quotes in the path, which substantially reduces direct path-based injection, but passing a composed command string into an interpreter remains a riskier pattern and can become exploitable if future changes add more interpolated values or if PowerShell parsing edge cases are missed.
