Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/dummy_vulnerable_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ def run_ping(host):

def run_backup(user_supplied_path):
# Vulnerability: command injection with subprocess.Popen and shell=True.
return subprocess.Popen("tar czf backup.tgz " + user_supplied_path, shell=True)
# Fixed: changed shell=True to shell=False and used shlex.split to safely handle user input.
import shlex
command = ["tar", "czf", "backup.tgz", shlex.quote(user_supplied_path)]
return subprocess.Popen(command, shell=False)


def run_admin_task(task_name):
Expand Down
Loading