//nefariousplan

CVE-2026-49818: Apache Patched The Samba Operator. The SFTP Sibling Still Calls os.path.join.

vendor

pattern

cve

proof of concept

Apache published an oss-security advisory for the Airflow Samba provider on 2026-06-09. The vulnerable function, GCSToSambaOperator._resolve_destination_path, ended with return os.path.join(self.destination_path, source_object). The fix at PR #67857 added os.path.normpath and a startswith(base + os.sep) prefix check, the actual sandbox primitive Python's os.path.join is not. Six days later, in the same Apache Airflow repository, GCSToSFTPOperator._resolve_destination_path at line 179 of gcs_to_sftp.py still returns os.path.join(self.destination_path, source_object). Same function name. Same line. Same trust shape. CVE-2026-49818 closed the operator the researcher named.

The advisory tells you who is hostile

The CVE description, posted by Jarek Potiuk to oss-security on 2026-06-09, reads in full:

The Apache Airflow Samba provider's GCSToSambaOperator joined GCS object names to the SMB destination path without a containment check, so an object named with ../ segments resolved a write path outside the configured destination_path. An attacker able to write objects into the source GCS bucket, typically an external data producer distinct from the trusted DAG author, could write files to arbitrary locations on the Samba target when the operator ran.

That phrasing is more careful than a CVE record usually is. It encodes the operator's design surface in one sentence. The DAG author chooses the source bucket and the destination path. The entity that writes objects into the source bucket is, by the operator's own use case, somebody else. The whole point of a GCS-to-SMB transfer is to move data across an organizational boundary: from a producer who packages files into a bucket your team subscribes to, onto a Windows file share inside your network. The bucket's writers and the share's readers are separate populations by design.

That makes source_object an attacker-controlled string for any operator instance whose source_bucket accepts writes from anyone the DAG author does not directly employ. Which is most of them. Data exchange between organizations is what the operator exists for.

The variable's type signature is source_object: str. Read the name. The name implies "a path under the bucket root that the trusted DAG author selected." The bytes are whatever a GCS bucket accepts as an object key. GCS accepts ../../etc/cron.d/runme.

os.path.join is normalize, not sandbox

Pre-patch, the function read:

def _resolve_destination_path(self, source_object: str, prefix: str | None = None) -> str:
    if not self.keep_directory_structure:
        if prefix:
            source_object = os.path.relpath(source_object, start=prefix)
        else:
            source_object = os.path.basename(source_object)
    return os.path.join(self.destination_path, source_object)

The variable name says destination_path. The function name says _resolve_destination_path. The body composes a base with a caller-supplied segment and returns the result. The pattern's name in our catalog is Join Is Not Sandbox: code reaches for os.path.join, filepath.Join, or path.join to compose a base directory with an untrusted segment, and reads the composition as a scoping primitive. The standard library defined that function as a normalizing primitive. The two behaviors disagree at exactly the inputs that matter.

>>> import os
>>> os.path.join("media", "../../etc/cron.d/runme")
'media/../../etc/cron.d/runme'
>>> os.path.normpath(_)
'../etc/cron.d/runme'
>>> os.path.join("media", "/etc/cron.d/runme")
'/etc/cron.d/runme'

os.path.join does not refuse .. segments. It does not refuse absolute paths. Python's documentation states both behaviors, has stated them for two decades, and they are the documented behaviors. Sandboxing was never on offer. The operator never called normpath. The downstream samba_hook.push_from_local(destination_path, ...) does what an SMB client does with a write path: it opens it, walks the .. segments at the protocol layer, writes there.

The structural mistake is reading the name of the standard-library helper as the contract. The helper joins two strings into a path string. The contract the developer believed was "scope the second argument under the first." That contract requires a second call. The function as written never made it.

The patch added the line the standard library does not provide

The PR #67857 diff, in full:

-        return os.path.join(self.destination_path, source_object)
+        # Source object names come from the GCS bucket and may contain ".." segments.
+        # Normalize the joined path and make sure it stays within destination_path so a
+        # crafted object name cannot resolve a write target outside the configured directory.
+        resolved = os.path.normpath(os.path.join(self.destination_path, source_object))
+        base = os.path.normpath(self.destination_path)
+        if resolved != base and not resolved.startswith(base + os.sep):
+            raise ValueError(
+                f"Resolved destination path {resolved!r} is outside the configured "
+                f"destination_path {base!r}; refusing to write outside it."
+            )
+        return resolved

os.path.normpath collapses .. segments into the absolute or relative form the filesystem will actually act on. The startswith(base + os.sep) prefix check is the standard Python idiom for "this resolved path is contained under this base." Together they are the post-join verification the pattern's name demands. The patch is correct, narrow, and tested.

