# CVE-2022-40127: RCE in Apache Airflow <2.4.0 bash example

Example BashOperator DAG interpolates user-controlled run_id into bash_command, letting any UI user who can trigger DAGs execute arbitrary OS commands.

- Payout: $4,000
- Severity: high
- Program: Internet Bug Bounty
- Found by (vendor credit): L3yx of Syclover Security Team
- Found by: leixiao
- Disclosed: 2023-01-05
- CVE: CVE-2022-40127
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/1776476
- Library page: https://bugbountylibrary.com/r/h1%3A1776476
- Tags: area:cloud domain:infra impact:privesc impact:rce kind:bounty platform:hackerone sev:high tech:python technique:source-review vuln:command-injection vuln:rce

**Target:** Apache Airflow example DAGs (example_bash_operator.py BashOperator)
**Root cause:** BashOperator's bash_command template embeds `{{ run_id }}` directly; run_id is attacker-controlled via 'Trigger DAG w/ config' and is not sanitized before shell execution.
**Steps:**
1. Enable example DAGs on Airflow <2.4.0
2. Open DAGs menu, select example_bash_operator, choose 'Trigger DAG w/ config'
3. Set run_id to `` `touch /tmp/success` `` and trigger
4. BashOperator renders bash_command with injected backticks and executes the command
**How found:** Code reading of example_bash_operator.py revealed `{{ run_id }}` interpolated into bash_command; hypothesis that run_id is user-controllable via the trigger-with-config UI was confirmed by injecting backticks.
**Exploitation:** Any authenticated UI user with DAG-trigger permission supplies a run_id containing shell metacharacters/backticks; the templated bash_command is executed by the scheduler/worker shell, yielding arbitrary command execution as the Airflow worker user.
**Insight:** Example/sample DAGs shipped in products are live attack surface: grep bundled templates for user-controllable Jinja variables (run_id, dag_run, params) rendered into BashOperator/PythonOperator commands.

## Proof of concept (copied exactly from the original report)

**Vulnerable BashOperator with run_id template**

```
also_run_this = BashOperator(
        task_id='also_run_this',
        bash_command='echo "run_id={{ run_id }} | dag_run={{ dag_run }}"',
    )
```

**run_id payload triggering command injection**

```
Set the run_id to " `touch /tmp/success` " and trigger.
```

