Summary
Apache Airflow's example_dag_decorator example DAG can place a value derived from an HTTP response into a shell command after checking it with Python's ipaddress module. When example DAGs are enabled, a user who can trigger the DAG with a custom URL may be able to cause command execution on the worker if the response contains a crafted IPv6 zone identifier.
Affected context
The issue occurs in Airflow deployments that load the example_dag_decorator example DAG and allow a user to trigger it with a custom url parameter. The validation accepts IPv6 zone identifiers containing characters that can affect shell command interpretation, and the resulting value is used in a shell command on the worker.
Exploit preconditions
- Attack surface: The Airflow example DAG and its HTTP request handling
- Required access: Ability to trigger the DAG and supply a custom
urlparameter - Trigger point: Processing the HTTP response and constructing the shell command
- Why exploitation is possible: The IP address check accepts zone identifiers containing arbitrary characters, and the validated value is subsequently placed into a shell command
Why this happens
The code treats successful IP parsing as proof that a value is safe for shell use. Python's ipaddress module accepts IPv6 zone identifiers that may contain characters with meaning to a shell; placing such a value into a command creates an OS command injection risk. This maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command.
Potential impact
- An attacker may execute commands on the Airflow worker
- Worker processes or data accessible to the worker could be compromised
- Depending on worker permissions and environment, an attacker could affect other workloads or systems
General mitigation guidance
Mitigation generally focuses on removing shell interpretation from data-handling paths and reducing exposure to example code.
Common defensive patterns include:
- Disable example DAG loading in production environments
- Avoid constructing shell commands from request or response data; use APIs that pass arguments directly to a process without invoking a shell
- Apply strict, purpose-specific validation and canonicalization rather than relying on IP parsing as shell-safety validation
- Run workers with least privilege and limit their access to sensitive resources
- Treat HTTP responses and user-supplied parameters as untrusted input
How teams detect issues like this
High-level review and monitoring can focus on:
- Static analysis patterns that identify shell execution APIs receiving interpolated or concatenated values
- Code review of validation-to-command flows, especially values derived from HTTP responses or DAG parameters
- Policies that prohibit shell-based execution where direct process APIs are suitable
- Airflow configuration checks that identify enabled example DAGs in production
- Runtime monitoring for unexpected process launches by worker tasks