The committed test parameterization in providers/samba/tests/unit/samba/transfers/test_gcs_to_samba.py reads:

@pytest.mark.parametrize(
    "source_object",
    [
        "../../victim_area/payload",
        "../escape",
        "subdir/../../escape",
    ],
)
def test_resolve_destination_path_rejects_traversal(self, source_object):
    ...
    with pytest.raises(ValueError, match="outside the configured"):
        operator._resolve_destination_path(source_object)

The test's parametrize list is also the reproducer for any operator running a pre-4.12.6 Samba provider against an attacker-writable bucket. One of those object names, dropped into the source bucket the DAG points at, lands the corresponding file under the SMB share's traversal of destination_path on the next operator run.

A small accuracy note: the oss-security advisory describes the fix as raising AirflowException. The shipped commit raises ValueError. The caller's experience is identical: the task fails before any SMB write.

The sibling operator was not patched

The Samba provider was not the original. The Airflow operator pattern for "copy a GCS object onto a remote filesystem" was first implemented for SFTP, in the Google provider's providers/google/cloud/transfers/gcs_to_sftp.py. The Samba operator is a near-line-for-line copy of that file, with the SFTPHook swapped for SambaHook. The function names, the constructor arguments, the docstring example, the wildcard handling, the _resolve_destination_path and _copy_single_object methods all derive from the SFTP version. diff between the two files reports differences in the module docstring, the class name, the connection-id default, and the addition of a buffer_size parameter. The path-handling logic is identical.

The current state of apache/airflow main, as of 2026-06-15:

def _resolve_destination_path(self, source_object: str, prefix: str | None = None) -> str:
    if not self.keep_directory_structure:
        if prefix:
            source_object = os.path.relpath(source_object, start=prefix)
        else:
            source_object = os.path.basename(source_object)
    return os.path.join(self.destination_path, source_object)

That is GCSToSFTPOperator._resolve_destination_path at lines 173 through 179 of gcs_to_sftp.py. Same function name as the patched Samba function. Same conditional rewrite of source_object. Same final return. The diff between this function and the pre-patch GCSToSambaOperator._resolve_destination_path is zero useful lines.

A search of apache/airflow open and closed pull requests for gcs_to_sftp plus path traversal returns nothing. There is no fix in flight for the sibling. The Samba CVE was published 2026-06-09. The Samba PR landed 2026-06-02. Today is 2026-06-15. The function still returns the join.

The same DAG, swapping GCSToSambaOperator for GCSToSFTPOperator, exhibits the same primitive against a different protocol. An object named ../../etc/cron.d/runme in the source bucket lands, after the operator's _copy_single_object calls sftp_hook.store_file(destination_path, ...), at the resolved path the SFTP server walks the same way the SMB server walked it: by following the segments. The Google provider is the most-installed Airflow provider in the ecosystem. The SFTP operator is one of its data-egress workhorses. The fix authored for one file applies, with the variable name samba replaced by sftp, to the other.

GCSToSambaOperator was patched. GCSToSFTPOperator in the same repository still returns os.path.join(self.destination_path, source_object).

The fourth exhibit on Join Is Not Sandbox

The pattern's prior exhibits in our catalog are:

  • Casdoor's Go function LocalFileSystemProvider.GetFullPath, where filepath.Join(BaseDir, path) plus filepath.Abs was read as a sandbox.
  • DbGate's Node function unzipDirectory, where path.join(outputDirectory, entry.fileName) was trusted to scope writes inside an extracted archive.
  • NASA AIT-Core's Python function _get_log_file, where os.path.join(handler["log_dir"], handler["path"], filename) exposed Python's absolute-path-overwrite behavior to a REST API.

CVE-2026-49818 is the fourth exhibit, and the second Python case. The first Python exhibit hit the absolute-path-overwrite variant: when the caller controls an argument that starts with /, os.path.join discards every prior argument. This case hits the .. segment variant: when the caller controls an argument whose .. segments walk past the base, os.path.normpath of the join walks past the base too. Both behaviors are documented. Both are sandbox-breaking for code that omitted the post-join verification. Both keep recurring in code authored by experienced maintainers in well-reviewed codebases.

The patches across the four exhibits converge on the same shape: normalize the join, then check that the result is the base or starts with the base plus separator. The standard libraries do not export that combined primitive. Every codebase that wants the sandbox writes the same four lines, and every codebase that doesn't is one CVE away from writing them.

Apache patched the operator that was reported. The sibling that was not reported still ships the line.