Command Injection in Argo Workflows
In March 2021, security researchers reported a command injection issue in Argo Workflows (see GitHub issue #5061). The report highlighted how seemingly harmless parameter substitutions could allow attackers to execute arbitrary code inside Kubernetes jobs.
In this article, you’ll learn to avoid using input parameters directly inside script bodies in Argo, and to convert parameters to environment variables instead to keep them safe. We will first explain what Argo Workflows are and why parameters can be risky. We will then cover common injection attacks against Argo templates. Next, we will show how to detect risky patterns in your code using Semgrep. Finally, we will provide concrete mitigation steps you can apply immediately in your workflows.
Understanding Argo Workflows and Parameters
Argo Workflows is a Kubernetes-native workflow engine designed to define and run complex jobs. It exists to simplify running multi-step workloads, such as data processing or CI/CD pipelines, directly inside Kubernetes. Developers can define workflows in YAML, and Argo executes the steps as pods.
The features that makes Argo so flexible, the use of parameters and templates, is also what creates security risks. Parameters in templates are written with curly brace placeholders (called mustache templates) like {{inputs.parameters.message}}. During execution they are replaced by the actual input values.
Common Injection Attacks in Argo Workflows
When mustache template placeholders are used directly inside a script or command, they act like unquoted user input, meaning they can inject arbitrary commands or code.