From 999b3fec2e157131ffa628e8fdac31adb0de02e3 Mon Sep 17 00:00:00 2001 From: Aarush <112254386+Hadar01@users.noreply.github.com> Date: Tue, 17 Mar 2026 18:23:13 +0530 Subject: [PATCH] fix: replace shell=True subprocess with argument list in modal CLI (#3487) * fix: replace shell=True subprocess with argument list in modal CLI Using shell=True with a formatted string containing docker_image (a user-controlled value) is a command injection risk (Bandit B602). Replace with an argument list, which passes args directly to the process without shell interpretation, removing the nosec annotation. * fix: add nosec annotation to suppress bandit B603/B607 warnings Removing shell=True (B602) surfaces B603 (subprocess without shell) and B607 (partial executable path for 'docker'). Use bare # nosec to suppress both, consistent with other nosec usages in the codebase. --- src/axolotl/cli/cloud/modal_.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/axolotl/cli/cloud/modal_.py b/src/axolotl/cli/cloud/modal_.py index 3e703a494..df8f8f215 100644 --- a/src/axolotl/cli/cloud/modal_.py +++ b/src/axolotl/cli/cloud/modal_.py @@ -90,9 +90,8 @@ class ModalCloud(Cloud): # grab the sha256 hash from docker hub for this image+tag # this ensures that we always get the latest image for this tag, even if it's already cached try: - manifest = subprocess.check_output( # nosec B602 - f"docker manifest inspect {docker_image}", - shell=True, + manifest = subprocess.check_output( # nosec + ["docker", "manifest", "inspect", docker_image], ).decode("utf-8") sha256_hash = json.loads(manifest)["manifests"][0]["digest"] except subprocess.CalledProcessError: