Apache Airflow Security
Last updated
Last updated
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Apache Airflow serves as a platform for orchestrating and scheduling data pipelines or workflows. The term "orchestration" in the context of data pipelines signifies the process of arranging, coordinating, and managing complex data workflows originating from various sources. The primary purpose of these orchestrated data pipelines is to furnish processed and consumable data sets. These data sets are extensively utilized by a myriad of applications, including but not limited to business intelligence tools, data science and machine learning models, all of which are foundational to the functioning of big data applications.
Basically, Apache Airflow will allow you to schedule the execution of code when something (event, cron) happens.
You can use the docker-compose config file from https://raw.githubusercontent.com/apache/airflow/main/docs/apache-airflow/start/docker-compose.yaml to launch a complete apache airflow docker environment. (If you are in MacOS make sure to give at least 6GB of RAM to the docker VM).
One easy way to run apache airflow is to run it with minikube:
Airflow might store sensitive information in its configuration or you can find weak configurations in place:
Before start attacking Airflow you should understand how permissions work:
If you have access to the web console you might be able to access some or all of the following information:
Variables (Custom sensitive information might be stored here)
Connections (Custom sensitive information might be stored here)
Access them in http://<airflow>/connection/list/
Configuration (Sensitive information like the secret_key
and passwords might be stored here)
List users & roles
Code of each DAG (which might contain interesting info)
Variables can be stored in Airflow so the DAGs can access their values. It's similar to secrets of other platforms. If you have enough permissions you can access them in the GUI in http://<airflow>/variable/list/
.
Airflow by default will show the value of the variable in the GUI, however, according to this it's possible to set a list of variables whose value will appear as asterisks in the GUI.
However, these values can still be retrieved via CLI (you need to have DB access), arbitrary DAG execution, API accessing the variables endpoint (the API needs to be activated), and even the GUI itself! To access those values from the GUI just select the variables you want to access and click on Actions -> Export. Another way is to perform a bruteforce to the hidden value using the search filtering it until you get it:
If the expose_config
configuration is set to True, from the role User and upwards can read the config in the web. In this config, the secret_key
appears, which means any user with this valid they can create its own signed cookie to impersonate any other user account.
If you have write access to the place where the DAGs are saved, you can just create one that will send you a reverse shell. Note that this reverse shell is going to be executed inside an airflow worker container:
If you set something to be executed in the root of the code, at the moment of this writing, it will be executed by the scheduler after a couple of seconds after placing it inside the DAG's folder.
If you manage to compromise a machine inside the DAG cluster, you can create new DAGs scripts in the dags/
folder and they will be replicated in the rest of the machines inside the DAG cluster.
When you execute a DAG from the GUI you can pass arguments to it. Therefore, if the DAG is not properly coded it could be vulnerable to Command Injection. That is what happened in this CVE: https://www.exploit-db.com/exploits/49927
All you need to know to start looking for command injections in DAGs is that parameters are accessed with the code dag_run.conf.get("param_name")
.
Moreover, the same vulnerability might occur with variables (note that with enough privileges you could control the value of the variables in the GUI). Variables are accessed with:
If they are used for example inside a a bash command, you could perform a command injection.
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)