Skip to content

unix-command-wildcard-injection (S609)

Added in v0.0.271 · Related issues · View source

Derived from the flake8-bandit linter.

What it does

Checks for possible wildcard injections in calls to subprocess.Popen().

Why is this bad?

Wildcard injections can lead to unexpected behavior if unintended files are matched by the wildcard. Consider using a more specific path instead.

Example

import subprocess

subprocess.Popen(["chmod", "777", "*.py"], shell=True)

Use instead:

import subprocess

subprocess.Popen(["chmod", "777", "main.py"], shell=True)

References