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

CVE-2022-38362: Apache Airflow Docker Provider <3.0 RCE vulnerability in example dag

An example DAG in the Apache Airflow Docker provider passed a user-supplied parameter into a shell command without sanitisation, allowing an authenticated user to run arbitrary commands on the Airflow worker host.

x_h1 Follow

Originally disclosed on HackerOne

High 8.8 View original
  • Triaged in 22 hours
  • Fixed in 8 days
  • Paid in 8 days
  • Disclosed after 38 days

Summary by the program

CVE-2022-38362: Apache Airflow Docker Provider <3.0 RCE vulnerability in example dag

Description:

Apache Airflow Docker's Provider shipped with an example DAG that was vulnerable to (authenticated) remote code exploit of code on the Airflow worker host.

Mitigation:

Disable loading of example DAGs or upgrade the apache-airflow-providers-docker to 3.0.0 or above

Credit:

Thanks to Kai Zhao of 3H Secruity Team for reporting this

Security Advisory: https://lists.apache.org/thread/614p38nf4gbk8xhvnskj9b1sqo2dknkb

The report

Apache Airflow Docker's Provider shipped with an example DAG that was vulnerable to (authenticated) remote code exploit of code on the Airflow worker host.

##Vulnerability summary: In DAG script of airflow 2.3.3, there is a command injection vulnerability (RCE) in the script (example_docker_copy_data.py of docker provider), which can obtain the permission of the operating system.

source path: airflow-2.3.3/airflow/providers/docker/example_dags/example_docker_copy_data.py

##Vulnerability details: (1) Vulnerability principle:

  1. It can be seen from the source code of example_docker_copy_data.py script that there is the function of executing bash command, The parameter ‘source_location’ in the template expression {{params.source_location}} is externally controllable and rendered through the jiaja2 template:
1.png
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;
2.png
2.png From the original on HackerOne

(2)Vulnerability exploit:

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

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

3.png
3.png From the original on HackerOne
  1. To construct payload, we can separate commands with ‘;’, so as to inject any operating system commands to be executed(RCE).
4.png
4.png From the original on HackerOne

PAYLOAD:{"source_location":";touch /tmp/thisistest;"}, Then click trigger to execute the task.

5.png
5.png From the original on HackerOne

The final command is as follows:

find ;touch /tmp/thisistest; -type f -printf “%f\n” | head -1
“””

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

6.png
6.png From the original on HackerOne
7.png
7.png

Impact

An attacker can execute arbitrary commands on the airflow host.

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 authenticated user could execute arbitrary commands on the Airflow worker host.

What the attacker needed

Authenticated Airflow user; example DAGs enabled

The fix

Mitigation is to upgrade apache-airflow-providers-docker to 3.0.0 or above, or disable loading of example DAGs.

How it was found

  1. Open the DAGs menu and choose 'Trigger DAG w/ config' for the docker_sample_copy_data task.
  2. Supply a source_location value containing a semicolon followed by an operating system command.
  3. Trigger the DAG and observe that the injected command runs on the worker host.

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.

A DAG is a workflow definition in Apache Airflow. One example workflow took a value from the person starting it and put it directly into a shell command, so typing extra shell commands after a semicolon made the server run them.

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.