subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def _npm_package_installed(pkg: str) -> bool: """Check if an npm package is installed globally.""" result = subprocess.run( ["npm", "list", "-g", pkg], capture_output=True, text=True, shell=(platform.system() == "Windows")- Confidence
- 91% confidence
- Finding
- This npm subprocess is executed with `shell=True` on Windows while incorporating a package name that can come from a manifest or track file. Even though a list is supplied, enabling shell invocation on Windows increases command-injection risk and allows attacker-controlled package values to influence shell parsing or invoke unexpected behavior in a cleanup utility that may run with broad local privileges.
