/

CVE-2026-50203

Severity:

CRITICAL RISK

(9.1)

Path Traversal (CWE-22) in Airflow SFTP Provider

CVE-2026-50203

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal issue in Apache Airflow's SFTP provider allows a malicious or compromised SFTP server to write files outside the intended local download directory.

When Airflow tasks use the vulnerable SFTP hook or operator against untrusted servers, crafted directory-entry names can cause files to be stored in arbitrary filesystem locations on the worker.

Affected context

This vulnerability affects Apache Airflow deployments that use the SFTP provider to download directories from SFTP servers which may be untrusted or only partially trusted.

It specifically involves the SFTPHook.retrieve_directory method and SFTPOperator when invoked with operation="get", where directory contents are recursively mirrored to a local destination.

The risk arises when directory-entry names received from the remote SFTP server are not fully normalized and validated against the configured local base directory, allowing crafted paths to escape the intended target folder.

Exploit preconditions

  • Attack surface: Any Airflow worker or task instance that downloads directories from an SFTP server via SFTPHook.retrieve_directory or SFTPOperator(operation="get").
  • Required access: Ability to control or compromise the remote SFTP server, or influence directory-entry names returned over SFTP (e.g., by adding files or symlinks with crafted paths).
  • Trigger point: Execution of a DAG task that performs a directory download from the affected SFTP provider to a local destination path.
  • Why exploitation is possible: The implementation trusts path components supplied by the remote SFTP server and concatenates them with the local destination directory without robust normalization and containment checks, enabling traversal outside the configured directory.

Why this happens

The root cause aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

The SFTP provider logic constructs local file paths directly from server-supplied filenames and directory names, assuming they are safe to place under the configured destination directory.

Without strict canonicalization and validation (e.g., rejecting .., absolute paths, or mixed separators after normalization), an attacker-controlled SFTP server can return entries whose names traverse out of the destination directory, causing file writes in unintended locations.

This pattern reflects a broader class of bugs where external path input is used for filesystem operations without enforcing a fixed, contained root.

Potential impact

  • Malicious files could be written outside the intended download folder.
  • Sensitive configuration or application files may be overwritten if the Airflow worker process has write permission.
  • New files can be planted in locations that influence application behavior (e.g., plugin folders, scripts, or data inputs).
  • Local privilege escalation or code execution may be possible if written files are later executed or loaded by other components.
  • Data integrity issues can arise through unauthorized modification of workflow inputs or outputs.

General mitigation guidance

Effective mitigation centers on enforcing strict path containment and reducing trust in remote file metadata.

Recommended defensive patterns include:

  • Normalize and resolve all remote path components (e.g., using canonical path utilities) before combining them with local destinations, and reject any path that would escape the configured base directory.
  • Treat any server-supplied filename or directory name as untrusted input and validate against an allowlist of patterns, rejecting unsafe sequences such as .., absolute paths, or drive letters.
  • Run Airflow workers under operating system accounts with minimal filesystem privileges so that even if traversal occurs, critical paths are not writable.
  • Isolate download directories onto dedicated volumes or sandboxes where writes cannot affect application code, configuration, or system binaries.
  • Prefer narrowly scoped sync patterns (e.g., target subdirectories or curated file lists) rather than broad recursive downloads from untrusted SFTP sources.

How teams detect issues like this

Detection focuses on both code-level review and runtime monitoring:

  • Use static analysis or code review to flag any file-write operations that concatenate external input (like remote filenames) with local paths without canonicalization and containment checks.
  • Search for implementations that rely on simple string operations (e.g., naive concatenation or prefix checks) to enforce directory boundaries, rather than using resolved absolute paths.
  • Implement logging around SFTP download operations, recording resolved local paths and alerting when writes target directories outside known safe roots.
  • Apply filesystem monitoring or intrusion detection on Airflow worker hosts to detect unexpected file creation or modification in sensitive locations during SFTP-based tasks.
  • Integrate automated security scanning into CI/CD pipelines to identify path traversal patterns across provider hooks and custom operators.

Sources

SourceLink
github.comgithub.com/apache/airflow/pull/67985
lists.apache.orglists.apache.org/thread/7f4b284oh44c1n95oq8mh1qc7y1lr9dx
openwall.comopenwall.com/lists/oss-security/2026/06/16/3

Frequently asked

questions

Yes. Any attacker who controls or has compromised the remote SFTP server can exploit the issue when an Airflow task connects and downloads a directory, even without access to Airflow itself.

No. The vulnerability is triggered by Airflow connecting to a malicious or compromised SFTP server. As long as a DAG is already configured to download from that server, no Airflow authentication is required for exploitation.

The safest approach is to enforce strict path normalization and containment checks, ensuring that all computed local paths remain under a predefined base directory, and to reject or sanitize any remote entries that would escape that directory.

Treat all remotely supplied paths as untrusted, use canonical path resolution before file operations, validate against explicit directory boundaries, and run data-transfer components with least-privilege filesystem access and strong logging to catch anomalies early.

Find out what's already
exploitable in your codebase.