/

CVE-2026-30898

Severity:

HIGH RISK

(8.8)

Command Injection in Airflow BashOperator Usage

CVE-2026-30898

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-77

Impact:

Remote Code Execution / Privilege Escalation in Worker Environment

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

An unsafe BashOperator pattern in the Apache Airflow documentation showed how to pass dag_run.conf directly into shell commands, allowing unsanitized user-controlled data to reach the command line.

If DAG authors copied this example without sanitization or proper quoting, an attacker who can influence dag_run.conf may escalate the Airflow UI user's privileges and execute arbitrary code on workers.

Affected context

This issue affects Airflow deployments where:

  • DAGs use BashOperator (or similar shell-based operators),
  • dag_run.conf values or other user-controlled parameters are interpolated directly into shell commands,
  • and those commands are executed with the privileges of the Airflow UI user or worker service account.

The vulnerability arises only when DAG authors adopted the unsafe documentation pattern and did not apply their own validation, escaping, or strict parameterization.

Exploit preconditions

  • Attack surface: Airflow entry points that allow setting or influencing dag_run.conf (e.g., API-triggered DAG runs, UI-triggered DAG runs with configuration, or external systems that populate these fields).
  • Required access: Ability to trigger DAG runs with controlled dag_run.conf values, or to modify upstream systems that supply these values.
  • Trigger point: Execution of a BashOperator (or similar) where the DAG code concatenates or interpolates dag_run.conf directly into a shell command.
  • Why exploitation is possible: Shell metacharacters and additional commands embedded in dag_run.conf are interpreted by the shell when input is not properly quoted or sanitized, leading to command injection (CWE-77).

Why this happens

The root cause is an unsafe example in the documentation that effectively treats dag_run.conf as trusted input and directly concatenates it into shell commands executed by BashOperator.

This reflects the CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection'), where user-controlled data is passed to a shell without robust quoting, escaping, or strict allow-list validation.

By constructing commands through string interpolation rather than structured parameters or safe APIs, the pattern allows attackers to inject shell syntax, alter command behavior, and execute additional commands under the worker's privileges.

Potential impact

  • Execution of arbitrary commands on worker nodes with the privileges of the Airflow worker or UI user.
  • Escalation of logical privileges within the Airflow environment (e.g., ability to run commands beyond what the UI user is intended to do).
  • Unauthorized access to data, credentials, or internal services reachable from the worker.
  • Lateral movement within the infrastructure if workers have network access to other internal systems.
  • Disruption of scheduled workflows, data pipelines, or downstream systems through malicious commands.

General mitigation guidance

Effective mitigation focuses on treating dag_run.conf and other runtime configuration as untrusted input and avoiding direct shell interpolation.

Recommended defensive patterns include:

  • Avoiding direct command concatenation: Use parameterized, structured APIs (e.g., Python operators or libraries) instead of constructing shell commands when possible.
  • Strict quoting and escaping: When shell commands are unavoidable, apply robust quoting so that user-provided values are treated as opaque strings rather than executable syntax.
  • Input validation and allow-lists: Constrain dag_run.conf fields to a narrow set of expected values (e.g., enumerations, numeric ranges, or strongly-typed fields) and reject unexpected input early.
  • Separation of control and data: Design DAGs so that control flow and command templates are static, with user input only affecting non-sensitive parameters.
  • Least privilege for workers: Run workers and UI components with minimal OS and network privileges, ensuring that even if a command is injected, its blast radius is limited.
  • Secure-by-default guidance: Update internal examples and engineering guidelines to promote safe parameter handling in BashOperator and other shell-based tasks.

How teams detect issues like this

Organizations can identify and monitor this class of vulnerability through a combination of static analysis, review practices, and runtime controls:

  • Static analysis and linters: Search for patterns where dag_run.conf or similarly user-controlled values are directly concatenated into shell command strings in BashOperator, SSHOperator, or custom shell wrappers.
  • Code review checklists: Include explicit review items for command construction in DAGs, requiring reviewers to verify proper quoting, validation, and separation of data from control.
  • Policy-driven scanning: Implement repository scanning rules (e.g., grep-based or custom static rules) to flag usage of {{ dag_run.conf[...] }} inside shell snippets without sanitization.
  • Runtime monitoring: Use logging and anomaly detection on worker nodes to flag unexpected shell commands, unusual arguments, or patterns indicative of command injection attempts.
  • Automated security tooling: Integrate SAST and IaC security tools into CI pipelines to systematically identify command injection risks in Airflow DAG code and associated scripts.

Sources

SourceLink
github.comgithub.com/apache/airflow/pull/64129
lists.apache.orglists.apache.org/thread/26zmhfj1t95c1hld2r14ho81nzh1bdc8
openwall.comopenwall.com/lists/oss-security/2026/04/17/7

Frequently asked

questions

It can be, depending on how DAG runs are triggered. If an attacker can remotely influence dag_run.conf (for example via an API or an integrated external system), they may be able to exploit insecure BashOperator usage without direct access to the Airflow host.

The attacker needs the ability to set or control dag_run.conf values for a DAG that uses the unsafe pattern. This could be via authenticated UI/API access or via control over an upstream integration that populates those fields.

Replace shell-based logic that interpolates dag_run.conf with safer constructs: use Python operators or library calls where possible, enforce strict validation or allow-lists on configuration values, and ensure any remaining shell commands treat user data as quoted, non-executable arguments.

Establish secure coding guidelines for DAG authors, mandate reviews for any shell-command construction, use automated scanning to catch direct interpolation of untrusted input into commands, and prefer higher-level abstractions over raw shell execution whenever feasible.

Find out what's already
exploitable in your codebase.